Skip to content

Commit 939f901

Browse files
authored
Test: Prefer config.destination and default ember-basic-dropdown-wormhole (#946)
* Prefer config.destination and default 'ember-basic-dropdown-wormhole' over root element as destination in tests Close #943 * Fix linting issues
1 parent c8a4c67 commit 939f901

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

ember-basic-dropdown/src/components/basic-dropdown.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,28 @@ export default class BasicDropdown extends Component<BasicDropdownSignature> {
405405
};
406406

407407
if (config.environment === 'test') {
408-
// document doesn't exists in fastboot apps, for this reason we need this check
408+
// document doesn't exist in fastboot apps, for this reason we need this check
409409
if (typeof document === 'undefined') {
410410
return 'ember-basic-dropdown-wormhole';
411411
}
412+
413+
// check if destination exists in tests:
414+
if (
415+
config['ember-basic-dropdown'] &&
416+
config['ember-basic-dropdown'].destination
417+
) {
418+
const destination = config['ember-basic-dropdown'].destination;
419+
if (document.getElementById(destination) !== null) {
420+
return destination;
421+
}
422+
}
423+
424+
// check if default element exists in tests:
425+
if (document.getElementById('ember-basic-dropdown-wormhole') !== null) {
426+
return 'ember-basic-dropdown-wormhole';
427+
}
428+
429+
// fall back to rootElement as destination
412430
const rootElement = config['APP']?.rootElement;
413431
return (
414432
document.querySelector(rootElement)?.id ??

0 commit comments

Comments
 (0)