From 954cad4494184b3f1e5ba67953b195ec0f505b3a Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Sat, 19 Jul 2025 16:09:32 -0700 Subject: [PATCH] feat: tests and workflow --- .gitea/workflows/ci.yml | 38 ++++++++++++++++++++++++++++++++++++++ package.json | 5 +++-- pnpm-lock.yaml | 3 +++ test/assets.spec.ts | 37 +++++++++++++++++++++++++++++++++++++ tsconfig.json | 3 ++- vitest.config.ts | 10 ++++++++++ 6 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 .gitea/workflows/ci.yml create mode 100644 test/assets.spec.ts create mode 100644 vitest.config.ts diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..cf414e4 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,38 @@ +name: Node.js CI +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + lint: + name: Lint and Test + + steps: + - name: Checkout Source Files + uses: actions/checkout@v4 + + - name: Use Node.js v22 + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 9 + + - name: Install Dependencies + run: pnpm install + + - name: Lint Source Files + run: pnpm run lint + + - name: Verify Build + run: pnpm run build + + - name: Run Tests + run: pnpm run test \ No newline at end of file diff --git a/package.json b/package.json index da17084..b283c39 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "lint": "eslint ./src --max-warnings 0", "build": "tsc", "start": "op run --env-file=./prod.env -- node ./prod/index.js", - "test": "echo 'No tests yet' && exit 0" + "test": "vitest run" }, "keywords": [], "author": "", @@ -18,7 +18,8 @@ "@nhcarrigan/eslint-config": "5.2.0", "@nhcarrigan/typescript-config": "4.0.0", "eslint": "9.31.0", - "typescript": "5.8.3" + "typescript": "5.8.3", + "vitest": "3.2.4" }, "dependencies": { "@nhcarrigan/logger": "1.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b2f43fa..15c058f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,6 +30,9 @@ importers: typescript: specifier: 5.8.3 version: 5.8.3 + vitest: + specifier: 3.2.4 + version: 3.2.4(@types/node@24.0.15) packages: diff --git a/test/assets.spec.ts b/test/assets.spec.ts new file mode 100644 index 0000000..1b7f305 --- /dev/null +++ b/test/assets.spec.ts @@ -0,0 +1,37 @@ +/** + * @copyright nhcarrigan + * @license Naomi's Public License + * @author Naomi Carrigan + */ + +import { describe, it, expect } from "vitest"; +import { anime } from "../src/assets/anime.js"; +import { cats } from "../src/assets/cats.js"; +import { emoji } from "../src/assets/emoji.js"; + +const uniqueAnime = new Set(anime.map((art) => { + return art.text; +})); +const uniqueCats = new Set(cats.map((art) => { + return art.text; +})); +const uniqueEmoji = new Set(emoji.map((art) => { + return art.text; +})); + +describe("assets", () => { + it("anime should be unique", () => { + expect.assertions(1); + expect(uniqueAnime.size, "anime has duplicate art").toBe(anime.length); + }); + + it("cats should be unique", () => { + expect.assertions(1); + expect(uniqueCats.size, "cats has duplicate art").toBe(cats.length); + }); + + it("emoji should be unique", () => { + expect.assertions(1); + expect(uniqueEmoji.size, "emoji has duplicate art").toBe(emoji.length); + }); +}); diff --git a/tsconfig.json b/tsconfig.json index 1bc7c7b..85810b4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,5 +3,6 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./prod" - } + }, + "exclude": ["test", "vitest.config.ts"] } diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..0de7aca --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,10 @@ +/** + * @copyright nhcarrigan + * @license Naomi's Public License + * @author Naomi Carrigan + */ + + +import { defineConfig } from "vitest/config"; + +export default defineConfig({});