From e2b8e351cda0058478435be304535489aacb68a2 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Mon, 6 Feb 2023 12:55:44 +1100 Subject: [PATCH] Restore reregistration unit test --- packages/experiments/src/test/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/experiments/src/test/index.js b/packages/experiments/src/test/index.js index f2953b7f4a195a..2456d5ca5039d9 100644 --- a/packages/experiments/src/test/index.js +++ b/packages/experiments/src/test/index.js @@ -37,6 +37,18 @@ describe( '__dangerousOptInToUnstableAPIsOnlyForCoreModules', () => { /This feature is only for JavaScript modules shipped with WordPress core/ ); } ); + it( 'Should not register the same module twice', () => { + expect( () => { + __dangerousOptInToUnstableAPIsOnlyForCoreModules( + requiredConsent, + '@experiments/test' + ); + __dangerousOptInToUnstableAPIsOnlyForCoreModules( + requiredConsent, + '@experiments/test' + ); + } ).toThrow( /is already registered/ ); + } ); it( 'Should grant access to unstable APIs when passed both a consent string and a previously unregistered package name', () => { const unstableAPIs = __dangerousOptInToUnstableAPIsOnlyForCoreModules( requiredConsent,