Skip to content

Commit

Permalink
write to file tested.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKarlsson committed Jan 22, 2018
1 parent 74f52eb commit be90404
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions __mocks__/fs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = jest.genMockFromModule('fs');

const __writeFile = path => {
return path;
const __writeFile = (path, script, cb) => {
return cb(null, path);
};

fs.writeFile = __writeFile;
Expand Down
17 changes: 17 additions & 0 deletions src/getScript/helper/writeToFile.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const writeToFile = require('./writeToFile');

jest.mock('fs');

describe('writeToFile', () => {
it('should return the file path of the script that is written to the FS', () => {
const path = 'script/frozen.html';
const mockScript = 'MOCK SCRIPT';
writeToFile(path, mockScript)
.then(result => {
expect(result).toBe(path);
})
.catch(err => {
console.error(err);
});
});
});

0 comments on commit be90404

Please sign in to comment.