Skip to content

Commit

Permalink
Move tests
Browse files Browse the repository at this point in the history
  • Loading branch information
penalosa committed Nov 20, 2024
1 parent 4d565fa commit 5f07397
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 126 deletions.
5 changes: 0 additions & 5 deletions fixtures/asset-config/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions fixtures/asset-config/env.d.ts

This file was deleted.

24 changes: 0 additions & 24 deletions fixtures/asset-config/package.json

This file was deleted.

15 changes: 0 additions & 15 deletions fixtures/asset-config/tsconfig.json

This file was deleted.

52 changes: 0 additions & 52 deletions fixtures/asset-config/vitest.config.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { SELF } from "cloudflare:test";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { applyConfigurationDefaults } from "../../packages/workers-shared/asset-worker/src/configuration";
import Worker from "../../packages/workers-shared/asset-worker/src/index";
import { getAssetWithMetadataFromKV } from "../../packages/workers-shared/asset-worker/src/utils/kv";
import { applyConfigurationDefaults } from "../src/configuration";
import Worker from "../src/index";
import { getAssetWithMetadataFromKV } from "../src/utils/kv";
import { encodingTestCases } from "./test-cases/encoding-test-cases";
import { htmlHandlingTestCases } from "./test-cases/html-handling-test-cases";
import type { AssetMetadata } from "../../packages/workers-shared/asset-worker/src/utils/kv";
import type { AssetMetadata } from "../src/utils/kv";

const IncomingRequest = Request<unknown, IncomingRequestCfProperties>;

vi.mock("../../packages/workers-shared/asset-worker/src/utils/kv.ts");
vi.mock("../../packages/workers-shared/asset-worker/src/configuration");
vi.mock("../src/utils/kv.ts");
vi.mock("../src/configuration");
const existsMock = (fileList: Set<string>) => {
vi.spyOn(Worker.prototype, "unstable_exists").mockImplementation(
async (pathname: string) => {
Expand All @@ -22,14 +22,6 @@ const existsMock = (fileList: Set<string>) => {
};
const BASE_URL = "http://example.com";

export type TestCase = {
title: string;
files: string[];
requestPath: string;
matchedFile?: string;
finalPath?: string;
};

const testSuites = [
{
title: "htmlHanding options",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TestCase } from "../html-handling.test";
import { TestCase } from "./test-case";

Check failure on line 1 in packages/workers-shared/asset-worker/tests/test-cases/encoding-test-cases.ts

View workflow job for this annotation

GitHub Actions / Checks

All imports in the declaration are only used as types. Use `import type`

export const encodingTestCases: {
html_handling:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TestCase } from "../html-handling.test";
import { TestCase } from "./test-case";

Check failure on line 1 in packages/workers-shared/asset-worker/tests/test-cases/html-handling-test-cases.ts

View workflow job for this annotation

GitHub Actions / Checks

All imports in the declaration are only used as types. Use `import type`

export const htmlHandlingTestCases: {
html_handling:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export type TestCase = {
title: string;
files: string[];
requestPath: string;
matchedFile?: string;
finalPath?: string;
};
2 changes: 1 addition & 1 deletion packages/workers-shared/asset-worker/tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"@cloudflare/vitest-pool-workers"
]
},
"include": ["**/*.test.ts"]
"include": ["**/*.ts"]
}
7 changes: 4 additions & 3 deletions packages/workers-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@
"bundle:router-worker": "esbuild router-worker/src/index.ts --format=esm --bundle --outfile=dist/router-worker.mjs --sourcemap=external",
"bundle:router-worker:prod": "pnpm run bundle:router-worker --minify",
"check:lint": "eslint . --max-warnings=0",
"check:type": "tsc -p ./tsconfig.json && tsc -p ./tsconfig.node.json",
"check:type": "pnpm run check:type:package && pnpm run check:type:asset-worker && pnpm run check:type:router-worker",
"check:type:asset-worker": "tsc -p ./asset-worker/tsconfig.json && tsc -p ./asset-worker/tests/tsconfig.json",
"check:type:package": "tsc -p ./tsconfig.json && tsc -p ./tsconfig.node.json",
"check:type:router-worker": "tsc -p ./router-worker/tsconfig.json && tsc -p ./router-worker/tests/tsconfig.json",
"clean": "rimraf dist",
"deploy": "pnpm run deploy:router-worker && pnpm run deploy:asset-worker",
"deploy:asset-worker": "CLOUDFLARE_API_TOKEN=$WORKERS_DEPLOY_AND_CONFIG_CLOUDFLARE_API_TOKEN pnpx wrangler versions upload --experimental-versions -c asset-worker/wrangler.toml",
"deploy:router-worker": "CLOUDFLARE_API_TOKEN=$WORKERS_DEPLOY_AND_CONFIG_CLOUDFLARE_API_TOKEN pnpx wrangler versions upload --experimental-versions -c router-worker/wrangler.toml",
"dev": "pnpm run clean && concurrently -n bundle:asset-worker,bundle:router-worker -c blue,magenta \"pnpm run bundle:asset-worker --watch\" \"pnpm run bundle:router-worker --watch\"",
"test": "vitest",
"test:ci": "vitest run",
"test": "vitest -c asset-worker/vitest.config.mts",
"test:ci": "vitest run -c asset-worker/vitest.config.mts",
"types:emit": "tsc index.ts --declaration --emitDeclarationOnly --declarationDir ./dist"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/workers-shared/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"lib": ["es2021"],
"module": "es2022",
"moduleResolution": "Bundler",
"types": ["@cloudflare/workers-types/experimental"],
"types": ["@cloudflare/workers-types/experimental", "@types/node"],
"noEmit": true,
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
},
"include": ["**/*.ts"],
"include": ["utils/*.ts"],
"exclude": ["scripts/**"]
}

0 comments on commit 5f07397

Please sign in to comment.