1import { ExpoConfig } from '@expo/config'; 2import fs from 'fs'; 3import { vol } from 'memfs'; 4import path from 'path'; 5 6import { withGradleProperties } from '../android-plugins'; 7import { evalModsAsync } from '../mod-compiler'; 8import { getAndroidModFileProviders, withAndroidBaseMods } from '../withAndroidBaseMods'; 9import rnFixture from './fixtures/react-native-project'; 10 11jest.mock('fs'); 12 13describe(withGradleProperties, () => { 14 const projectRoot = '/app'; 15 16 beforeEach(async () => { 17 vol.fromJSON( 18 { 19 ...rnFixture, 20 }, 21 projectRoot 22 ); 23 }); 24 25 afterEach(() => { 26 vol.reset(); 27 }); 28 29 it(`is passed gradle.properties`, async () => { 30 let config: ExpoConfig = { 31 name: 'foobar', 32 slug: 'foobar', 33 }; 34 35 config = withGradleProperties(config, (config) => { 36 config.modResults.push({ type: 'comment', value: 'expo-test' }); 37 config.modResults.push({ type: 'empty' }); 38 config.modResults.push({ type: 'property', key: 'foo', value: 'bar' }); 39 config.modResults.push({ type: 'empty' }); 40 config.modResults.push({ type: 'comment', value: 'end-expo-test' }); 41 return config; 42 }); 43 config = withAndroidBaseMods(config, { 44 providers: { 45 gradleProperties: getAndroidModFileProviders().gradleProperties, 46 }, 47 }); 48 49 await evalModsAsync(config, { 50 projectRoot, 51 platforms: ['android'], 52 assertMissingModProviders: true, 53 }); 54 55 const contents = fs.readFileSync(path.join(projectRoot, 'android/gradle.properties'), 'utf8'); 56 expect(contents.endsWith('# expo-test\n\nfoo=bar\n\n# end-expo-test')).toBe(true); 57 }); 58}); 59