Skip to content

Commit

Permalink
fix(unit tests): fix error with fs unlink usage
Browse files Browse the repository at this point in the history
  • Loading branch information
acamposruiz committed May 27, 2019
1 parent 7155ed2 commit 5f98c9d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ describe('shared / Regenerators / RegenerateModelIndex', () => {

expect(result).to.equal(true);
expect(fileExists(fakeModelPath)).to.equal(true);
fs.unlink(fakeModelPath);
fs.unlink(fakeModelPath, (err) => {
if (err) {
console.log("failed to delete local file:"+err);
} else {
console.log('successfully deleted local file');
}
});

});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ describe('shared / Generators / RegenerateReducerIndex', () => {

expect(result).to.equal(true);
expect(fileExists(fakeReducerPath)).to.equal(true);
fs.unlink(fakeReducerPath);
fs.unlink(fakeReducerPath, (err) => {
if (err) {
console.log("failed to delete local file:"+err);
} else {
console.log('successfully deleted local file');
}
});

});
});
Expand Down
16 changes: 14 additions & 2 deletions src/base/shared/spec/FileSystem.shared.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ describe('shared / FileSystem', () => {

const readed = readFile(file, 'utf8');

fs.unlink(file);
fs.unlink(file, (err) => {
if (err) {
console.log("failed to delete local file:"+err);
} else {
console.log('successfully deleted local file');
}
});
expect(readed).to.equal(content);

});
Expand All @@ -54,7 +60,13 @@ describe('shared / FileSystem', () => {
writeFile(file,content);

const wrote = fs.readFileSync(file, "utf8");
fs.unlink(file);
fs.unlink(file, (err) => {
if (err) {
console.log("failed to delete local file:"+err);
} else {
console.log('successfully deleted local file');
}
});

expect(wrote).to.equal(content);

Expand Down

0 comments on commit 5f98c9d

Please sign in to comment.