Skip to content

Commit 1960efa

Browse files
committed
chore: fix tests
1 parent 909a4b8 commit 1960efa

7 files changed

+68
-36
lines changed

Diff for: package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "api.mojis.dev",
33
"type": "module",
44
"private": true,
5-
"packageManager": "[email protected].4",
5+
"packageManager": "[email protected].5",
66
"scripts": {
77
"dev": "wrangler dev",
88
"build": "wrangler deploy --dry-run --outdir=dist",
@@ -18,20 +18,20 @@
1818
"dependencies": {
1919
"@hono/zod-openapi": "^0.19.2",
2020
"@mojis/internal-utils": "^0.0.5",
21-
"@scalar/hono-api-reference": "^0.7.1",
21+
"@scalar/hono-api-reference": "^0.7.2",
2222
"hono": "^4.7.4",
2323
"zod": "^3.24.2"
2424
},
2525
"devDependencies": {
26-
"@cloudflare/vitest-pool-workers": "^0.8.1",
26+
"@cloudflare/vitest-pool-workers": "^0.8.2",
2727
"@luxass/eslint-config": "^4.17.1",
2828
"@stoplight/spectral-cli": "^6.14.3",
2929
"eslint": "^9.22.0",
3030
"eslint-plugin-format": "^1.0.1",
3131
"tsx": "^4.19.3",
3232
"typescript": "^5.8.2",
3333
"vitest": "^3.0.9",
34-
"wrangler": "^4.1.0"
34+
"wrangler": "^4.2.0"
3535
},
3636
"pnpm": {
3737
"onlyBuiltDependencies": [

Diff for: pnpm-lock.yaml

+29-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/routes/v1_categories.ts

-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ V1_CATEGORIES_ROUTER.openapi(ALL_CATEGORIES_ROUTE, async (c) => {
2020
const version = c.req.param("version");
2121

2222
const res = await c.env.EMOJI_DATA.get(`v${version}/groups.json`);
23-
2423
if (res == null) {
2524
throw new HTTPException(500, {
2625
message: "failed to fetch categories",
@@ -30,7 +29,6 @@ V1_CATEGORIES_ROUTER.openapi(ALL_CATEGORIES_ROUTE, async (c) => {
3029
const data = await res.json();
3130

3231
const result = z.array(EmojiCategorySchema).safeParse(data);
33-
3432
if (!result.success) {
3533
return createError(c, 500, "failed to parse categories");
3634
}

Diff for: test/routes/v1_categories.test.ts

+28-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,36 @@ import {
44
env,
55
waitOnExecutionContext,
66
} from "cloudflare:test";
7-
import { describe, expect, it } from "vitest";
7+
import { beforeAll, describe, expect, it } from "vitest";
88
import worker from "../../src";
99

10+
beforeAll(async () => {
11+
await env.EMOJI_DATA.put("v15.1/groups.json", JSON.stringify([
12+
{
13+
name: "Smileys & Emotion",
14+
slug: "smileys-emotion",
15+
subgroups: [
16+
"face-smiling",
17+
"face-affection",
18+
"face-tongue",
19+
"face-hand",
20+
"face-neutral-skeptical",
21+
"face-sleepy",
22+
"face-unwell",
23+
"face-hat",
24+
"face-glasses",
25+
"face-concerned",
26+
"face-negative",
27+
"face-costume",
28+
"cat-face",
29+
"monkey-face",
30+
"heart",
31+
"emotion",
32+
],
33+
},
34+
]));
35+
});
36+
1037
describe("v1_categories", () => {
1138
it("should return 404 for non-existent version", async () => {
1239
const request = new Request("https://api.mojis.dev/api/v1/categories/999.0");

Diff for: tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"resolveJsonModule": true,
88
"types": [
99
"./worker-configuration.d.ts",
10+
"./worker-configuration-test.d.ts",
1011
// for `cloudflare:test` types
1112
"@cloudflare/vitest-pool-workers"
1213
],

Diff for: vitest.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default defineWorkersProject({
66
poolOptions: {
77
workers: {
88
singleWorker: true,
9+
isolatedStorage: true,
910
miniflare: {
1011
compatibilityFlags: ["nodejs_compat"],
1112
bindings: {

Diff for: worker-configuration-test.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module "cloudflare:test" {
2+
// eslint-disable-next-line ts/no-empty-object-type
3+
interface ProvidedEnv extends CloudflareBindings {
4+
}
5+
}

0 commit comments

Comments
 (0)