1import os from 'os'; 2 3import { getContext } from '../rudderstackClient'; 4 5jest.mock('ci-info', () => ({ isCI: true, isPR: true, name: 'GitHub Actions' })); 6 7describe(getContext, () => { 8 const originalVersion = process.env.__EXPO_VERSION; 9 const knownPlatformNames = { 10 darwin: 'Mac', 11 linux: 'Linux', 12 win32: 'Windows', 13 }; 14 15 beforeEach(() => { 16 delete process.env.__EXPO_VERSION; 17 }); 18 19 afterAll(() => { 20 process.env.__EXPO_VERSION = originalVersion; 21 }); 22 23 it('contains os name and version', () => { 24 expect(getContext().os).toMatchObject({ 25 name: knownPlatformNames[os.platform()] || os.platform(), 26 version: os.release(), 27 }); 28 }); 29 30 it('contains device type and model', () => { 31 expect(getContext().device).toMatchObject({ 32 type: knownPlatformNames[os.platform()] || os.platform(), 33 model: knownPlatformNames[os.platform()] || os.platform(), 34 }); 35 }); 36 37 it('contains app name and version', () => { 38 process.env.__EXPO_VERSION = '1337'; 39 expect(getContext().app).toMatchObject({ 40 name: 'expo', 41 version: '1337', 42 }); 43 }); 44 45 it('contains ci name and if its executed from PR', () => { 46 expect(getContext().ci).toMatchObject({ 47 name: 'GitHub Actions', 48 isPr: true, 49 }); 50 }); 51}); 52