Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: Prefer config.destination and default ember-basic-dropdown-wormhole #946

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion ember-basic-dropdown/src/components/basic-dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,28 @@ export default class BasicDropdown extends Component<BasicDropdownSignature> {
};

if (config.environment === 'test') {
// document doesn't exists in fastboot apps, for this reason we need this check
// document doesn't exist in fastboot apps, for this reason we need this check
if (typeof document === 'undefined') {
return 'ember-basic-dropdown-wormhole';
}

// check if destination exists in tests:
if (
config['ember-basic-dropdown'] &&
config['ember-basic-dropdown'].destination
) {
const destination = config['ember-basic-dropdown'].destination;
if (document.getElementById(destination) !== null) {
return destination;
}
}

// check if default element exists in tests:
if (document.getElementById('ember-basic-dropdown-wormhole') !== null) {
return 'ember-basic-dropdown-wormhole';
}

// fall back to rootElement as destination
const rootElement = config['APP']?.rootElement;
return (
document.querySelector(rootElement)?.id ??
Expand Down