1import nock from 'nock'; 2 3import { getExpoApiBaseUrl } from '../endpoint'; 4import { getExpoGoIntermediateCertificateAsync } from '../getExpoGoIntermediateCertificate'; 5 6jest.mock('../user/actions', () => ({ 7 ensureLoggedInAsync: jest.fn(), 8})); 9 10beforeAll(() => { 11 process.env.EXPO_NO_CACHE = 'true'; 12}); 13 14describe(getExpoGoIntermediateCertificateAsync, () => { 15 it('gets project development certificate', async () => { 16 const scope = nock(getExpoApiBaseUrl()) 17 .get( 18 '/v2/projects/4254c843-457a-4a6e-9b21-1506dc175ba4/development-certificates/expo-go-intermediate-certificate' 19 ) 20 .reply(200, 'hello'); 21 const cert = await getExpoGoIntermediateCertificateAsync( 22 '4254c843-457a-4a6e-9b21-1506dc175ba4' 23 ); 24 expect(cert).toBe('hello'); 25 expect(scope.isDone()).toBe(true); 26 }); 27 it('fails when the servers are down', async () => { 28 const scope = nock(getExpoApiBaseUrl()) 29 .get('/v2/projects/123/development-certificates/expo-go-intermediate-certificate') 30 .reply(500, 'something went wrong'); 31 await expect(getExpoGoIntermediateCertificateAsync('123')).rejects.toThrowError(/Expo server/); 32 expect(scope.isDone()).toBe(true); 33 }); 34}); 35