diff --git a/test/e2e/components/Application.test.tsx b/test/e2e/components/Application.test.tsx index 90e4c282..875c6905 100644 --- a/test/e2e/components/Application.test.tsx +++ b/test/e2e/components/Application.test.tsx @@ -9,6 +9,7 @@ import { render } from '@testing-library/react'; import { useEffect } from 'react'; import { Application } from '../../../src/components/Application'; +import { isAppMounted } from '../../utils/isAppMounted'; import { useApplication } from '../../../src/hooks/useApplication'; describe('Application', () => { @@ -65,7 +66,7 @@ describe('Application', () => { unmount(); - await expect.poll(() => Boolean(testApp.renderer && testApp.stage)).toBeFalsy(); + await expect.poll(() => isAppMounted(testApp)).toBeFalsy(); }); it('unmounts during init', async () => { @@ -106,7 +107,7 @@ describe('Application', () => { unmount(); - await expect.poll(() => Boolean(testApp.renderer && testApp.stage)).toBeFalsy(); + await expect.poll(() => isAppMounted(testApp)).toBeFalsy(); }); }); }); diff --git a/test/utils/getAppRoot.ts b/test/utils/getAppRoot.ts new file mode 100644 index 00000000..dcf8763b --- /dev/null +++ b/test/utils/getAppRoot.ts @@ -0,0 +1,19 @@ +import { type Application as PixiApplication } from 'pixi.js'; +import { roots } from '../../src/core/roots'; +import { type Root } from '../../src/typedefs/Root'; + +export function getAppRoot(app: PixiApplication) +{ + let root: Root | undefined; + + for (const oRoot of roots.values()) + { + if (oRoot.applicationState.app === app) + { + root = oRoot; + break; + } + } + + return root; +} diff --git a/test/utils/isAppMounted.ts b/test/utils/isAppMounted.ts new file mode 100644 index 00000000..6bae6556 --- /dev/null +++ b/test/utils/isAppMounted.ts @@ -0,0 +1,22 @@ +import { type Application as PixiApplication } from 'pixi.js'; +import { getAppRoot } from './getAppRoot'; + +export function isAppMounted(app: PixiApplication) +{ + if (app.stage === null) + { + return false; + } + + if (app.renderer === null) + { + return false; + } + + if (typeof getAppRoot(app) === 'undefined') + { + return false; + } + + return true; +}