Skip to content

Commit

Permalink
Merge pull request #51 from mkim219/add-unit-test
Browse files Browse the repository at this point in the history
add more unit test for CI
  • Loading branch information
Eugene Chung authored Nov 19, 2021
2 parents 1b7056f + 094cb77 commit 37a379b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async function createHtmlFileTest(basename, data, stylesheet = "", outputPath) {
style: stylesheet,
fileExtname: path.extname(basename),
};
const underscoreFileName = fileName.replaceAll(" ", "_");
//const underscoreFileName = fileName.replaceAll(" ", "_");

//dont actually write the file.

Expand Down Expand Up @@ -330,4 +330,5 @@ module.exports = {
displayError,
createHtmlFile,
createHtmlFileTest,
createIndexHtmlFile
};
25 changes: 25 additions & 0 deletions test/helper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-disable no-undef */
const path = require("path");
const { isFileCheck } = require("./../bin/helper");
const { createIndexHtmlFile } = require("./../bin/helper");

describe("IsFileCheck check", () => {
it("Check for correct file", () => {
Expand Down Expand Up @@ -78,4 +79,28 @@ describe("Render HTML", () => {
expect(data.replace(/\s/g, "")).toBe(expectedHtml.replace(/\s/g, ""));
});
});

describe("Should IsFileCheck return false with .docx, .cs, .html",()=> {
it("Check for .docx", () => {
const file = ".docx";
expect(isFileCheck(file)).toBe(false);
});

it("Check for .cs", () => {
const file = ".cs";
expect(isFileCheck(file)).toBe(false);
});

it("Check for .html", () => {
const file = ".html";
expect(isFileCheck(file)).toBe(false);
});
});

const fs = require('fs');
test("Should createIndexHtmlFile generate index.html", async ()=>{
await createIndexHtmlFile(['dummpy1', 'dummy2'],"",'./dist');
const result = fs.existsSync('./dist/index.html');
expect(result).toBe(true);
});
});

0 comments on commit 37a379b

Please sign in to comment.