diff --git a/packages/global-registrator/src/GlobalRegistrator.ts b/packages/global-registrator/src/GlobalRegistrator.ts index 6cc615da5..c0854cf54 100644 --- a/packages/global-registrator/src/GlobalRegistrator.ts +++ b/packages/global-registrator/src/GlobalRegistrator.ts @@ -11,7 +11,7 @@ export default class GlobalRegistrator { */ public static register(): void { if (this.registered.length) { - throw new Error('Failed to registered. Happy DOM has already been globally registered.'); + throw new Error('Failed to register. Happy DOM has already been globally registered.'); } const window = new GlobalWindow(); for (const key of Object.keys(window)) { @@ -26,9 +26,9 @@ export default class GlobalRegistrator { * Registers Happy DOM globally. */ public static unregister(): void { - if (this.registered.length) { + if (!this.registered.length) { throw new Error( - 'Failed to unregistered. Happy DOM has not previously been globally registered.' + 'Failed to unregister. Happy DOM has not previously been globally registered.' ); } for (const key of this.registered) { diff --git a/packages/global-registrator/test/react/React.test.tsx b/packages/global-registrator/test/react/React.test.tsx index 0d371d53c..3130031c0 100644 --- a/packages/global-registrator/test/react/React.test.tsx +++ b/packages/global-registrator/test/react/React.test.tsx @@ -26,3 +26,5 @@ function unmountReactComponent(): void { mountReactComponent(); unmountReactComponent(); + +GlobalRegistrator.unregister();