42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { strict as assert } from "node:assert";
|
|
import { test } from "node:test";
|
|
import { parseStartupDeepLinkIntent } from "../lib/startupDeepLink";
|
|
|
|
test("all supported startup URLs map to stable intents", () => {
|
|
const fixtures = [
|
|
["jrshikoku://open/felica", "felicaHistory"],
|
|
["jrshikoku://topMenu/setting/FelicaHistoryPage", "felicaHistory"],
|
|
["jrshikoku://open/traininfo", "trainInfo"],
|
|
["jrshikoku://open/operation", "operation"],
|
|
["jrshikoku://open/settings", "settings"],
|
|
["jrshikoku://open/topmenu", "topMenu"],
|
|
["jrshikoku://positions/apps", "positions"],
|
|
] as const;
|
|
|
|
for (const [url, intent] of fixtures) {
|
|
assert.equal(parseStartupDeepLinkIntent(url), intent, url);
|
|
}
|
|
});
|
|
|
|
test("startup URL parsing remains case-insensitive", () => {
|
|
assert.equal(
|
|
parseStartupDeepLinkIntent("JRSHIKOKU://OPEN/OPERATION"),
|
|
"operation",
|
|
);
|
|
});
|
|
|
|
test("empty and unsupported URLs do not claim startup navigation", () => {
|
|
for (const url of [null, undefined, "", " ", "https://example.com/"]) {
|
|
assert.equal(parseStartupDeepLinkIntent(url), null);
|
|
}
|
|
});
|
|
|
|
test("legacy FeliCa route keeps priority when a malformed URL contains two patterns", () => {
|
|
assert.equal(
|
|
parseStartupDeepLinkIntent(
|
|
"jrshikoku://open/felica?redirect=open/traininfo",
|
|
),
|
|
"felicaHistory",
|
|
);
|
|
});
|