Skip to content

Commit

Permalink
Update insert.test.js
Browse files Browse the repository at this point in the history
Add tests for App.tsx
  • Loading branch information
KBirzins authored and yousif-bugsnag committed Jan 9, 2025
1 parent e6e370a commit b1eae0e
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions packages/expo-cli/lib/test/insert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,32 @@ describe('expo-cli: insert', () => {
expect(appTsAfter).toBe(appTsBefore)
})
})

it('shouldn’t insert if @bugsnag/expo is already imported (import, tsx)', async () => {
await withFixture('already-configured-ts-import', async (projectRoot) => {
const appTsBefore = await readFile(`${projectRoot}/App.tsx`, 'utf8')
const msg = await insert(projectRoot)
expect(msg).toMatch(/already/)

const appTsAfter = await readFile(`${projectRoot}/App.txs`, 'utf8')
expect(appTsAfter).toBe(appTsBefore)
})
})

it('shouldn’t insert if @bugsnag/expo is already imported (require, tsx)', async () => {
await withFixture('already-configured-ts-require', async (projectRoot) => {
const appTsBefore = await readFile(`${projectRoot}/App.tsx`, 'utf8')
const msg = await insert(projectRoot)
expect(msg).toMatch(/already/)

const appTsAfter = await readFile(`${projectRoot}/App.tsx`, 'utf8')
expect(appTsAfter).toBe(appTsBefore)
})
})

it('should provide a reasonable error when there is no App.js or App.ts', async () => {
it('should provide a reasonable error when there is no App.js or App.ts/tsx', async () => {
await withFixture('empty-00', async (projectRoot) => {
await expect(insert(projectRoot)).rejects.toThrow(/^Couldnt find App\.js or App\.ts in/)
await expect(insert(projectRoot)).rejects.toThrow(/^Couldnt find App\.js or App\.ts\/tsx in/)
})
})

Expand Down

0 comments on commit b1eae0e

Please sign in to comment.