-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.test.js
90 lines (82 loc) · 2.58 KB
/
index.test.js
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const translateRoutingDestination = require(".");
const {
questionnaireJson,
questionnaireJsonWithSummary,
} = require("../../basicQuestionnaireJSON");
describe("Translation of a routing destination", () => {
it("should translate an absolute destination to another Page", () => {
const ctx = {
questionnaireJson: {
sections: [{ folders: [{ pages: [{ id: "2" }] }] }],
},
};
const authorDestination = {
pageId: "2",
};
expect(
translateRoutingDestination(
authorDestination,
authorDestination.pageId,
ctx
)
).toMatchObject({
block: "2",
});
});
it("should translate an absolute destination to another Section", () => {
const authorDestination = {
sectionId: "2",
};
expect(
translateRoutingDestination(authorDestination, "2", { questionnaireJson })
).toMatchObject({
group: "group2",
});
});
it("should translate a next page destination", () => {
const authorDestination = {
logical: "NextPage",
};
expect(
translateRoutingDestination(authorDestination, "1", { questionnaireJson })
).toMatchObject({ block: "2" });
});
it("should translate a next page destination when last page in section", () => {
const authorDestination = {
logical: "NextPage",
};
expect(
translateRoutingDestination(authorDestination, "2", { questionnaireJson })
).toMatchObject({ group: "group2" });
});
it("should translate a next page destination as confirmation-group when last page in questionnaire", () => {
const authorDestination = {
logical: "NextPage",
};
expect(
translateRoutingDestination(authorDestination, "4", { questionnaireJson })
).toMatchObject({ group: "confirmation-group" });
});
it("should translate a next page destination as summary when last page in questionnaire", () => {
const authorDestination = {
logical: "NextPage",
};
expect(
translateRoutingDestination(authorDestination, "4", {
questionnaireJson: questionnaireJsonWithSummary,
})
).toMatchObject({ group: "summary-group" });
});
it("should fail if not provided any destinations", () => {
const authorDestination = {};
expect(() => translateRoutingDestination(authorDestination)).toThrow(
"not a valid destination object"
);
});
it("should fail if provided a non-valid logical type", () => {
const authorDestination = { logical: "Foo" };
expect(() => translateRoutingDestination(authorDestination)).toThrow(
"not a valid destination type"
);
});
});