Skip to content

Commit

Permalink
Restore filesystem after tests
Browse files Browse the repository at this point in the history
  • Loading branch information
troyharvey committed Oct 20, 2016
1 parent b3cef35 commit afc19b2
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions test/TearDownCommandTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ let fsMock = require('mock-fs');
let TearDownCommand = require('../src/TearDownCommand');

describe('Tear down command tests', () => {

after(fsMock.restore);

it("should throw an error when a seeded data json file doesn't exist", () =>{
let drivers = {};

Expand All @@ -16,6 +19,22 @@ describe('Tear down command tests', () => {
}
};

let tearDownCommand = new TearDownCommand(
driverLocator,
fs,
'./path/to/seed.json'
);

expect(tearDownCommand.run.bind(tearDownCommand)).to.throw(
'ENOENT: no such file or directory, open \'./path/to/seed.json\''
);

});

it('should throw an error when there is no driver for a seeded object', () => {

let drivers = {};

fsMock({
'seededData.json': JSON.stringify([
{
Expand All @@ -25,16 +44,21 @@ describe('Tear down command tests', () => {
}
}
])
})
});

let driverLocator = {
drivers: function () {
return drivers;
}
};

let tearDownCommand = new TearDownCommand(
driverLocator,
fs,
'./path/to/seed.json'
fs
);

expect(tearDownCommand.run.bind(tearDownCommand)).to.throw(
'Error: ENOENT, no such file or directory \'./path/to/seed.json\''
'Seeded data file does not contain a type that you have a driver for'
);

});
Expand Down

0 comments on commit afc19b2

Please sign in to comment.