From 588ca4bcd619f5e0fd7c132d73755906dcc98908 Mon Sep 17 00:00:00 2001 From: K Om Senapati Date: Mon, 10 Feb 2025 18:54:50 +0530 Subject: [PATCH] add test to check all footprint are in src/footprinter.ts (#178) * add test to check all footprint are in src/footprinter.ts * ci: add bun test workflow --- .github/workflows/bun-test.yml | 28 ++++++++++++++++++++++++++++ tests/footprint-completeness.test.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 .github/workflows/bun-test.yml create mode 100644 tests/footprint-completeness.test.ts diff --git a/.github/workflows/bun-test.yml b/.github/workflows/bun-test.yml new file mode 100644 index 0000000..8426cd1 --- /dev/null +++ b/.github/workflows/bun-test.yml @@ -0,0 +1,28 @@ +# Created using @tscircuit/plop (npm install -g @tscircuit/plop) +name: Bun Test + +on: + pull_request: + push: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Install dependencies + run: bun install + + - name: Run tests + run: bun test \ No newline at end of file diff --git a/tests/footprint-completeness.test.ts b/tests/footprint-completeness.test.ts new file mode 100644 index 0000000..4aa9113 --- /dev/null +++ b/tests/footprint-completeness.test.ts @@ -0,0 +1,26 @@ +import { describe, expect, it } from "bun:test" +import { getFootprintNames } from "../src/footprinter" +import fs from "fs" +import path from "path" + +describe("footprint completeness", () => { + it("should expose all footprint functions from src/fn/", () => { + const fnDir = path.join(process.cwd(), "src", "fn") + const footprintFiles = fs + .readdirSync(fnDir) + .filter((file) => file.endsWith(".ts") && file !== "index.ts") + .map((file) => path.basename(file, ".ts")) + + const exposedFootprints = getFootprintNames() + + for (const file of footprintFiles) { + expect(exposedFootprints.includes(file)).toBe(true) + } + + for (const footprint of exposedFootprints) { + expect(footprintFiles.includes(footprint)).toBe(true) + } + + expect(footprintFiles.length).toBe(exposedFootprints.length) + }) +})