coh-content-db 2.0.0-rc.2 → 2.0.0-rc.21
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 +10 -11
- package/.github/workflows/build.yml +4 -2
- package/.github/workflows/pull-request.yml +1 -1
- package/.github/workflows/release.yml +1 -1
- package/CHANGELOG.md +47 -0
- package/README.md +77 -32
- package/dist/coh-content-db.d.ts +755 -290
- package/dist/coh-content-db.js +1028 -358
- package/dist/coh-content-db.js.map +1 -1
- package/dist/coh-content-db.mjs +998 -349
- package/dist/coh-content-db.mjs.map +1 -1
- package/eslint.config.mjs +1 -0
- package/jest.config.mjs +1 -0
- package/package.json +14 -14
- package/src/main/api/alignment.ts +18 -2
- package/src/main/api/badge-data.ts +29 -51
- 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 +15 -15
- package/src/main/api/bundle-data.ts +47 -0
- package/src/main/api/bundle-header-data.ts +44 -0
- package/src/main/api/contact-data.ts +49 -0
- package/src/main/api/enhancement-category.ts +26 -26
- package/src/main/api/level-range-data.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 +57 -0
- package/src/main/api/mission-flashback-data.ts +31 -0
- package/src/main/api/mission-type.ts +2 -0
- package/src/main/api/morality.ts +49 -0
- package/src/main/api/set-title-data.ts +4 -0
- package/src/main/api/sex.ts +8 -1
- package/src/main/api/variant-context.ts +11 -0
- package/src/main/api/variant-data.ts +22 -0
- package/src/main/api/zone-data.ts +44 -0
- package/src/main/api/zone-type.ts +59 -0
- package/src/main/db/abstract-index.ts +37 -0
- package/src/main/db/alignment-list.ts +54 -0
- package/src/main/db/badge-index.ts +83 -0
- package/src/main/db/badge-requirement.ts +81 -0
- package/src/main/db/badge-search-options.ts +52 -0
- package/src/main/db/badge.ts +97 -74
- package/src/main/db/bundle-header.ts +52 -0
- package/src/main/db/coh-content-database.ts +123 -14
- package/src/main/db/contact.ts +63 -0
- package/src/main/db/level-range.ts +15 -0
- package/src/main/db/location.ts +30 -0
- package/src/main/db/mission.ts +108 -0
- package/src/main/db/morality-list.ts +99 -0
- package/src/main/db/paged.ts +11 -0
- package/src/main/db/set-title-ids.ts +10 -0
- package/src/main/db/variants.ts +84 -0
- package/src/main/db/zone.ts +57 -0
- package/src/main/index.ts +33 -18
- package/src/main/util/coalesce-to-array.ts +13 -0
- package/src/main/util/links.ts +104 -0
- package/src/main/util/to-date.ts +9 -0
- package/src/test/api/alignment.test.ts +38 -4
- package/src/test/api/badge-data.fixture.ts +2 -15
- package/src/test/api/badge-data.test.ts +5 -4
- 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 +5 -5
- package/src/test/api/bundle-data.fixture.ts +7 -0
- package/src/test/api/bundle-header-data.fixture.ts +8 -0
- package/src/test/api/contact-data.fixture.ts +7 -0
- package/src/test/api/enhancement-category.test.ts +5 -5
- package/src/test/api/mission-data.fixture.ts +12 -0
- package/src/test/api/morality.test.ts +31 -0
- package/src/test/api/sex.test.ts +33 -1
- package/src/test/api/zone-data.fixture.ts +9 -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/badge-index.test.ts +653 -0
- package/src/test/db/badge-requirement.test.ts +145 -0
- package/src/test/db/badge.test.ts +416 -14
- package/src/test/db/bundle-header.test.ts +89 -0
- package/src/test/db/coh-content-database.test.ts +265 -24
- package/src/test/db/contact.test.ts +98 -0
- package/src/test/db/level-range.test.ts +47 -0
- package/src/test/db/location.test.ts +51 -0
- package/src/test/db/mission.test.ts +173 -0
- package/src/test/db/morality-list.test.ts +457 -0
- package/src/test/db/set-title-ids.test.ts +19 -0
- package/src/test/db/variants.test.ts +188 -0
- package/src/test/db/zone.test.ts +81 -0
- package/src/test/integration.test.ts +16 -0
- package/src/test/util/coalese-to-array.test.ts +17 -0
- package/src/test/util/links.test.ts +149 -0
- package/src/test/util/to-date.test.ts +15 -0
- package/src/main/api/alternate-data.ts +0 -22
- package/src/main/api/badge-partial-data.ts +0 -65
- package/src/main/api/badge-partial-type.ts +0 -8
- package/src/main/api/change.ts +0 -14
- package/src/main/api/game-map-data.ts +0 -26
- package/src/main/api/plaque-type.ts +0 -6
- package/src/main/api/server-group-data.ts +0 -65
- package/src/main/api/vidiot-map-data.ts +0 -18
- package/src/main/api/vidiot-map-point-of-interest-data.ts +0 -30
- package/src/main/changelog.ts +0 -20
- package/src/main/db/alternates.ts +0 -81
- package/src/main/db/badge-partial.ts +0 -35
- package/src/main/db/game-map.ts +0 -33
- package/src/main/db/server-group.ts +0 -112
- package/src/main/db/vidiot-map-point-of-interest.ts +0 -40
- package/src/main/db/vidiot-map.ts +0 -25
- package/src/main/util.ts +0 -17
- package/src/test/api/badge-partial-data.fixture.ts +0 -17
- package/src/test/api/badge-partial-type.test.ts +0 -31
- package/src/test/api/game-map-data.fixture.ts +0 -10
- package/src/test/api/plaque-type.test.ts +0 -31
- package/src/test/api/server-group-data.fixture.ts +0 -23
- package/src/test/api/server-group-data.test.ts +0 -15
- package/src/test/api/vidiot-map-point-of-interest.fixture.ts +0 -10
- package/src/test/api/vidiot-map.fixture.ts +0 -9
- package/src/test/changelog.test.ts +0 -36
- package/src/test/db/alternates.test.ts +0 -223
- package/src/test/db/server-group.test.ts +0 -124
- package/src/test/index.test.ts +0 -10
- package/src/test/util.test.ts +0 -39
|
@@ -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 explicit 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,19 @@
|
|
|
1
|
+
import { SetTitleIds } from '../../main'
|
|
2
|
+
|
|
3
|
+
describe(SetTitleIds.name, () => {
|
|
4
|
+
describe('Constructor', () => {
|
|
5
|
+
test('should accept both primal and praetorian values', () => {
|
|
6
|
+
const ids = new SetTitleIds([5, 10])
|
|
7
|
+
expect(ids).toBeDefined()
|
|
8
|
+
expect(ids.primal).toEqual(5)
|
|
9
|
+
expect(ids.praetorian).toEqual(10)
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('should accept primal only', () => {
|
|
13
|
+
const ids = new SetTitleIds([1])
|
|
14
|
+
expect(ids).toBeDefined()
|
|
15
|
+
expect(ids.primal).toEqual(1)
|
|
16
|
+
expect(ids.praetorian).toBeUndefined()
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
})
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { Variants } from '../../main'
|
|
2
|
+
|
|
3
|
+
describe(Variants.name, () => {
|
|
4
|
+
describe('Constructor', () => {
|
|
5
|
+
test('should accept a list of variant values', () => {
|
|
6
|
+
new Variants([
|
|
7
|
+
{ value: 'Default' },
|
|
8
|
+
{ sex: 'M', value: 'Male' },
|
|
9
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
10
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
11
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
12
|
+
])
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
test('should accept a single value', () => {
|
|
16
|
+
expect(new Variants('foo').default?.value).toBe('foo')
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
describe('getValue', () => {
|
|
21
|
+
test('should return undefined if there are no values', () => {
|
|
22
|
+
expect(new Variants([]).getValue()).toBeUndefined()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test('should return the least-specific value when no classifiers are provided', () => {
|
|
26
|
+
expect(new Variants([
|
|
27
|
+
{ value: 'Default' },
|
|
28
|
+
{ sex: 'M', value: 'Male' },
|
|
29
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
30
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
31
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
32
|
+
]).getValue()).toBe('Default')
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test('should return the least-specific value when no classifiers are provided, regardless of insert order', () => {
|
|
36
|
+
expect(new Variants([
|
|
37
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
38
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
39
|
+
{ value: 'Default' },
|
|
40
|
+
{ sex: 'M', value: 'Male' },
|
|
41
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
42
|
+
]).getValue()).toBe('Default')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
test('should return the most specific match', () => {
|
|
46
|
+
expect(new Variants([
|
|
47
|
+
{ value: 'Default' },
|
|
48
|
+
{ sex: 'M', value: 'Male' },
|
|
49
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
50
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
51
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
52
|
+
]).getValue({ morality: 'villain', sex: 'M' })).toBe('Male Villain')
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test('should return the most specific match, regardless of insert order', () => {
|
|
56
|
+
expect(new Variants([
|
|
57
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
58
|
+
{ sex: 'M', value: 'Male' },
|
|
59
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
60
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
61
|
+
{ value: 'Default' },
|
|
62
|
+
]).getValue({ morality: 'villain', sex: 'M' })).toBe('Male Villain')
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
test('should return the lowest canonical value if there is no default', () => {
|
|
66
|
+
expect(new Variants([
|
|
67
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
68
|
+
{ sex: 'M', value: 'Male' },
|
|
69
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
70
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
71
|
+
]).getValue()).toBe('Male')
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
test('should return the lowest canonical value if a specific is requested that does not exist', () => {
|
|
75
|
+
expect(new Variants([
|
|
76
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
77
|
+
{ alignment: 'villain', value: 'Villain' },
|
|
78
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
79
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
80
|
+
]).getValue({ sex: 'F' })).toBe('Hero')
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
describe('default', () => {
|
|
85
|
+
test('should return undefined if there are no values', () => {
|
|
86
|
+
expect(new Variants([]).default).toBeUndefined()
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
test('should return the lowest priority value', () => {
|
|
90
|
+
expect(new Variants([
|
|
91
|
+
{ value: 'Default' },
|
|
92
|
+
{ sex: 'M', value: 'Male' },
|
|
93
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
94
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
95
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
96
|
+
]).default?.value).toBe('Default')
|
|
97
|
+
|
|
98
|
+
expect(new Variants([
|
|
99
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
100
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
101
|
+
{ sex: 'M', value: 'Male' },
|
|
102
|
+
{ value: 'Default' },
|
|
103
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
104
|
+
]).default?.value).toBe('Default')
|
|
105
|
+
|
|
106
|
+
expect(new Variants([
|
|
107
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
108
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
109
|
+
{ sex: 'M', value: 'Male' },
|
|
110
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
111
|
+
]).default?.value).toBe('Male')
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
describe('canonical', () => {
|
|
116
|
+
test('should be empty if there are no values', () => {
|
|
117
|
+
expect(new Variants([]).canonical).toHaveLength(0)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test('should return values sorted in canonical order', () => {
|
|
121
|
+
const result = new Variants([
|
|
122
|
+
{ alignment: 'hero', sex: 'F', value: 'Female Hero' },
|
|
123
|
+
{ alignment: 'praetorian', value: 'Praetorian' },
|
|
124
|
+
{ sex: 'F', value: 'Female' },
|
|
125
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
126
|
+
{ alignment: 'praetorian', sex: 'M', value: 'Male Praetorian' },
|
|
127
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
128
|
+
{ alignment: 'hero', sex: 'M', value: 'Male Hero' },
|
|
129
|
+
{ sex: 'M', value: 'Male' },
|
|
130
|
+
{ alignment: 'villain', value: 'Villain' },
|
|
131
|
+
{ alignment: 'villain', sex: 'F', value: 'Female Villain' },
|
|
132
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Female Praetorian' },
|
|
133
|
+
{ value: 'Default' },
|
|
134
|
+
]).canonical
|
|
135
|
+
|
|
136
|
+
expect(result).toStrictEqual([
|
|
137
|
+
{ value: 'Default' },
|
|
138
|
+
{ sex: 'M', value: 'Male' },
|
|
139
|
+
{ sex: 'F', value: 'Female' },
|
|
140
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
141
|
+
{ alignment: 'villain', value: 'Villain' },
|
|
142
|
+
{ alignment: 'praetorian', value: 'Praetorian' },
|
|
143
|
+
{ alignment: 'hero', sex: 'M', value: 'Male Hero' },
|
|
144
|
+
{ alignment: 'hero', sex: 'F', value: 'Female Hero' },
|
|
145
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
146
|
+
{ alignment: 'villain', sex: 'F', value: 'Female Villain' },
|
|
147
|
+
{ alignment: 'praetorian', sex: 'M', value: 'Male Praetorian' },
|
|
148
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Female Praetorian' },
|
|
149
|
+
])
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
test('should sort unspecified values by alpha', () => {
|
|
153
|
+
expect(new Variants([
|
|
154
|
+
{ value: 'A' },
|
|
155
|
+
{ value: 'C' },
|
|
156
|
+
{ value: 'B' },
|
|
157
|
+
]).canonical).toStrictEqual([
|
|
158
|
+
{ value: 'A' },
|
|
159
|
+
{ value: 'B' },
|
|
160
|
+
{ value: 'C' },
|
|
161
|
+
])
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
test('should sort identical values by value alpha', () => {
|
|
165
|
+
expect(new Variants([
|
|
166
|
+
{ alignment: 'villain', value: 'B' },
|
|
167
|
+
{ sex: 'M', value: 'D' },
|
|
168
|
+
{ alignment: 'villain', value: 'A' },
|
|
169
|
+
{ sex: 'M', value: 'C' },
|
|
170
|
+
]).canonical).toStrictEqual([
|
|
171
|
+
{ sex: 'M', value: 'C' },
|
|
172
|
+
{ sex: 'M', value: 'D' },
|
|
173
|
+
{ alignment: 'villain', value: 'A' },
|
|
174
|
+
{ alignment: 'villain', value: 'B' },
|
|
175
|
+
])
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
describe('toString', () => {
|
|
180
|
+
test('should create a string separated by the separator', () => {
|
|
181
|
+
expect(new Variants([
|
|
182
|
+
{ sex: 'M', value: 'A' },
|
|
183
|
+
{ sex: 'F', value: 'B' },
|
|
184
|
+
{ alignment: 'hero', value: 'C' },
|
|
185
|
+
]).toString(', ')).toBe('A, B, C')
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
})
|