Skip to content

Commit

Permalink
Add tests to verify packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
kmtusher97 committed Nov 20, 2024
1 parent 78189c7 commit 00e22d7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/unit-test.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,12 @@ jobs:
- name: Install dependencies
run: npm install

- name: Link repo-toc package
run: |
npm Link
cd tests
npm link repo-toc
cd ..
- name: Run tests
run: npm test
25 changes: 25 additions & 0 deletions tests/runPackage.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const fs = require("fs");
const { generateTableOfContent } = require("repo-toc");

describe("test repo-toc package", () => {
test("should generate TOC on marker less markdown file", () => {
const dirPath = __dirname + "/mocks";

const filePath = __dirname + "/" + "temp.md";

fs.writeFileSync(filePath, "## Table of contents");
generateTableOfContent({ dirPath, filePath });

const fileContent = fs.readFileSync(filePath, "utf8");

expect(fileContent).toContain(
`* [TestFile3](./TestFile3.md)\n* **test-files**\n * [Test File 1 Title](./test-files/TestFile1.md)\n`
);

fs.unlink(filePath, (err) => {
if (err) {
throw err;
}
});
});
});

0 comments on commit 00e22d7

Please sign in to comment.