Skip to content

Commit

Permalink
chore(jest): clean up after tampering with globals
Browse files Browse the repository at this point in the history
  • Loading branch information
drepram committed Apr 22, 2022
1 parent c2e353d commit d6aa02f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion utilities/BlobToBase64.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ describe('convert blob to base 64 successfully', () => {
})

describe('convert blob to base 64 failing', () => {
test('file is jpeg', async () => {
const original = global.FileReader
beforeAll(() => {
Object.defineProperty(global, 'FileReader', {
writable: true,
value: jest.fn().mockImplementation(() => ({
Expand All @@ -29,6 +30,14 @@ describe('convert blob to base 64 failing', () => {
onload: jest.fn(),
})),
})
})
afterAll(() => {
Object.defineProperty(global, 'FileReader', {
writable: true,
value: original,
})
})
test('file is jpeg', async () => {
const jpegBlob = new Blob(['testing'], { type: 'image/jpeg' })

try {
Expand Down

0 comments on commit d6aa02f

Please sign in to comment.