Skip to content

Commit

Permalink
Adding tests for createTmpDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
ollelauribostrom committed Jan 20, 2019
1 parent 7500c2b commit 89ebeca
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/createTmpDirectory.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const fs = require('fs');
const os = require('os');
const path = require('path');
const createTmpDirectory = require('../src/utils/createTmpDirectory');

jest.mock('fs');
jest.mock('os');
jest.mock('path');

describe('Tests for createTmpDirectory', () => {
it('creates a tempyrary directory based on the os.tmpdir path', () => {
fs.mkdtempSync = jest.fn(dir => dir);
os.tmpdir = jest.fn(() => 'tmp-test');
path.sep = '/';
expect(createTmpDirectory()).toEqual('tmp-test/');
expect(fs.mkdtempSync).toHaveBeenCalledTimes(1);
expect(os.tmpdir).toHaveBeenCalledTimes(1);
});
});

0 comments on commit 89ebeca

Please sign in to comment.