coh-content-db 1.4.1 → 2.0.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +24 -0
- package/.github/workflows/build.yml +38 -0
- package/.github/workflows/pull-request.yml +32 -0
- package/.github/workflows/release.yml +52 -0
- package/CHANGELOG.md +42 -0
- package/LICENSE +24 -674
- package/README.md +101 -16
- package/dist/coh-content-db.d.ts +988 -22
- package/dist/coh-content-db.js +1044 -2
- package/dist/coh-content-db.js.map +1 -0
- package/dist/coh-content-db.mjs +1009 -0
- package/dist/coh-content-db.mjs.map +1 -0
- package/eslint.config.mjs +31 -0
- package/jest.config.mjs +7 -0
- package/package.json +31 -23
- package/rollup.config.mjs +27 -0
- package/src/main/api/alignment.ts +19 -0
- package/src/main/api/alternate-data.ts +22 -0
- package/src/main/api/archetype-data.ts +5 -0
- package/src/main/api/badge-data.ts +81 -0
- package/src/main/api/badge-requirement-data.ts +64 -0
- package/src/main/api/badge-requirement-type.ts +32 -0
- package/src/main/api/badge-type.ts +19 -0
- package/src/main/api/bundle-data.ts +47 -0
- package/src/main/api/bundle-header-data.ts +37 -0
- package/src/main/api/contact-data.ts +48 -0
- package/src/main/api/enhancement-category.ts +30 -0
- package/src/main/api/link.ts +4 -0
- package/src/main/api/location-data.ts +28 -0
- package/src/main/api/markdown-string.ts +4 -0
- package/src/main/api/mission-data.ts +83 -0
- package/src/main/api/mission-type.ts +2 -0
- package/src/main/api/morality.ts +31 -0
- package/src/main/api/sex.ts +10 -0
- package/src/main/api/zone-data.ts +20 -0
- package/src/main/db/abstract-index.ts +37 -0
- package/src/main/db/alignment-list.ts +54 -0
- package/src/main/db/alternates.ts +67 -0
- package/src/main/db/archetype.ts +14 -0
- package/src/main/db/badge-index.ts +57 -0
- package/src/main/db/badge-requirement.ts +81 -0
- package/src/main/db/badge-search-options.ts +51 -0
- package/src/main/db/badge.ts +147 -0
- package/src/main/db/bundle-header.ts +44 -0
- package/src/main/db/coh-content-database.ts +138 -0
- package/src/main/db/contact.ts +62 -0
- package/src/main/db/key.ts +18 -0
- package/src/main/db/location.ts +30 -0
- package/src/main/db/mission.ts +107 -0
- package/src/main/db/morality-list.ts +99 -0
- package/src/main/db/paged.ts +7 -0
- package/src/main/db/zone.ts +28 -0
- package/src/main/index.ts +41 -0
- package/src/main/util.ts +118 -0
- package/src/test/api/alignment.test.ts +65 -0
- package/src/test/api/archetype-data.fixture.ts +8 -0
- package/src/test/api/badge-data.fixture.ts +8 -0
- package/src/test/api/badge-data.test.ts +15 -0
- package/src/test/api/badge-requirement-data.fixture.ts +7 -0
- package/src/test/api/badge-requirement-type.test.ts +31 -0
- package/src/test/api/badge-type.test.ts +35 -0
- package/src/test/api/bundle-data.fixture.ts +6 -0
- package/src/test/api/bundle-header-data.fixture.ts +6 -0
- package/src/test/api/contact-data.fixture.ts +7 -0
- package/src/test/api/enhancement-category.test.ts +35 -0
- package/src/test/api/mission-data.fixture.ts +12 -0
- package/src/test/api/sex.test.ts +63 -0
- package/src/test/api/zone-data.fixture.ts +8 -0
- package/src/test/db/abstract-index.test.ts +55 -0
- package/src/test/db/alignment-list.test.ts +200 -0
- package/src/test/db/alternates.test.ts +188 -0
- package/src/test/db/archetype.test.ts +38 -0
- package/src/test/db/badge-index.test.ts +519 -0
- package/src/test/db/badge-requirement.test.ts +145 -0
- package/src/test/db/badge.test.ts +337 -0
- package/src/test/db/bundle-header.test.ts +76 -0
- package/src/test/db/coh-content-database.test.ts +282 -0
- package/src/test/db/contact.test.ts +97 -0
- package/src/test/db/key.test.ts +22 -0
- package/src/test/db/location.test.ts +51 -0
- package/src/test/db/mission.test.ts +171 -0
- package/src/test/db/morality-list.test.ts +457 -0
- package/src/test/db/zone.test.ts +36 -0
- package/src/test/integration.test.ts +16 -0
- package/src/test/util.test.ts +165 -0
- package/tsconfig.json +117 -0
- package/dist/_changelog.d.ts +0 -3
- package/dist/coh-content-db.nomin.js +0 -635
- package/dist/content-refence-utils.d.ts +0 -4
- package/dist/index.d.ts +0 -8
- package/dist/internal/_common.d.ts +0 -4
- package/dist/internal/archetype.d.ts +0 -10
- package/dist/internal/badge.d.ts +0 -44
- package/dist/internal/game-map.d.ts +0 -33
- package/dist/internal/server-group.d.ts +0 -24
- package/dist/types/archetype.d.ts +0 -9
- package/dist/types/badge.d.ts +0 -192
- package/dist/types/enhancement.d.ts +0 -28
- package/dist/types/game-map.d.ts +0 -47
- package/dist/types/link.d.ts +0 -4
- package/dist/types/server-group.d.ts +0 -75
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { MoralityList } from '../../main'
|
|
2
|
+
|
|
3
|
+
describe(MoralityList.name, () => {
|
|
4
|
+
describe('items', () => {
|
|
5
|
+
test('should return the basic set', () => {
|
|
6
|
+
expect(new MoralityList(['hero', 'villain', 'loyalist']).items).toStrictEqual(['hero', 'villain', 'loyalist'])
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test('should collapse extended values', () => {
|
|
10
|
+
expect(new MoralityList(['primal']).items).toStrictEqual(['hero', 'vigilante', 'villain', 'rogue'])
|
|
11
|
+
expect(new MoralityList(['heroic']).items).toStrictEqual(['hero', 'vigilante'])
|
|
12
|
+
expect(new MoralityList(['heroic', 'praetorian']).items).toStrictEqual(['hero', 'vigilante', 'resistance', 'loyalist'])
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
test('should not duplicate overlaps', () => {
|
|
16
|
+
expect(new MoralityList(['primal', 'heroic', 'hero']).items).toStrictEqual(['hero', 'vigilante', 'villain', 'rogue'])
|
|
17
|
+
expect(new MoralityList(['all', 'heroic', 'hero']).items).toStrictEqual(['hero', 'vigilante', 'villain', 'rogue', 'resistance', 'loyalist'])
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
test('should have deterministic order', () => {
|
|
21
|
+
expect(new MoralityList(['hero', 'villain']).items).toStrictEqual(['hero', 'villain'])
|
|
22
|
+
expect(new MoralityList(['villain', 'hero']).items).toStrictEqual(['hero', 'villain'])
|
|
23
|
+
expect(new MoralityList(['primal', 'all', 'hero']).items).toStrictEqual(['hero', 'vigilante', 'villain', 'rogue', 'resistance', 'loyalist'])
|
|
24
|
+
expect(new MoralityList(['hero', 'primal', 'all']).items).toStrictEqual(['hero', 'vigilante', 'villain', 'rogue', 'resistance', 'loyalist'])
|
|
25
|
+
expect(new MoralityList(['all', 'hero', 'primal']).items).toStrictEqual(['hero', 'vigilante', 'villain', 'rogue', 'resistance', 'loyalist'])
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('should treat undefined as all values', () => {
|
|
29
|
+
expect(new MoralityList().items).toStrictEqual(['hero', 'vigilante', 'villain', 'rogue', 'resistance', 'loyalist'])
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test('should treat empty as no values', () => {
|
|
33
|
+
expect(new MoralityList([]).items).toStrictEqual([])
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
describe('values', () => {
|
|
38
|
+
test('should all be true when undefined', () => {
|
|
39
|
+
const moralitys = new MoralityList()
|
|
40
|
+
expect(moralitys.hero).toBeTruthy()
|
|
41
|
+
expect(moralitys.vigilante).toBeTruthy()
|
|
42
|
+
expect(moralitys.villain).toBeTruthy()
|
|
43
|
+
expect(moralitys.rogue).toBeTruthy()
|
|
44
|
+
expect(moralitys.resistance).toBeTruthy()
|
|
45
|
+
expect(moralitys.loyalist).toBeTruthy()
|
|
46
|
+
expect(moralitys.primal).toBeTruthy()
|
|
47
|
+
expect(moralitys.praetorian).toBeTruthy()
|
|
48
|
+
expect(moralitys.heroic).toBeTruthy()
|
|
49
|
+
expect(moralitys.villainous).toBeTruthy()
|
|
50
|
+
expect(moralitys.paragonCityAccess).toBeTruthy()
|
|
51
|
+
expect(moralitys.rogueIslesAccess).toBeTruthy()
|
|
52
|
+
expect(moralitys.all).toBeTruthy()
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test('should all be false when empty', () => {
|
|
56
|
+
const moralitys = new MoralityList([])
|
|
57
|
+
expect(moralitys.hero).toBeFalsy()
|
|
58
|
+
expect(moralitys.vigilante).toBeFalsy()
|
|
59
|
+
expect(moralitys.villain).toBeFalsy()
|
|
60
|
+
expect(moralitys.rogue).toBeFalsy()
|
|
61
|
+
expect(moralitys.resistance).toBeFalsy()
|
|
62
|
+
expect(moralitys.loyalist).toBeFalsy()
|
|
63
|
+
expect(moralitys.primal).toBeFalsy()
|
|
64
|
+
expect(moralitys.praetorian).toBeFalsy()
|
|
65
|
+
expect(moralitys.heroic).toBeFalsy()
|
|
66
|
+
expect(moralitys.villainous).toBeFalsy()
|
|
67
|
+
expect(moralitys.paragonCityAccess).toBeFalsy()
|
|
68
|
+
expect(moralitys.rogueIslesAccess).toBeFalsy()
|
|
69
|
+
expect(moralitys.all).toBeFalsy()
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
describe('hero', () => {
|
|
74
|
+
test('should detect a hero', () => {
|
|
75
|
+
expect(new MoralityList(['hero', 'villain']).hero).toBeTruthy()
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test('should detect primal', () => {
|
|
79
|
+
expect(new MoralityList(['primal']).hero).toBeTruthy()
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
test('should detect heroic', () => {
|
|
83
|
+
expect(new MoralityList(['heroic']).hero).toBeTruthy()
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
test('should detect paragon-city-access', () => {
|
|
87
|
+
expect(new MoralityList(['paragon-city-access']).hero).toBeTruthy()
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
test('should detect all', () => {
|
|
91
|
+
expect(new MoralityList(['all']).hero).toBeTruthy()
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('should not falsely detect a hero', () => {
|
|
95
|
+
expect(new MoralityList(['villain']).hero).toBeFalsy()
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
describe('vigilante', () => {
|
|
100
|
+
test('should detect a vigilante', () => {
|
|
101
|
+
expect(new MoralityList(['vigilante', 'villain']).vigilante).toBeTruthy()
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
test('should detect primal', () => {
|
|
105
|
+
expect(new MoralityList(['primal']).vigilante).toBeTruthy()
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
test('should detect heroic', () => {
|
|
109
|
+
expect(new MoralityList(['heroic']).vigilante).toBeTruthy()
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
test('should detect paragon-city-access', () => {
|
|
113
|
+
expect(new MoralityList(['paragon-city-access']).vigilante).toBeTruthy()
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
test('should detect rogue-isles-access', () => {
|
|
117
|
+
expect(new MoralityList(['rogue-isles-access']).vigilante).toBeTruthy()
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test('should detect all', () => {
|
|
121
|
+
expect(new MoralityList(['all']).vigilante).toBeTruthy()
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
test('should not falsely detect a vigilante', () => {
|
|
125
|
+
expect(new MoralityList(['villain']).vigilante).toBeFalsy()
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
describe('villain', () => {
|
|
130
|
+
test('should detect a villain', () => {
|
|
131
|
+
expect(new MoralityList(['hero', 'villain']).villain).toBeTruthy()
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
test('should detect primal', () => {
|
|
135
|
+
expect(new MoralityList(['primal']).villain).toBeTruthy()
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
test('should detect villainous', () => {
|
|
139
|
+
expect(new MoralityList(['villainous']).villain).toBeTruthy()
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
test('should detect rogue-isles-access', () => {
|
|
143
|
+
expect(new MoralityList(['rogue-isles-access']).villain).toBeTruthy()
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
test('should detect all', () => {
|
|
147
|
+
expect(new MoralityList(['all']).villain).toBeTruthy()
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
test('should not falsely detect a villain', () => {
|
|
151
|
+
expect(new MoralityList(['hero']).villain).toBeFalsy()
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
describe('rogue', () => {
|
|
156
|
+
test('should detect a rogue', () => {
|
|
157
|
+
expect(new MoralityList(['hero', 'rogue']).rogue).toBeTruthy()
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
test('should detect primal', () => {
|
|
161
|
+
expect(new MoralityList(['primal']).rogue).toBeTruthy()
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
test('should detect villainous', () => {
|
|
165
|
+
expect(new MoralityList(['villainous']).rogue).toBeTruthy()
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
test('should detect paragon-city-access', () => {
|
|
169
|
+
expect(new MoralityList(['paragon-city-access']).rogue).toBeTruthy()
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
test('should detect rogue-isles-access', () => {
|
|
173
|
+
expect(new MoralityList(['rogue-isles-access']).rogue).toBeTruthy()
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
test('should detect all', () => {
|
|
177
|
+
expect(new MoralityList(['all']).rogue).toBeTruthy()
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
test('should not falsely detect a rogue', () => {
|
|
181
|
+
expect(new MoralityList(['hero']).rogue).toBeFalsy()
|
|
182
|
+
})
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
describe('primal', () => {
|
|
186
|
+
test('should detect hero, vigilante, villain and rogue', () => {
|
|
187
|
+
expect(new MoralityList(['hero', 'vigilante', 'villain', 'rogue']).primal).toBeTruthy()
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
test('should detect primal', () => {
|
|
191
|
+
expect(new MoralityList(['primal']).primal).toBeTruthy()
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
test('should detect all', () => {
|
|
195
|
+
expect(new MoralityList(['all']).primal).toBeTruthy()
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
test('should not falsely detect a primal', () => {
|
|
199
|
+
expect(new MoralityList(['villain']).primal).toBeFalsy()
|
|
200
|
+
expect(new MoralityList(['praetorian']).primal).toBeFalsy()
|
|
201
|
+
expect(new MoralityList(['hero', 'villain']).primal).toBeFalsy()
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
describe('praetorian', () => {
|
|
206
|
+
test('should detect resistance and loyalist', () => {
|
|
207
|
+
expect(new MoralityList(['resistance', 'loyalist']).praetorian).toBeTruthy()
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
test('should detect praetorian', () => {
|
|
211
|
+
expect(new MoralityList(['praetorian']).praetorian).toBeTruthy()
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
test('should detect all', () => {
|
|
215
|
+
expect(new MoralityList(['all']).praetorian).toBeTruthy()
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
test('should not falsely detect a praetorian', () => {
|
|
219
|
+
expect(new MoralityList(['villain']).praetorian).toBeFalsy()
|
|
220
|
+
expect(new MoralityList(['primal']).praetorian).toBeFalsy()
|
|
221
|
+
expect(new MoralityList(['hero', 'villain']).praetorian).toBeFalsy()
|
|
222
|
+
})
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
describe('heroic', () => {
|
|
226
|
+
test('should detect hero and vigilante', () => {
|
|
227
|
+
expect(new MoralityList(['hero', 'vigilante']).heroic).toBeTruthy()
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
test('should detect heroic', () => {
|
|
231
|
+
expect(new MoralityList(['heroic']).heroic).toBeTruthy()
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
test('should detect paragon-city-access', () => {
|
|
235
|
+
expect(new MoralityList(['paragon-city-access']).heroic).toBeTruthy()
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
test('should detect all', () => {
|
|
239
|
+
expect(new MoralityList(['all']).heroic).toBeTruthy()
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
test('should not falsely detect heroic', () => {
|
|
243
|
+
expect(new MoralityList(['villain']).heroic).toBeFalsy()
|
|
244
|
+
expect(new MoralityList(['praetorian']).heroic).toBeFalsy()
|
|
245
|
+
expect(new MoralityList(['villain', 'rogue']).heroic).toBeFalsy()
|
|
246
|
+
})
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
describe('villainous', () => {
|
|
250
|
+
test('should detect villain and rogue', () => {
|
|
251
|
+
expect(new MoralityList(['villain', 'rogue']).villainous).toBeTruthy()
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
test('should detect villainous', () => {
|
|
255
|
+
expect(new MoralityList(['villainous']).villainous).toBeTruthy()
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
test('should detect rogue-isles-access', () => {
|
|
259
|
+
expect(new MoralityList(['rogue-isles-access']).villainous).toBeTruthy()
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
test('should detect all', () => {
|
|
263
|
+
expect(new MoralityList(['all']).villainous).toBeTruthy()
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
test('should not falsely detect villainous', () => {
|
|
267
|
+
expect(new MoralityList(['villain']).villainous).toBeFalsy()
|
|
268
|
+
expect(new MoralityList(['praetorian']).villainous).toBeFalsy()
|
|
269
|
+
expect(new MoralityList(['hero', 'vigilante']).villainous).toBeFalsy()
|
|
270
|
+
})
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
describe('paragonCityAccess', () => {
|
|
274
|
+
test('should detect hero, vigilante and rogue', () => {
|
|
275
|
+
expect(new MoralityList(['hero', 'vigilante', 'rogue']).paragonCityAccess).toBeTruthy()
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
test('should detect paragon-city-access', () => {
|
|
279
|
+
expect(new MoralityList(['paragon-city-access']).paragonCityAccess).toBeTruthy()
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
test('should detect all', () => {
|
|
283
|
+
expect(new MoralityList(['all']).paragonCityAccess).toBeTruthy()
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
test('should not falsely detect paragonCityAccess', () => {
|
|
287
|
+
expect(new MoralityList(['villain']).paragonCityAccess).toBeFalsy()
|
|
288
|
+
expect(new MoralityList(['praetorian']).paragonCityAccess).toBeFalsy()
|
|
289
|
+
expect(new MoralityList(['hero', 'vigilante']).paragonCityAccess).toBeFalsy()
|
|
290
|
+
})
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
describe('rogueIslesAccess', () => {
|
|
294
|
+
test('should detect villain, rogue and vigilante', () => {
|
|
295
|
+
expect(new MoralityList(['villain', 'rogue', 'vigilante']).rogueIslesAccess).toBeTruthy()
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
test('should detect rogue-isles-access', () => {
|
|
299
|
+
expect(new MoralityList(['rogue-isles-access']).rogueIslesAccess).toBeTruthy()
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
test('should detect all', () => {
|
|
303
|
+
expect(new MoralityList(['all']).rogueIslesAccess).toBeTruthy()
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
test('should not falsely detect rogueIslesAccess', () => {
|
|
307
|
+
expect(new MoralityList(['villain']).rogueIslesAccess).toBeFalsy()
|
|
308
|
+
expect(new MoralityList(['praetorian']).rogueIslesAccess).toBeFalsy()
|
|
309
|
+
expect(new MoralityList(['hero', 'vigilante']).rogueIslesAccess).toBeFalsy()
|
|
310
|
+
})
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
describe('all', () => {
|
|
314
|
+
test('should detect when all are present', () => {
|
|
315
|
+
expect(new MoralityList(['hero', 'vigilante', 'villain', 'rogue', 'resistance', 'loyalist']).all).toBeTruthy()
|
|
316
|
+
expect(new MoralityList(['heroic', 'villainous', 'praetorian']).all).toBeTruthy()
|
|
317
|
+
expect(new MoralityList(['primal', 'praetorian']).all).toBeTruthy()
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
test('should detect all', () => {
|
|
321
|
+
expect(new MoralityList(['all']).all).toBeTruthy()
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
test('should not falsely detect all', () => {
|
|
325
|
+
expect(new MoralityList(['villain']).all).toBeFalsy()
|
|
326
|
+
expect(new MoralityList(['praetorian']).all).toBeFalsy()
|
|
327
|
+
expect(new MoralityList(['primal']).all).toBeFalsy()
|
|
328
|
+
})
|
|
329
|
+
})
|
|
330
|
+
|
|
331
|
+
describe('has', () => {
|
|
332
|
+
test('should return true if present', () => {
|
|
333
|
+
expect(new MoralityList(['villain']).has('villain')).toBeTruthy()
|
|
334
|
+
expect(new MoralityList(['hero', 'loyalist']).has('loyalist')).toBeTruthy()
|
|
335
|
+
})
|
|
336
|
+
|
|
337
|
+
test('should return false if absent', () => {
|
|
338
|
+
expect(new MoralityList(['hero']).has('villain')).toBeFalsy()
|
|
339
|
+
expect(new MoralityList(['heroic']).has('villain')).toBeFalsy()
|
|
340
|
+
expect(new MoralityList(['hero', 'praetorian']).has('primal')).toBeFalsy()
|
|
341
|
+
})
|
|
342
|
+
|
|
343
|
+
test('should return false if undefined', () => {
|
|
344
|
+
expect(new MoralityList(['hero']).has()).toBeFalsy()
|
|
345
|
+
})
|
|
346
|
+
|
|
347
|
+
test('should test hero correctly', () => {
|
|
348
|
+
expect(new MoralityList(['hero']).has('hero')).toBeTruthy()
|
|
349
|
+
expect(new MoralityList(['heroic']).has('hero')).toBeTruthy()
|
|
350
|
+
expect(new MoralityList(['primal']).has('hero')).toBeTruthy()
|
|
351
|
+
expect(new MoralityList(['all']).has('hero')).toBeTruthy()
|
|
352
|
+
|
|
353
|
+
expect(new MoralityList(['villain']).has('hero')).toBeFalsy()
|
|
354
|
+
})
|
|
355
|
+
|
|
356
|
+
test('should test vigilante correctly', () => {
|
|
357
|
+
expect(new MoralityList(['hero', 'vigilante']).has('vigilante')).toBeTruthy()
|
|
358
|
+
expect(new MoralityList(['heroic']).has('vigilante')).toBeTruthy()
|
|
359
|
+
expect(new MoralityList(['primal']).has('vigilante')).toBeTruthy()
|
|
360
|
+
expect(new MoralityList(['all']).has('vigilante')).toBeTruthy()
|
|
361
|
+
|
|
362
|
+
expect(new MoralityList(['villain']).has('vigilante')).toBeFalsy()
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
test('should test villain correctly', () => {
|
|
366
|
+
expect(new MoralityList(['villain']).has('villain')).toBeTruthy()
|
|
367
|
+
expect(new MoralityList(['villainous']).has('villain')).toBeTruthy()
|
|
368
|
+
expect(new MoralityList(['primal']).has('villain')).toBeTruthy()
|
|
369
|
+
expect(new MoralityList(['all']).has('villain')).toBeTruthy()
|
|
370
|
+
|
|
371
|
+
expect(new MoralityList(['hero']).has('villain')).toBeFalsy()
|
|
372
|
+
})
|
|
373
|
+
|
|
374
|
+
test('should test rogue correctly', () => {
|
|
375
|
+
expect(new MoralityList(['rogue']).has('rogue')).toBeTruthy()
|
|
376
|
+
expect(new MoralityList(['villainous']).has('rogue')).toBeTruthy()
|
|
377
|
+
expect(new MoralityList(['primal']).has('rogue')).toBeTruthy()
|
|
378
|
+
expect(new MoralityList(['all']).has('rogue')).toBeTruthy()
|
|
379
|
+
|
|
380
|
+
expect(new MoralityList(['hero']).has('rogue')).toBeFalsy()
|
|
381
|
+
})
|
|
382
|
+
|
|
383
|
+
test('should test resistance correctly', () => {
|
|
384
|
+
expect(new MoralityList(['resistance']).has('resistance')).toBeTruthy()
|
|
385
|
+
expect(new MoralityList(['praetorian']).has('resistance')).toBeTruthy()
|
|
386
|
+
expect(new MoralityList(['all']).has('resistance')).toBeTruthy()
|
|
387
|
+
|
|
388
|
+
expect(new MoralityList(['villain']).has('resistance')).toBeFalsy()
|
|
389
|
+
})
|
|
390
|
+
|
|
391
|
+
test('should test loyalist correctly', () => {
|
|
392
|
+
expect(new MoralityList(['loyalist']).has('loyalist')).toBeTruthy()
|
|
393
|
+
expect(new MoralityList(['praetorian']).has('loyalist')).toBeTruthy()
|
|
394
|
+
expect(new MoralityList(['all']).has('loyalist')).toBeTruthy()
|
|
395
|
+
|
|
396
|
+
expect(new MoralityList(['villain']).has('loyalist')).toBeFalsy()
|
|
397
|
+
})
|
|
398
|
+
|
|
399
|
+
test('should test primal correctly', () => {
|
|
400
|
+
expect(new MoralityList(['hero', 'vigilante', 'villain', 'rogue']).has('primal')).toBeTruthy()
|
|
401
|
+
expect(new MoralityList(['heroic', 'villainous']).has('primal')).toBeTruthy()
|
|
402
|
+
expect(new MoralityList(['primal']).has('primal')).toBeTruthy()
|
|
403
|
+
expect(new MoralityList(['all']).has('primal')).toBeTruthy()
|
|
404
|
+
|
|
405
|
+
expect(new MoralityList(['villain']).has('primal')).toBeFalsy()
|
|
406
|
+
})
|
|
407
|
+
|
|
408
|
+
test('should test praetorian correctly', () => {
|
|
409
|
+
expect(new MoralityList(['resistance', 'loyalist']).has('praetorian')).toBeTruthy()
|
|
410
|
+
expect(new MoralityList(['praetorian']).has('praetorian')).toBeTruthy()
|
|
411
|
+
expect(new MoralityList(['all']).has('praetorian')).toBeTruthy()
|
|
412
|
+
|
|
413
|
+
expect(new MoralityList(['villain']).has('praetorian')).toBeFalsy()
|
|
414
|
+
})
|
|
415
|
+
|
|
416
|
+
test('should test heroic correctly', () => {
|
|
417
|
+
expect(new MoralityList(['hero', 'vigilante']).has('heroic')).toBeTruthy()
|
|
418
|
+
expect(new MoralityList(['heroic']).has('heroic')).toBeTruthy()
|
|
419
|
+
expect(new MoralityList(['all']).has('heroic')).toBeTruthy()
|
|
420
|
+
|
|
421
|
+
expect(new MoralityList(['villain']).has('heroic')).toBeFalsy()
|
|
422
|
+
})
|
|
423
|
+
|
|
424
|
+
test('should test villainous correctly', () => {
|
|
425
|
+
expect(new MoralityList(['villain', 'rogue']).has('villainous')).toBeTruthy()
|
|
426
|
+
expect(new MoralityList(['villainous']).has('villainous')).toBeTruthy()
|
|
427
|
+
expect(new MoralityList(['all']).has('villainous')).toBeTruthy()
|
|
428
|
+
|
|
429
|
+
expect(new MoralityList(['villain']).has('villainous')).toBeFalsy()
|
|
430
|
+
})
|
|
431
|
+
|
|
432
|
+
test('should test paragon-city-access correctly', () => {
|
|
433
|
+
expect(new MoralityList(['hero', 'vigilante', 'rogue']).has('paragon-city-access')).toBeTruthy()
|
|
434
|
+
expect(new MoralityList(['heroic', 'rogue']).has('paragon-city-access')).toBeTruthy()
|
|
435
|
+
expect(new MoralityList(['all']).has('paragon-city-access')).toBeTruthy()
|
|
436
|
+
|
|
437
|
+
expect(new MoralityList(['villain']).has('paragon-city-access')).toBeFalsy()
|
|
438
|
+
})
|
|
439
|
+
|
|
440
|
+
test('should test rogue-isles-access correctly', () => {
|
|
441
|
+
expect(new MoralityList(['villain', 'rogue', 'vigilante']).has('rogue-isles-access')).toBeTruthy()
|
|
442
|
+
expect(new MoralityList(['villainous', 'vigilante']).has('rogue-isles-access')).toBeTruthy()
|
|
443
|
+
expect(new MoralityList(['all']).has('rogue-isles-access')).toBeTruthy()
|
|
444
|
+
|
|
445
|
+
expect(new MoralityList(['villain']).has('rogue-isles-access')).toBeFalsy()
|
|
446
|
+
})
|
|
447
|
+
|
|
448
|
+
test('should test all correctly', () => {
|
|
449
|
+
expect(new MoralityList(['hero', 'vigilante', 'villain', 'rogue', 'resistance', 'loyalist']).has('all')).toBeTruthy()
|
|
450
|
+
expect(new MoralityList(['primal', 'praetorian']).has('all')).toBeTruthy()
|
|
451
|
+
expect(new MoralityList(['heroic', 'villainous', 'praetorian']).has('all')).toBeTruthy()
|
|
452
|
+
expect(new MoralityList(['all']).has('all')).toBeTruthy()
|
|
453
|
+
|
|
454
|
+
expect(new MoralityList(['villain']).has('all')).toBeFalsy()
|
|
455
|
+
})
|
|
456
|
+
})
|
|
457
|
+
})
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Zone } from '../../main'
|
|
2
|
+
import { zoneDataFixture } from '../api/zone-data.fixture'
|
|
3
|
+
|
|
4
|
+
describe(Zone.name, () => {
|
|
5
|
+
describe('Constructor', () => {
|
|
6
|
+
test(`should accept the test fixture`, () => {
|
|
7
|
+
new Zone(zoneDataFixture.create())
|
|
8
|
+
})
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
describe('key', () => {
|
|
12
|
+
test(`should be set from the data`, () => {
|
|
13
|
+
const zone = new Zone(zoneDataFixture.create({ key: 'foo' }))
|
|
14
|
+
expect(zone.key).toEqual('foo')
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
describe('name', () => {
|
|
19
|
+
test(`should be set from the data`, () => {
|
|
20
|
+
const zone = new Zone(zoneDataFixture.create({ name: 'foo' }))
|
|
21
|
+
expect(zone.name).toEqual('foo')
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
describe('links', () => {
|
|
26
|
+
test(`should be set from the data`, () => {
|
|
27
|
+
const zone = new Zone(zoneDataFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
|
|
28
|
+
expect(zone.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test(`should be optional`, () => {
|
|
32
|
+
const zone = new Zone(zoneDataFixture.omit('links').create())
|
|
33
|
+
expect(zone.links).toHaveLength(0)
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BundleData } from '../main'
|
|
2
|
+
import { TEST_BADGE } from './api/badge-data.test'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* If you change this test, update the example in the README as well
|
|
6
|
+
*/
|
|
7
|
+
export const TEST_BUNDLE: BundleData = {
|
|
8
|
+
header: { name: 'My Content Bundle' },
|
|
9
|
+
badges: [TEST_BADGE],
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe('BundleData', () => {
|
|
13
|
+
test('should be a usable interface', () => {
|
|
14
|
+
expect(TEST_BUNDLE).not.toBeUndefined()
|
|
15
|
+
})
|
|
16
|
+
})
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { Badge, badgeLink, badgeUri, coalesceToArray, Contact, contactLink, contactUri, Mission, missionLink, missionUri, Zone, zoneLink, zoneUri } from '../main'
|
|
2
|
+
import { badgeDataFixture } from './api/badge-data.fixture'
|
|
3
|
+
import { zoneDataFixture } from './api/zone-data.fixture'
|
|
4
|
+
import { contactDataFixture } from './api/contact-data.fixture'
|
|
5
|
+
import { missionDataFixture } from './api/mission-data.fixture'
|
|
6
|
+
|
|
7
|
+
describe(badgeUri.name, () => {
|
|
8
|
+
test('should return the expected pattern', () => {
|
|
9
|
+
expect(badgeUri('foo')).toBe('badge://foo')
|
|
10
|
+
expect(badgeUri('bar')).toBe('badge://bar')
|
|
11
|
+
expect(badgeUri('foo-bar')).toBe('badge://foo-bar')
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test('should accept a Badge object', () => {
|
|
15
|
+
const badge = new Badge(badgeDataFixture.create({ key: 'foo' }))
|
|
16
|
+
expect(badgeUri(badge)).toBe('badge://foo')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test('should accept a BadgeData object', () => {
|
|
20
|
+
const badge = badgeDataFixture.create({ key: 'foo' })
|
|
21
|
+
expect(badgeUri(badge)).toBe('badge://foo')
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
describe(badgeLink.name, () => {
|
|
26
|
+
test('should return the expected pattern', () => {
|
|
27
|
+
expect(badgeLink('foo')).toBe('[foo](badge://foo)')
|
|
28
|
+
expect(badgeLink('bar')).toBe('[bar](badge://bar)')
|
|
29
|
+
expect(badgeLink('foo-bar')).toBe('[foo-bar](badge://foo-bar)')
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test('should accept a Badge object', () => {
|
|
33
|
+
const badge = new Badge(badgeDataFixture.create({ key: 'foo' }))
|
|
34
|
+
expect(badgeLink(badge)).toBe('[foo](badge://foo)')
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test('should accept a BadgeData object', () => {
|
|
38
|
+
const badge = badgeDataFixture.create({ key: 'foo' })
|
|
39
|
+
expect(badgeLink(badge)).toBe('[foo](badge://foo)')
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
describe(contactUri.name, () => {
|
|
44
|
+
test('should return the expected pattern', () => {
|
|
45
|
+
expect(contactUri('foo')).toBe('contact://foo')
|
|
46
|
+
expect(contactUri('bar')).toBe('contact://bar')
|
|
47
|
+
expect(contactUri('foo-bar')).toBe('contact://foo-bar')
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test('should accept a Contact object', () => {
|
|
51
|
+
const contact = new Contact(contactDataFixture.create({ key: 'foo' }))
|
|
52
|
+
expect(contactUri(contact)).toBe('contact://foo')
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test('should accept a ContactData object', () => {
|
|
56
|
+
const contact = contactDataFixture.create({ key: 'foo' })
|
|
57
|
+
expect(contactUri(contact)).toBe('contact://foo')
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
describe(contactLink.name, () => {
|
|
62
|
+
test('should return the expected pattern', () => {
|
|
63
|
+
expect(contactLink('foo')).toBe('[foo](contact://foo)')
|
|
64
|
+
expect(contactLink('bar')).toBe('[bar](contact://bar)')
|
|
65
|
+
expect(contactLink('foo-bar')).toBe('[foo-bar](contact://foo-bar)')
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test('should accept a Contact object', () => {
|
|
69
|
+
const contact = new Contact(contactDataFixture.create({ key: 'foo' }))
|
|
70
|
+
expect(contactLink(contact)).toBe('[foo](contact://foo)')
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test('should accept a ContactData object', () => {
|
|
74
|
+
const contact = contactDataFixture.create({ key: 'foo' })
|
|
75
|
+
expect(contactLink(contact)).toBe('[foo](contact://foo)')
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
describe(missionUri.name, () => {
|
|
80
|
+
test('should return the expected pattern', () => {
|
|
81
|
+
expect(missionUri('foo')).toBe('mission://foo')
|
|
82
|
+
expect(missionUri('bar')).toBe('mission://bar')
|
|
83
|
+
expect(missionUri('foo-bar')).toBe('mission://foo-bar')
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
test('should accept a Mission object', () => {
|
|
87
|
+
const mission = new Mission(missionDataFixture.create({ key: 'foo' }))
|
|
88
|
+
expect(missionUri(mission)).toBe('mission://foo')
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
test('should accept a MissionData object', () => {
|
|
92
|
+
const mission = missionDataFixture.create({ key: 'foo' })
|
|
93
|
+
expect(missionUri(mission)).toBe('mission://foo')
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
describe(missionLink.name, () => {
|
|
98
|
+
test('should return the expected pattern', () => {
|
|
99
|
+
expect(missionLink('foo')).toBe('[foo](mission://foo)')
|
|
100
|
+
expect(missionLink('bar')).toBe('[bar](mission://bar)')
|
|
101
|
+
expect(missionLink('foo-bar')).toBe('[foo-bar](mission://foo-bar)')
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
test('should accept a Mission object', () => {
|
|
105
|
+
const mission = new Mission(missionDataFixture.create({ key: 'foo' }))
|
|
106
|
+
expect(missionLink(mission)).toBe('[foo](mission://foo)')
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
test('should accept a MissionData object', () => {
|
|
110
|
+
const mission = missionDataFixture.create({ key: 'foo' })
|
|
111
|
+
expect(missionLink(mission)).toBe('[foo](mission://foo)')
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
describe(zoneUri.name, () => {
|
|
116
|
+
test('should return the expected pattern', () => {
|
|
117
|
+
expect(zoneUri('foo')).toBe('zone://foo')
|
|
118
|
+
expect(zoneUri('bar')).toBe('zone://bar')
|
|
119
|
+
expect(zoneUri('foo-bar')).toBe('zone://foo-bar')
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
test('should accept a Zone object', () => {
|
|
123
|
+
const zone = new Zone(zoneDataFixture.create({ key: 'foo' }))
|
|
124
|
+
expect(zoneUri(zone)).toBe('zone://foo')
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
test('should accept a ZoneData object', () => {
|
|
128
|
+
const zone = zoneDataFixture.create({ key: 'foo' })
|
|
129
|
+
expect(zoneUri(zone)).toBe('zone://foo')
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
describe(zoneLink.name, () => {
|
|
134
|
+
test('should return the expected pattern', () => {
|
|
135
|
+
expect(zoneLink('foo')).toBe('[foo](zone://foo)')
|
|
136
|
+
expect(zoneLink('bar')).toBe('[bar](zone://bar)')
|
|
137
|
+
expect(zoneLink('foo-bar')).toBe('[foo-bar](zone://foo-bar)')
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
test('should accept a Zone object', () => {
|
|
141
|
+
const zone = new Zone(zoneDataFixture.create({ key: 'foo' }))
|
|
142
|
+
expect(zoneLink(zone)).toBe('[foo](zone://foo)')
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
test('should accept a ZoneData object', () => {
|
|
146
|
+
const zone = zoneDataFixture.create({ key: 'foo' })
|
|
147
|
+
expect(zoneLink(zone)).toBe('[foo](zone://foo)')
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
describe(coalesceToArray.name, () => {
|
|
152
|
+
test('should return an array unmodified', () => {
|
|
153
|
+
expect(coalesceToArray(['a', 'b'])).toStrictEqual(['a', 'b'])
|
|
154
|
+
expect(coalesceToArray([1, 2])).toStrictEqual([1, 2])
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
test('should return a single value as a single-value array', () => {
|
|
158
|
+
expect(coalesceToArray('a')).toStrictEqual(['a'])
|
|
159
|
+
expect(coalesceToArray(1)).toStrictEqual([1])
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
test('should return undefined value as undefined', () => {
|
|
163
|
+
expect(coalesceToArray()).toBeUndefined()
|
|
164
|
+
})
|
|
165
|
+
})
|