Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"exclude": ["**/_fresh/*"],
"imports": {
"#src/": "./src/",
"$fresh/": "https://deno.land/x/fresh@1.6.8/",
"$fresh/": "https://deno.land/x/fresh@1.7.1/",
"$fresh_charts/": "https://deno.land/x/fresh_charts@0.3.1/",
"$std/": "https://deno.land/std@0.216.0/",
"$gfm": "jsr:@deno/gfm@^0.8.2",
Expand Down
2 changes: 1 addition & 1 deletion src/fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import * as $Countdown from "./islands/Countdown.tsx";
import * as $Counter from "./islands/Counter.tsx";
import * as $MapIsland from "./islands/MapIsland.tsx";
import * as $NextContentButton from "./islands/NextContentButton.tsx";
import { type Manifest } from "$fresh/server.ts";
import type { Manifest } from "$fresh/server.ts";

const manifest = {
routes: {
Expand Down
1 change: 1 addition & 0 deletions tests/main_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as modAssert from "https://deno.land/std@0.224.0/assert/assert.ts";

const CONN_INFO: ServeHandlerInfo = {
remoteAddr: { hostname: "127.0.0.1", port: 8000, transport: "tcp" },
completed: Promise.resolve(),
};

const verifyPageContainsText = async (
Expand Down
33 changes: 33 additions & 0 deletions tests/utils/api_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as modAssertEqual from "https://deno.land/std@0.224.0/assert/assert_equals.ts";
import * as modAssertThrows from "https://deno.land/std@0.224.0/assert/assert_throws.ts";
import { getUserKey, handleUserNotFound, statusCheck } from "#src/utils/api.ts";

Deno.test("statusCheck", async (t) => {
await t.step("#1 throws error when status is falsy", () => {
modAssertThrows.assertThrows(
() => statusCheck(null as unknown as Deno.KvCommitResult),
Error,
"Something went wrong.",
);
});

await t.step("#2 does not throw when status is truthy", () => {
const mockStatus = {} as Deno.KvCommitResult;
statusCheck(mockStatus);
});
});

Deno.test("getUserKey returns correct user key", () => {
const id = "123";
const expectedKey = ["user", "123"];
modAssertEqual.assertEquals(getUserKey(id), expectedKey);
});

Deno.test("handleUserNotFound returns correct response", async () => {
const id = "123";
const response = handleUserNotFound(id);
modAssertEqual.assertEquals(response.status, 200);

const bodyText = await response.text();
modAssertEqual.assertEquals(bodyText, `No user with id ${id} found`);
});