Skip to content

Commit

Permalink
tests: improve appendFile test-case
Browse files Browse the repository at this point in the history
  • Loading branch information
hemal7735 authored and evenstensberg committed Feb 5, 2019
1 parent be7b259 commit 18bde78
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/test-utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,20 @@ Child ${config2Name}:
describe("appendFile functionality", () => {
describe("positive test-cases", () => {
const junkFile = resolve(__dirname, "junkFile.js");
const initialJunkData = "initial junk data";
const junkComment = "//junk comment";

beforeEach(() => {
writeFileSync(junkFile, "");
writeFileSync(junkFile, initialJunkData);
});
afterEach(() => {
unlinkSync(junkFile);
});
it("should append data to file if file exists", () => {
const expectedData = "//junk comment";
appendDataIfFileExists(__dirname, junkFile, expectedData);
appendDataIfFileExists(__dirname, junkFile, junkComment);
const actualData = readFileSync(junkFile).toString();

expect(actualData).toBe(expectedData);
expect(actualData).toBe(initialJunkData + junkComment);
});
});

Expand Down

0 comments on commit 18bde78

Please sign in to comment.