orderListRouteParams.spec.js
1.89 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
64
const {
LEGACY_TAB_PANE,
LEGACY_LABEL_TO_PANE,
resolveTabPaneFromParams,
computeRouteParamPatch,
} = require("@/views/orderManage/utils/orderListRouteParams");
describe("orderListRouteParams", () => {
describe("resolveTabPaneFromParams", () => {
it("maps tabPane 1 to pane key", () => {
expect(resolveTabPaneFromParams({ tabPane: "1" })).toBe("1");
});
it("maps tabLabel order to pane 1", () => {
expect(resolveTabPaneFromParams({ tabLabel: "order" })).toBe("1");
});
it("maps tabLabel integral-shopping to pane 5", () => {
expect(resolveTabPaneFromParams({ tabLabel: "integral-shopping" })).toBe("5");
});
it("returns null for empty params", () => {
expect(resolveTabPaneFromParams({})).toBeNull();
expect(resolveTabPaneFromParams(null)).toBeNull();
});
it("returns null for unknown tabPane", () => {
expect(resolveTabPaneFromParams({ tabPane: "99" })).toBe("99");
});
});
describe("computeRouteParamPatch", () => {
it("maps tabPane 1 to light category and l-1-1 leaf", () => {
expect(computeRouteParamPatch({ tabPane: "1" })).toEqual({
activeCategory: "light",
pendingLegacyLeaf: "l-1-1",
rightsFromLegacyTab4: false,
isApplyingRoute: true,
});
});
it("maps tabPane 4 with carDamage label to rights and legacyRightsAll", () => {
expect(computeRouteParamPatch({ tabPane: "4", tabLabel: "carDamage" })).toEqual({
activeCategory: "rights",
pendingLegacyLeaf: "l-2-1",
rightsFromLegacyTab4: true,
isApplyingRoute: true,
});
});
it("returns null for empty params", () => {
expect(computeRouteParamPatch({})).toBeNull();
});
it("returns null for unknown tabPane mapping", () => {
expect(computeRouteParamPatch({ tabPane: "99" })).toBeNull();
});
});
it("exports legacy maps for orderList shell", () => {
expect(LEGACY_TAB_PANE["1"].category).toBe("light");
expect(LEGACY_LABEL_TO_PANE.order).toBe("1");
});
});