Skip to content

Commit

Permalink
use consistent BasicDropdownWormhole behaviour in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed Aug 7, 2024
1 parent b078018 commit 2f3fe4d
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions ember-basic-dropdown/src/components/basic-dropdown-wormhole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,13 @@ export interface BasicDropdownWormholeSignature {

export default class BasicDropdownWormholeComponent extends Component<BasicDropdownWormholeSignature> {
get getDestinationId(): string {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error resolveRegistration not typed
const config = getOwner(this).resolveRegistration('config:environment') as {
environment: string;
APP: {
rootElement: string;
};
'ember-basic-dropdown': {
destination: string;
'ember-basic-dropdown'?: {
destination?: string;
};
};

if (config.environment === 'test') {
// document doesn't exists in fastboot apps, for this reason we need this check
if (typeof document === 'undefined') {
return '';
}
const rootElement = config['APP']?.rootElement;
return document.querySelector(rootElement)?.id ?? '';
}

return ((config['ember-basic-dropdown'] &&
config['ember-basic-dropdown'].destination) ||
'ember-basic-dropdown-wormhole') as string;
Expand Down

0 comments on commit 2f3fe4d

Please sign in to comment.