From 7880ad2f46c042b151dc066011e8c288cf5e678d Mon Sep 17 00:00:00 2001 From: Jussi Laasonen Date: Wed, 31 Oct 2018 14:08:50 +0100 Subject: [PATCH] Migrate specs to jest --- package.json | 2 +- spec/main.spec.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 2c1bb87..008cd6a 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "standard": { "parser": "babel-eslint", "env": { - "jasmine": true, + "jest": true, "node": true } }, diff --git a/spec/main.spec.js b/spec/main.spec.js index b1392a9..afbcdec 100644 --- a/spec/main.spec.js +++ b/spec/main.spec.js @@ -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)) }) })