-
Notifications
You must be signed in to change notification settings - Fork 716
/
validate-dev-props.test.ts
56 lines (48 loc) · 2.1 KB
/
validate-dev-props.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { validateDevProps } from "../dev/validate-dev-props";
import type { DevProps } from "../dev/dev";
describe("validateDevProps", () => {
it("should throw if the user tries to use the service-worker format with an `assets` directory", () => {
const props = {
isWorkersSite: false,
legacyAssetPaths: ["assets"],
entry: { format: "service-worker" },
bindings: {},
};
expect(() => validateDevProps(props as unknown as DevProps)).toThrowError(
"You cannot use the service-worker format with an `assets` directory yet. For information on how to migrate to the module-worker format, see: https://developers.cloudflare.com/workers/learning/migrating-to-module-workers/"
);
});
it("should throw if the user tries to configure [wasm_modules] with an ES module worker", () => {
const props = {
isWorkersSite: false,
legacyAssetPaths: [],
entry: { format: "modules" },
bindings: { wasm_modules: true },
};
expect(() => validateDevProps(props as unknown as DevProps)).toThrowError(
"You cannot configure [wasm_modules] with an ES module worker. Instead, import the .wasm module directly in your code"
);
});
it("should throw if the user tries to configure [text_blobs] with an ES module worker", () => {
const props = {
isWorkersSite: false,
legacyAssetPaths: [],
entry: { format: "modules" },
bindings: { text_blobs: true },
};
expect(() => validateDevProps(props as unknown as DevProps)).toThrowError(
"You cannot configure [text_blobs] with an ES module worker. Instead, import the file directly in your code, and optionally configure `[rules]` in your wrangler.toml"
);
});
it("should throw if the user tries to configure [data_blobs] with an ES module worker", () => {
const props = {
isWorkersSite: false,
legacyAssetPaths: [],
entry: { format: "modules" },
bindings: { data_blobs: true },
};
expect(() => validateDevProps(props as unknown as DevProps)).toThrowError(
"You cannot configure [data_blobs] with an ES module worker. Instead, import the file directly in your code, and optionally configure `[rules]` in your wrangler.toml"
);
});
});