Skip to content

Commit

Permalink
test: update/create tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiofranca02 committed Aug 1, 2023
1 parent f055b73 commit a95df8c
Show file tree
Hide file tree
Showing 10 changed files with 660 additions and 310 deletions.
9 changes: 9 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @type {import('jest').Config}
*/
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/tests/__mocks__'],
coveragePathIgnorePatterns: ['./src/index.ts'],
}
20 changes: 20 additions & 0 deletions tests/__mocks__/mockFileReader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
global.window = {
// @ts-ignore
FileReader: class MockFileReader {
onload: any = null
onerror: any = null
result = ''

async readAsText(blob: Blob) {
try {
if (blob instanceof Blob) {
const result = await blob.text()
this.onload({ target: { result } })
} else
this.onerror({ target: { error: new DOMException('Invalid blob') } })
} catch (error) {
this.onerror({ target: { error } })
}
}
},
}
Loading

0 comments on commit a95df8c

Please sign in to comment.