diff --git a/packages/react-native-worklets/__tests__/plugin.test.ts b/packages/react-native-worklets/__tests__/plugin.test.ts index 868f29af34ac..73dc3d64d3e3 100644 --- a/packages/react-native-worklets/__tests__/plugin.test.ts +++ b/packages/react-native-worklets/__tests__/plugin.test.ts @@ -540,6 +540,52 @@ describe('babel plugin', () => { }); }); + describe('for bundle mode runtime entry', () => { + const workletRuntimeEntryFilename = + '/tmp/react-native-worklets/src/initializers/workletRuntimeEntry.native.ts'; + + test('enables bundle mode in worklet runtime entry', () => { + const input = html``; + + const { code } = runPlugin(input, undefined, { + bundleMode: true, + }, workletRuntimeEntryFilename); + + expect(code).toContain('globalThis._WORKLETS_BUNDLE_MODE_ENABLED = true;'); + }); + + test('allows react-native imports when explicitly configured', () => { + const input = html``; + + const { code } = runPlugin(input, undefined, { + bundleMode: true, + workletizableModules: ['react-native'], + }, workletRuntimeEntryFilename); + + expect(code).toContain( + 'globalThis._WORKLETS_REACT_NATIVE_IMPORTS_ALLOWED = true;' + ); + }); + + test("doesn't allow react-native imports by default", () => { + const input = html``; + + const { code } = runPlugin(input, undefined, { + bundleMode: true, + }, workletRuntimeEntryFilename); + + expect(code).toContain( + 'globalThis._WORKLETS_REACT_NATIVE_IMPORTS_ALLOWED = false;' + ); + }); + }); + describe('for explicit worklets', () => { test('workletizes FunctionDeclaration', () => { const input = html`