-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathcreate-catalog.test.ts
216 lines (209 loc) · 5.18 KB
/
create-catalog.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import { expect } from "chai";
import { createCatalog } from "../src/createCatalog";
describe("Create catalog", () => {
const validWCAG = {
title: "WCAG 2.0",
lang: "en",
standard: [
{
id: "wcag-2.0",
label: "Web Content Accessibility Guidelines 2.0",
report_heading: "WCAG 2.0 Report",
url: "https://www.w3.org/TR/WCAG20/",
chapters: ["success_criteria_level_a"],
},
],
chapters: [
{
id: "success_criteria_level_a",
label: "Success Criteria, Level A",
order: 1,
criteria: [
{
id: "1.1.1",
handle: "Non-text Content (Level A)",
alt_id: "text-equiv",
components: [
"web",
"electronic-docs",
"software",
"authoring-tool",
],
},
{
id: "1.2.2",
handle: "1.2.2 Captions (Prerecorded) (Level A)",
alt_id: "media-equiv",
components: [
"web",
"electronic-docs",
"software",
"authoring-tool",
],
},
],
},
],
};
const validSection508 = {
title: "WCAG 2.0",
lang: "en",
standard: [
{
id: "508",
label:
"Revised Section 508 standards published January 18, 2017 and corrected January 22, 2018",
report_heading: "Revised Section 508 Report",
url: "https://www.access-board.gov/ict/",
chapters: ["hardware"],
},
],
chapters: [
{
id: "hardware",
label: "Hardware",
order: 4,
criteria: [
{
id: "402",
handle: "Closed Functionality",
alt_id: "402-closed-functionality",
components: [],
},
{
id: "402.1",
handle: "General",
alt_id: "402.1",
components: [],
},
],
},
],
};
const validComponents = {
title: "Components",
lang: "en",
components: [
{
id: "web",
label: "Web",
},
{
id: "electronic-docs",
label: "Electronic Documents",
},
{
id: "software",
label: "Software",
},
{
id: "authoring-tool",
label: "Authoring Tool",
},
{
id: "none",
label: "",
},
],
};
const validTerms = {
title: "Terms",
lang: "en",
terms: [
{
id: "supports",
label: "Supports",
description:
"The functionality of the product has at least one method that meets the criterion without known defects or meets with equivalent facilitation.",
},
{
id: "partially-supports",
label: "Partially Supports",
description:
"Some functionality of the product does not meet the criterion.",
},
{
id: "does-not-support",
label: "Does Not Support",
description:
"The majority of product functionality does not meet the criterion.",
},
{
id: "not-applicable",
label: "Not Applicable",
description: "The criterion is not relevant to the product.",
},
{
id: "not-evaluated",
label: "Not Evaluated",
description:
"The product has not been evaluated against the criterion. This can be used only in WCAG 2.0 Level AAA.",
},
],
};
let result;
it("pass valid catalogs should have valid standards", () => {
result = createCatalog(
[validWCAG, validSection508],
validComponents,
validTerms,
"VPAT",
"en"
);
expect(result.standards[0].id).to.equal("wcag-2.0");
expect(result.standards[1].id).to.equal("508");
});
it("pass invalid section508 should have undefined standards and chapters", () => {
result = createCatalog(
[validWCAG, {}],
validComponents,
validTerms,
"VPAT",
"en"
);
expect(result.standards).to.be.undefined;
expect(result.chapters).to.be.undefined;
});
it("pass invalid WCAG should have undefined standards and chapters", () => {
result = createCatalog(
[{}, validSection508],
validComponents,
validTerms,
"VPAT",
"en"
);
expect(result.standards).to.be.undefined;
expect(result.chapters).to.be.undefined;
});
it("pass invalid components should have undefined components", () => {
result = createCatalog(
[validWCAG, validSection508],
{},
validTerms,
"VPAT",
"en"
);
expect(result.components).to.be.undefined;
});
it("pass invalid terms should have undefined terms", () => {
result = createCatalog(
[validWCAG, validSection508],
validComponents,
{},
"VPAT",
"en"
);
expect(result.terms).to.be.undefined;
});
it("pass null WCAG and invalid section508 should have undefined standards and chapters", () => {
result = createCatalog(
[null, {}],
validComponents,
validTerms,
"VPAT",
"en"
);
expect(result.standards).to.be.undefined;
expect(result.chapters).to.be.undefined;
});
});