Skip to content

Commit

Permalink
Resolve the filesystem files to work cross-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
negativetwelve committed Nov 9, 2017
1 parent 0fd87cc commit 3eb8c6e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/jest-plugin-fs/src/__tests__/fs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import context from 'jest-plugin-context';
import set from 'jest-plugin-set';
import fsExtra from 'fs-extra';
import path from 'path';
import fs from '../fs';

// Path to the fixtures directory.
Expand Down Expand Up @@ -54,10 +55,7 @@ describe('fs', () => {
});

context('with files', () => {
beforeEach(() => fs.mock({
test: 'content',
hello: 'goodbye',
}));
beforeEach(() => fs.mock({test: 'content', hello: 'goodbye'}));

it('should return the files', () => {
expect(fs.files()).toEqual({'/test': 'content', '/hello': 'goodbye'});
Expand All @@ -81,12 +79,14 @@ describe('fs', () => {

describe('#unmock', () => {
context('with unmocked file', () => {
set('file', () => `${FIXTURES}/test.txt`);
set('filename', () => `${FIXTURES}/test.txt`);

beforeEach(() => fs.unmock([file]));
beforeEach(() => fs.unmock([filename]));

it('should exist in the virtual filesystem', () => {
expect(fsExtra.readFileSync(file, 'utf8')).toEqual('this is a test\n');
expect(
fsExtra.readFileSync(path.resolve(filename), 'utf8'),
).toEqual('this is a test\n');
});
});
});
Expand Down

0 comments on commit 3eb8c6e

Please sign in to comment.