import { applyExclusion, PACKAGE_NAME } from '../plugin/applyExclusion' const base = () => ({ name: 'my-app', version: '1.0.0' }) describe('applyExclusion', () => { it('adds the package to all exclude lists when enabled is false', () => { const out = applyExclusion(base(), { enabled: false }) expect(out.expo.autolinking.exclude).toContain(PACKAGE_NAME) expect(out.expo.autolinking.ios.exclude).toContain(PACKAGE_NAME) expect(out.expo.autolinking.android.exclude).toContain(PACKAGE_NAME) }) it('does not mutate the input', () => { const input = base() applyExclusion(input, { enabled: false }) expect(input).toEqual({ name: 'my-app', version: '1.0.0' }) }) it('is idempotent when excluding (no duplicates)', () => { const once = applyExclusion(base(), { enabled: false }) const twice = applyExclusion(once, { enabled: false }) expect(twice).toEqual(once) expect(twice.expo.autolinking.exclude).toEqual([PACKAGE_NAME]) }) it('removes the package and prunes empty containers when enabled', () => { const excluded = applyExclusion(base(), { enabled: false }) const restored = applyExclusion(excluded, { enabled: true }) expect(restored).toEqual(base()) }) it('treats default (no props) and enabled:true as "include" (removal)', () => { const excluded = applyExclusion(base(), { enabled: false }) expect(applyExclusion(excluded)).toEqual(base()) expect(applyExclusion(excluded, {})).toEqual(base()) }) it('preserves unrelated excludes and other autolinking keys', () => { const pkg = { name: 'my-app', expo: { autolinking: { exclude: ['some-other-pkg'], nativeModulesDir: './modules', }, }, } const out = applyExclusion(pkg, { enabled: false }) expect(out.expo.autolinking.exclude).toEqual([ 'some-other-pkg', PACKAGE_NAME, ]) expect(out.expo.autolinking.nativeModulesDir).toBe('./modules') const back = applyExclusion(out, { enabled: true }) expect(back.expo.autolinking.exclude).toEqual(['some-other-pkg']) expect(back.expo.autolinking.nativeModulesDir).toBe('./modules') }) })