Skip to content

Commit 18bde78

Browse files
hemal7735evenstensberg
authored andcommitted
tests: improve appendFile test-case
1 parent be7b259 commit 18bde78

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

test/test-utils.test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,20 @@ Child ${config2Name}:
107107
describe("appendFile functionality", () => {
108108
describe("positive test-cases", () => {
109109
const junkFile = resolve(__dirname, "junkFile.js");
110+
const initialJunkData = "initial junk data";
111+
const junkComment = "//junk comment";
110112

111113
beforeEach(() => {
112-
writeFileSync(junkFile, "");
114+
writeFileSync(junkFile, initialJunkData);
113115
});
114116
afterEach(() => {
115117
unlinkSync(junkFile);
116118
});
117119
it("should append data to file if file exists", () => {
118-
const expectedData = "//junk comment";
119-
appendDataIfFileExists(__dirname, junkFile, expectedData);
120+
appendDataIfFileExists(__dirname, junkFile, junkComment);
120121
const actualData = readFileSync(junkFile).toString();
121122

122-
expect(actualData).toBe(expectedData);
123+
expect(actualData).toBe(initialJunkData + junkComment);
123124
});
124125
});
125126

0 commit comments

Comments
 (0)