-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathappBase.test.ts
More file actions
63 lines (55 loc) · 1.73 KB
/
appBase.test.ts
File metadata and controls
63 lines (55 loc) · 1.73 KB
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
import { describe, expect, it } from "vitest";
import {
APP_ROUTE_PATHS,
deriveAppBasePath,
getAppPath,
getOidcCallbackUrl,
normalizeAppIndexUrl,
resolveAppUrl,
} from "./appBase";
describe("deriveAppBasePath", () => {
it("uses the bundled asset location outside development", () => {
expect(
deriveAppBasePath({
dev: false,
pathname: "/runme-dev-assets/runs",
moduleUrl:
"https://storage.googleapis.com/runme-dev-assets/index.BdN4INbO.js",
}),
).toBe("/runme-dev-assets/");
});
it("falls back to the current document path in development", () => {
expect(
deriveAppBasePath({
dev: true,
pathname: "/runme-dev-assets/index.html",
}),
).toBe("/runme-dev-assets/");
});
});
describe("app base URL helpers", () => {
it("resolves app-relative paths beneath the mounted base path", () => {
window.history.replaceState(null, "", "/runme-dev-assets/index.html");
const origin = window.location.origin;
expect(getAppPath(APP_ROUTE_PATHS.oidcCallback)).toBe(
"/runme-dev-assets/oidc/callback",
);
expect(resolveAppUrl("configs/app-configs.yaml").toString()).toBe(
`${origin}/runme-dev-assets/configs/app-configs.yaml`,
);
expect(getOidcCallbackUrl()).toBe(
`${origin}/runme-dev-assets/oidc/callback`,
);
});
it("normalizes index.html entry URLs to the directory path", () => {
window.history.replaceState(
null,
"",
"/runme-dev-assets/index.html?doc=foo#section-1",
);
normalizeAppIndexUrl();
expect(window.location.pathname).toBe("/runme-dev-assets/");
expect(window.location.search).toBe("?doc=foo");
expect(window.location.hash).toBe("#section-1");
});
});