1import { ExpoConfig } from '@expo/config-types'; 2import { vol } from 'memfs'; 3 4import { withEntitlementsPlist, withInfoPlist } from '../ios-plugins'; 5import { evalModsAsync } from '../mod-compiler'; 6import { withIosBaseMods } from '../withIosBaseMods'; 7 8jest.mock('fs'); 9 10describe('entitlements', () => { 11 afterEach(() => { 12 vol.reset(); 13 }); 14 15 it(`evaluates in dry run mode`, async () => { 16 // Ensure this test runs in a blank file system 17 vol.fromJSON({}); 18 let config: ExpoConfig = { name: 'bacon', slug: 'bacon' }; 19 config = withEntitlementsPlist(config, (config) => { 20 config.modResults['haha'] = 'bet'; 21 return config; 22 }); 23 24 // base mods must be added last 25 config = withIosBaseMods(config, { 26 saveToInternal: true, 27 providers: { 28 entitlements: { 29 getFilePath() { 30 return ''; 31 }, 32 async read() { 33 return {}; 34 }, 35 async write() {}, 36 }, 37 }, 38 }); 39 config = await evalModsAsync(config, { projectRoot: '/', platforms: ['ios'] }); 40 41 expect(config.ios?.entitlements).toStrictEqual({ 42 haha: 'bet', 43 }); 44 // @ts-ignore: mods are untyped 45 expect(config.mods.ios.entitlements).toBeDefined(); 46 47 expect(config._internal.modResults.ios.entitlements).toBeDefined(); 48 49 // Ensure no files were written 50 expect(vol.toJSON()).toStrictEqual({}); 51 }); 52}); 53 54describe('infoPlist', () => { 55 afterEach(() => { 56 vol.reset(); 57 }); 58 59 it(`evaluates in dry run mode`, async () => { 60 // Ensure this test runs in a blank file system 61 vol.fromJSON({}); 62 let config: ExpoConfig = { name: 'bacon', slug: 'bacon' }; 63 config = withInfoPlist(config, (config) => { 64 config.modResults['haha'] = 'bet'; 65 return config; 66 }); 67 68 // base mods must be added last 69 config = withIosBaseMods(config, { 70 saveToInternal: true, 71 providers: { 72 infoPlist: { 73 getFilePath() { 74 return ''; 75 }, 76 async read() { 77 return {}; 78 }, 79 async write() {}, 80 }, 81 }, 82 }); 83 config = await evalModsAsync(config, { projectRoot: '/', platforms: ['ios'] }); 84 85 expect(config.ios?.infoPlist).toStrictEqual({ 86 haha: 'bet', 87 }); 88 // @ts-ignore: mods are untyped 89 expect(config.mods.ios.infoPlist).toBeDefined(); 90 91 expect(config._internal.modResults.ios.infoPlist).toBeDefined(); 92 93 // Ensure no files were written 94 expect(vol.toJSON()).toStrictEqual({}); 95 }); 96}); 97