-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.ts
74 lines (60 loc) · 2.09 KB
/
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { unstable_dev } from "wrangler";
import type { UnstableDevWorker } from "wrangler";
describe("Worker", () => {
let worker: UnstableDevWorker;
interface AppleAppSiteAssociation {
activitycontinuation: {
apps: string[];
};
webcredentials?: {
apps: string[];
};
applinks?: {
apps: string[];
details: Array<{
appID: string;
paths: string[];
}>;
};
}
interface AssetLinks {
relation: string[];
target: {
namespace: string;
package_name: string;
sha256_cert_fingerprints: string[];
};
}
beforeAll(async () => {
worker = await unstable_dev("./worker.ts", {
experimental: { disableExperimentalWarning: true },
});
});
afterAll(async () => {
await worker.stop();
});
it("should return the apple-app-site-association JSON on the correct route", async () => {
const resp = await worker.fetch("/.well-known/apple-app-site-association");
expect(resp.status).toBe(200);
expect(resp.headers.get("content-type")).toBe("application/json");
const json = await resp.json() as AppleAppSiteAssociation;
expect(json).toHaveProperty("activitycontinuation");
expect(json.activitycontinuation).toHaveProperty("apps");
expect(json).toHaveProperty("applinks");
expect(json.applinks).toHaveProperty("details");
expect(json.applinks).toHaveProperty("apps");
expect(json.applinks?.details[0]).toHaveProperty("paths");
});
it("should return the assetLinks JSON on the correct route", async () => {
const resp = await worker.fetch("/.well-known/assetlinks.json");
expect(resp.status).toBe(200);
expect(resp.headers.get("content-type")).toBe("application/json");
const json = await resp.json() as Array<AssetLinks>;
const assetLinks = json[0];
expect(assetLinks).toHaveProperty("relation");
expect(assetLinks).toHaveProperty("target");
expect(assetLinks.target).toHaveProperty("namespace");
expect(assetLinks.target).toHaveProperty("package_name");
expect(assetLinks.target).toHaveProperty("sha256_cert_fingerprints");
});
});