From 33dbdfefcc62916bf22ce8367561b6b73f1c8cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20H=C3=A5rek=20Andreassen?= Date: Thu, 11 Apr 2024 21:10:16 +0200 Subject: [PATCH] feat: Add unit-tests (#25) --- .github/workflows/test.yaml | 18 ++ components/Search.tsx | 4 +- deno.json | 8 +- generate-types.ts | 6 +- lib/caching.test.ts | 51 +++++ lib/caching.ts | 72 +++++-- lib/nrk/nrk.test.ts | 52 +++++ lib/nrk/nrk.ts | 192 ++++++++++-------- lib/rss.test.ts | 10 +- lib/rss.ts | 18 +- lib/storage.test.ts | 2 +- lib/test-utils.ts | 35 ++-- lib/utils.ts | 31 +++ routes/api/feeds/[seriesId].ts | 12 +- .../feeds/[seriesId]/[episodeId]/chapters.ts | 16 +- routes/index.tsx | 21 +- utils.ts | 9 - 17 files changed, 384 insertions(+), 173 deletions(-) create mode 100644 .github/workflows/test.yaml create mode 100644 lib/caching.test.ts create mode 100644 lib/nrk/nrk.test.ts create mode 100644 lib/utils.ts delete mode 100644 utils.ts diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..ff8436c --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,18 @@ +name: Test + +on: + push: + +jobs: + run-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Setup deno + uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + - name: Run checks + run: deno task check + - name: Run test + run: deno task test diff --git a/components/Search.tsx b/components/Search.tsx index e264d49..da0863a 100644 --- a/components/Search.tsx +++ b/components/Search.tsx @@ -1,4 +1,4 @@ -export default function Search(props: { defaultValue: string }) { +export default function Search(props: { defaultValue: string | null }) { return (
@@ -8,7 +8,7 @@ export default function Search(props: { defaultValue: string }) { className="border-2 rounded-md px-2" name="query" id="query" - defaultValue={props.defaultValue} + defaultValue={props.defaultValue ?? ""} />