Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Migrate specs to jest
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaasonen committed Oct 31, 2018
1 parent aafa967 commit 7880ad2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"standard": {
"parser": "babel-eslint",
"env": {
"jasmine": true,
"jest": true,
"node": true
}
},
Expand Down
12 changes: 6 additions & 6 deletions spec/main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ const expectedJson = JSON.stringify(ids.map(_id => buildObject({ _id })), null,

describe('main', () => {
beforeEach(() => {
spyOn(fs, 'readFile').and.callFake((file, charset, cb) => cb(null, csv))
spyOn(fs, 'writeFile').and.callFake((file, dict, cb) => cb())
jest.spyOn(fs, 'readFile').mockImplementation((file, charset, cb) => cb(null, csv))
jest.spyOn(fs, 'writeFile').mockImplementation((file, dict, cb) => cb())
})

it('reads the given file', async () => {
await main(csvFilename).catch(fail)
expect(fs.readFile).toHaveBeenCalledWith(csvFilename, 'utf8', jasmine.any(Function))
await main(csvFilename)
expect(fs.readFile).toHaveBeenCalledWith(csvFilename, 'utf8', expect.any(Function))
})

it('writes output to fragmentarium.json', async () => {
await main(csvFilename).catch(fail)
expect(fs.writeFile).toHaveBeenCalledWith(jsonFileName, expectedJson, jasmine.any(Function))
await main(csvFilename)
expect(fs.writeFile).toHaveBeenCalledWith(jsonFileName, expectedJson, expect.any(Function))
})
})

0 comments on commit 7880ad2

Please sign in to comment.