1import nock from 'nock'; 2 3import { getExpoApiBaseUrl } from '../endpoint'; 4import { updateDevelopmentSessionAsync } from '../updateDevelopmentSession'; 5 6describe(updateDevelopmentSessionAsync, () => { 7 it('update development session', async () => { 8 const scope = nock(getExpoApiBaseUrl()) 9 .post('/v2/development-sessions/notify-alive?deviceId=123') 10 .reply(200, require('./fixtures/native-modules/44.0.0.json')); 11 await updateDevelopmentSessionAsync({ 12 deviceIds: ['123'], 13 exp: { 14 name: 'Test', 15 description: 'Test', 16 slug: 'test', 17 primaryColor: '#ffffff', 18 }, 19 runtime: 'native', 20 url: 'https://example.com', 21 }); 22 23 expect(scope.isDone()).toBe(true); 24 }); 25 it('fails when the servers are down', async () => { 26 const scope = nock(getExpoApiBaseUrl()) 27 .post('/v2/development-sessions/notify-alive?deviceId=123') 28 .reply(500, 'something went wrong'); 29 await expect( 30 updateDevelopmentSessionAsync({ 31 deviceIds: ['123'], 32 exp: { 33 name: 'Test', 34 description: 'Test', 35 slug: 'test', 36 primaryColor: '#ffffff', 37 }, 38 runtime: 'native', 39 url: 'https://example.com', 40 }) 41 ).rejects.toThrowError(/Expo server/); 42 expect(scope.isDone()).toBe(true); 43 }); 44}); 45