1import { ExpoConfig } from 'expo/config'; 2import { AndroidConfig, IOSConfig } from 'expo/config-plugins'; 3 4import withUpdates from '../withUpdates'; 5 6jest.mock('@expo/config'); 7 8describe('Updates plugin', () => { 9 beforeAll(() => { 10 const config = getConfig(); 11 jest.spyOn(AndroidConfig.Updates, 'withUpdates').mockReturnValue(config); 12 jest.spyOn(IOSConfig.Updates, 'withUpdates').mockReturnValue(config); 13 }); 14 15 afterAll(() => { 16 jest.clearAllMocks(); 17 }); 18 19 it('calls platforms', () => { 20 withUpdates(getConfig()); 21 22 // @ts-ignore: this is an expect extension and is not defined on the type 23 const _ = expect.literallyAnything(); 24 expect(AndroidConfig.Updates.withUpdates).toHaveBeenCalledWith(_); 25 expect(IOSConfig.Updates.withUpdates).toHaveBeenCalledWith(_); 26 }); 27}); 28 29function getConfig(options = {}): ExpoConfig { 30 return { 31 name: 'foo', 32 slug: 'my-app', 33 ...options, 34 }; 35} 36 37// expect.anything() doesn't match for undefined | null 38expect.extend({ 39 literallyAnything: () => { 40 return { 41 message: () => 'This value is ignored', 42 pass: true, 43 }; 44 }, 45}); 46