coh-content-db 2.0.0-rc.6 → 2.0.0-rc.7
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/README.md +3 -3
- package/dist/coh-content-db.d.ts +384 -181
- package/dist/coh-content-db.js +604 -348
- package/dist/coh-content-db.js.map +1 -1
- package/dist/coh-content-db.mjs +592 -347
- package/dist/coh-content-db.mjs.map +1 -1
- package/eslint.config.mjs +1 -0
- package/package.json +1 -1
- package/src/main/api/alignment.ts +18 -2
- package/src/main/api/badge-data.ts +12 -42
- package/src/main/api/badge-requirement-data.ts +17 -35
- package/src/main/api/badge-requirement-type.ts +28 -7
- package/src/main/api/badge-type.ts +15 -15
- package/src/main/api/contact-data.ts +7 -5
- package/src/main/api/content-bundle.ts +6 -0
- package/src/main/api/enhancement-category.ts +26 -26
- package/src/main/api/location-data.ts +28 -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 +8 -1
- package/src/main/api/zone-data.ts +1 -1
- package/src/main/changelog.ts +5 -4
- package/src/main/db/alignment-list.ts +54 -0
- package/src/main/db/alternates.ts +15 -32
- package/src/main/db/badge-index.ts +11 -36
- package/src/main/db/badge-requirement.ts +22 -43
- package/src/main/db/badge-search-options.ts +4 -4
- package/src/main/db/badge.ts +53 -54
- package/src/main/db/coh-content-database.ts +28 -24
- package/src/main/db/contact.ts +17 -14
- 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/zone.ts +1 -1
- package/src/main/index.ts +8 -3
- package/src/main/util.ts +43 -3
- package/src/test/api/alignment.test.ts +38 -4
- package/src/test/api/badge-data.fixture.ts +1 -17
- package/src/test/api/badge-data.test.ts +3 -3
- package/src/test/api/badge-requirement-data.fixture.ts +1 -11
- package/src/test/api/badge-requirement-type.test.ts +3 -3
- package/src/test/api/badge-type.test.ts +5 -5
- package/src/test/api/contact-data.fixture.ts +0 -6
- package/src/test/api/content-bundle.fixture.ts +1 -17
- package/src/test/api/enhancement-category.test.ts +5 -5
- package/src/test/api/mission-data.fixture.ts +12 -0
- package/src/test/api/sex.test.ts +33 -1
- package/src/test/api/zone-data.fixture.ts +1 -1
- package/src/test/db/alignment-list.test.ts +200 -0
- package/src/test/db/alternates.test.ts +60 -56
- package/src/test/db/badge-index.test.ts +82 -72
- package/src/test/db/badge-requirement.test.ts +35 -70
- package/src/test/db/badge.test.ts +185 -64
- package/src/test/db/coh-content-database.test.ts +58 -69
- package/src/test/db/contact.test.ts +25 -24
- 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 +4 -4
- package/src/test/util.test.ts +54 -1
- package/src/main/api/plaque-type.ts +0 -6
- package/src/main/db/alignments.ts +0 -17
- package/src/test/api/alignments.test.ts +0 -40
- package/src/test/api/plaque-type.test.ts +0 -31
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Badge } from '../../main'
|
|
1
|
+
import { Badge, compareByDefaultName, compareByZoneKey } from '../../main'
|
|
2
2
|
import { badgeDataFixture } from '../api/badge-data.fixture'
|
|
3
3
|
import { badgeRequirementDataFixture } from '../api/badge-requirement-data.fixture'
|
|
4
4
|
|
|
@@ -18,8 +18,8 @@ describe(Badge.name, () => {
|
|
|
18
18
|
|
|
19
19
|
describe('type', () => {
|
|
20
20
|
test('should be set from the data', () => {
|
|
21
|
-
const badge = new Badge(badgeDataFixture.create({ type: '
|
|
22
|
-
expect(badge.type).toEqual('
|
|
21
|
+
const badge = new Badge(badgeDataFixture.create({ type: 'achievement' }))
|
|
22
|
+
expect(badge.type).toEqual('achievement')
|
|
23
23
|
})
|
|
24
24
|
})
|
|
25
25
|
|
|
@@ -30,12 +30,22 @@ describe(Badge.name, () => {
|
|
|
30
30
|
})
|
|
31
31
|
})
|
|
32
32
|
|
|
33
|
-
describe('
|
|
33
|
+
describe('morality', () => {
|
|
34
34
|
test('should be set from the data', () => {
|
|
35
|
-
const badge = new Badge(badgeDataFixture.create({
|
|
36
|
-
expect(badge.
|
|
37
|
-
expect(badge.
|
|
38
|
-
|
|
35
|
+
const badge = new Badge(badgeDataFixture.create({ morality: ['hero', 'villain'] }))
|
|
36
|
+
expect(badge.morality.hero).toBeTruthy()
|
|
37
|
+
expect(badge.morality.villain).toBeTruthy()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
test('should accept a single string', () => {
|
|
41
|
+
const badge = new Badge(badgeDataFixture.create({ morality: 'hero' }))
|
|
42
|
+
expect(badge.morality.hero).toBeTruthy()
|
|
43
|
+
expect(badge.morality.villain).toBeFalsy()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('should be optional, defaulting to all', () => {
|
|
47
|
+
const badge = new Badge(badgeDataFixture.omit('morality').create())
|
|
48
|
+
expect(badge.morality.all).toBeTruthy()
|
|
39
49
|
})
|
|
40
50
|
})
|
|
41
51
|
|
|
@@ -99,30 +109,6 @@ describe(Badge.name, () => {
|
|
|
99
109
|
})
|
|
100
110
|
})
|
|
101
111
|
|
|
102
|
-
describe('zoneKey', () => {
|
|
103
|
-
test('should be set from the data', () => {
|
|
104
|
-
const badge = new Badge(badgeDataFixture.create({ zoneKey: 'foo' }))
|
|
105
|
-
expect(badge.zoneKey).toEqual('foo')
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
test('should be optional', () => {
|
|
109
|
-
const badge = new Badge(badgeDataFixture.omit('zoneKey').create())
|
|
110
|
-
expect(badge.zoneKey).toBeUndefined()
|
|
111
|
-
})
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
describe('loc', () => {
|
|
115
|
-
test('should be set from the data', () => {
|
|
116
|
-
const badge = new Badge(badgeDataFixture.create({ loc: [1, 2, 3] }))
|
|
117
|
-
expect(badge.loc).toStrictEqual([1, 2, 3])
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
test('should be optional', () => {
|
|
121
|
-
const badge = new Badge(badgeDataFixture.omit('loc').create())
|
|
122
|
-
expect(badge.loc).toBeUndefined()
|
|
123
|
-
})
|
|
124
|
-
})
|
|
125
|
-
|
|
126
112
|
describe('effect', () => {
|
|
127
113
|
test('should be set from the data', () => {
|
|
128
114
|
const badge = new Badge(badgeDataFixture.create({ effect: 'foo' }))
|
|
@@ -135,27 +121,20 @@ describe(Badge.name, () => {
|
|
|
135
121
|
})
|
|
136
122
|
})
|
|
137
123
|
|
|
138
|
-
describe('
|
|
124
|
+
describe('setTitle', () => {
|
|
139
125
|
test('should be set from the data', () => {
|
|
140
|
-
const badge = new Badge(badgeDataFixture.create({
|
|
141
|
-
expect(badge.
|
|
126
|
+
const badge = new Badge(badgeDataFixture.create({ setTitleId: [123, 456] }))
|
|
127
|
+
expect(badge.setTitleId).toStrictEqual([123, 456])
|
|
142
128
|
})
|
|
143
129
|
|
|
144
|
-
test('should
|
|
145
|
-
const badge = new Badge(badgeDataFixture.
|
|
146
|
-
expect(badge.
|
|
147
|
-
})
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
describe('setTitle', () => {
|
|
151
|
-
test('should be set from the data', () => {
|
|
152
|
-
const badge = new Badge(badgeDataFixture.create({ setTitle: { id: 123, praetorianId: 456 } }))
|
|
153
|
-
expect(badge.setTitle).toStrictEqual({ id: 123, praetorianId: 456 })
|
|
130
|
+
test('should treat the praetorian id as optional', () => {
|
|
131
|
+
const badge = new Badge(badgeDataFixture.create({ setTitleId: [123] }))
|
|
132
|
+
expect(badge.setTitleId).toStrictEqual([123])
|
|
154
133
|
})
|
|
155
134
|
|
|
156
135
|
test('should be optional', () => {
|
|
157
|
-
const badge = new Badge(badgeDataFixture.omit('
|
|
158
|
-
expect(badge.
|
|
136
|
+
const badge = new Badge(badgeDataFixture.omit('setTitleId').create())
|
|
137
|
+
expect(badge.setTitleId).toBeUndefined()
|
|
159
138
|
})
|
|
160
139
|
})
|
|
161
140
|
|
|
@@ -172,34 +151,22 @@ describe(Badge.name, () => {
|
|
|
172
151
|
})
|
|
173
152
|
|
|
174
153
|
describe('requirements', () => {
|
|
175
|
-
test(`should throw an error on duplicate key
|
|
154
|
+
test(`should throw an error on duplicate key`, () => {
|
|
176
155
|
const data = badgeDataFixture.create({
|
|
177
156
|
key: 'badge',
|
|
178
|
-
requirements: [
|
|
157
|
+
requirements: [
|
|
179
158
|
badgeRequirementDataFixture.create({ key: 'foo' }),
|
|
180
159
|
badgeRequirementDataFixture.create({ key: 'foo' }),
|
|
181
|
-
]
|
|
160
|
+
],
|
|
182
161
|
})
|
|
183
|
-
expect(() => new Badge(data)).toThrow('Duplicate badge requirement key [badge:foo]
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
test(`should not throw an error on duplicate key in different group`, () => {
|
|
187
|
-
const data = badgeDataFixture.create({
|
|
188
|
-
key: 'badge',
|
|
189
|
-
requirements: [[
|
|
190
|
-
badgeRequirementDataFixture.create({ key: 'foo' }),
|
|
191
|
-
], [
|
|
192
|
-
badgeRequirementDataFixture.create({ key: 'foo' }),
|
|
193
|
-
]],
|
|
194
|
-
})
|
|
195
|
-
new Badge(data)
|
|
162
|
+
expect(() => new Badge(data)).toThrow('Duplicate badge requirement key [badge:foo]')
|
|
196
163
|
})
|
|
197
164
|
})
|
|
198
165
|
|
|
199
166
|
describe('getRequirement', () => {
|
|
200
167
|
test(`should retrieve requirement from the index`, () => {
|
|
201
168
|
const data = badgeDataFixture.create({
|
|
202
|
-
requirements: [
|
|
169
|
+
requirements: [badgeRequirementDataFixture.create({ key: 'foo' })],
|
|
203
170
|
})
|
|
204
171
|
|
|
205
172
|
expect(new Badge(data).getRequirement('foo')).not.toBeUndefined()
|
|
@@ -213,4 +180,158 @@ describe(Badge.name, () => {
|
|
|
213
180
|
expect(() => new Badge(data).getRequirement('foo')).toThrow('Unknown badge requirement key [foo]')
|
|
214
181
|
})
|
|
215
182
|
})
|
|
183
|
+
|
|
184
|
+
describe('zoneKeys', () => {
|
|
185
|
+
test(`should return the list of keys`, () => {
|
|
186
|
+
const badge = new Badge(badgeDataFixture.create({
|
|
187
|
+
requirements: [
|
|
188
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'a' } }),
|
|
189
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'c' } }),
|
|
190
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'b' } }),
|
|
191
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'c' } }),
|
|
192
|
+
],
|
|
193
|
+
}))
|
|
194
|
+
expect(badge.zoneKeys).toStrictEqual(['a', 'c', 'b'])
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
test(`should return undefined if there no zones`, () => {
|
|
198
|
+
const badge = new Badge(badgeDataFixture.create({
|
|
199
|
+
requirements: [
|
|
200
|
+
badgeRequirementDataFixture.omit('location').create(),
|
|
201
|
+
],
|
|
202
|
+
}))
|
|
203
|
+
expect(badge.zoneKey).toBeUndefined()
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
test(`should ignore requirements with no location`, () => {
|
|
207
|
+
const badge = new Badge(badgeDataFixture.create({
|
|
208
|
+
requirements: [
|
|
209
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'a' } }),
|
|
210
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'c' } }),
|
|
211
|
+
badgeRequirementDataFixture.omit('location').create(),
|
|
212
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'c' } }),
|
|
213
|
+
],
|
|
214
|
+
}))
|
|
215
|
+
expect(badge.zoneKeys).toStrictEqual(['a', 'c'])
|
|
216
|
+
})
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
describe('zoneKey', () => {
|
|
220
|
+
test(`should return the key for a single zone`, () => {
|
|
221
|
+
const badge = new Badge(badgeDataFixture.create({
|
|
222
|
+
requirements: [
|
|
223
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'a' } }),
|
|
224
|
+
],
|
|
225
|
+
}))
|
|
226
|
+
expect(badge.zoneKey).toBe('a')
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
test(`should return undefined if there no zones`, () => {
|
|
230
|
+
const badge = new Badge(badgeDataFixture.create({
|
|
231
|
+
requirements: [
|
|
232
|
+
badgeRequirementDataFixture.omit('location').create(),
|
|
233
|
+
],
|
|
234
|
+
}))
|
|
235
|
+
expect(badge.zoneKey).toBeUndefined()
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
test(`should return undefined if there are multiple zones`, () => {
|
|
239
|
+
const badge = new Badge(badgeDataFixture.create({
|
|
240
|
+
requirements: [
|
|
241
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'a' } }),
|
|
242
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'c' } }),
|
|
243
|
+
],
|
|
244
|
+
}))
|
|
245
|
+
expect(badge.zoneKey).toBeUndefined()
|
|
246
|
+
})
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
describe(compareByDefaultName.name, () => {
|
|
250
|
+
test(`should compare two badges by name`, () => {
|
|
251
|
+
const badgeA = new Badge(badgeDataFixture.create({ name: 'A' }))
|
|
252
|
+
const badgeB = new Badge(badgeDataFixture.create({ name: 'B' }))
|
|
253
|
+
expect(compareByDefaultName(badgeA, badgeB)).toBeLessThan(0)
|
|
254
|
+
expect([badgeB, badgeA].sort(compareByDefaultName)).toStrictEqual([badgeA, badgeB])
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
test(`should return 0 for equal names`, () => {
|
|
258
|
+
const badgeA = new Badge(badgeDataFixture.create({ name: 'A' }))
|
|
259
|
+
const badgeB = new Badge(badgeDataFixture.create({ name: 'A' }))
|
|
260
|
+
expect(compareByDefaultName(badgeA, badgeB)).toEqual(0)
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
test(`should compare two undefined values`, () => {
|
|
264
|
+
const badgeA = new Badge(badgeDataFixture.create({ name: [] }))
|
|
265
|
+
const badgeB = new Badge(badgeDataFixture.create({ name: [] }))
|
|
266
|
+
expect(compareByDefaultName(badgeA, badgeB)).toEqual(0)
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
test(`should sort undefined values last`, () => {
|
|
270
|
+
const badgeA = new Badge(badgeDataFixture.create({ name: 'A' }))
|
|
271
|
+
const badgeB = new Badge(badgeDataFixture.create({ name: [] }))
|
|
272
|
+
expect([badgeA, badgeB].sort(compareByDefaultName)).toStrictEqual([badgeA, badgeB])
|
|
273
|
+
expect([badgeB, badgeA].sort(compareByDefaultName)).toStrictEqual([badgeA, badgeB])
|
|
274
|
+
})
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
describe(compareByZoneKey.name, () => {
|
|
278
|
+
test(`should compare two badges by zoneKey`, () => {
|
|
279
|
+
const badgeA = new Badge(badgeDataFixture.create({
|
|
280
|
+
requirements: [
|
|
281
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'a' } }),
|
|
282
|
+
],
|
|
283
|
+
}))
|
|
284
|
+
const badgeB = new Badge(badgeDataFixture.create({
|
|
285
|
+
requirements: [
|
|
286
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'b' } }),
|
|
287
|
+
],
|
|
288
|
+
}))
|
|
289
|
+
expect(compareByZoneKey(badgeA, badgeB)).toBeLessThan(0)
|
|
290
|
+
expect([badgeB, badgeA].sort(compareByZoneKey)).toStrictEqual([badgeA, badgeB])
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
test(`should return 0 for equal zoneKeys`, () => {
|
|
294
|
+
const badgeA = new Badge(badgeDataFixture.create({
|
|
295
|
+
requirements: [
|
|
296
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'a' } }),
|
|
297
|
+
],
|
|
298
|
+
}))
|
|
299
|
+
const badgeB = new Badge(badgeDataFixture.create({
|
|
300
|
+
requirements: [
|
|
301
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'a' } }),
|
|
302
|
+
],
|
|
303
|
+
}))
|
|
304
|
+
expect(compareByZoneKey(badgeA, badgeB)).toEqual(0)
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
test(`should equate two undefined values`, () => {
|
|
308
|
+
const badgeA = new Badge(badgeDataFixture.create({
|
|
309
|
+
requirements: [
|
|
310
|
+
badgeRequirementDataFixture.omit('location').create(),
|
|
311
|
+
],
|
|
312
|
+
}))
|
|
313
|
+
const badgeB = new Badge(badgeDataFixture.create({
|
|
314
|
+
requirements: [
|
|
315
|
+
badgeRequirementDataFixture.omit('location').create(),
|
|
316
|
+
],
|
|
317
|
+
}))
|
|
318
|
+
expect(compareByZoneKey(badgeA, badgeB)).toEqual(0)
|
|
319
|
+
})
|
|
320
|
+
|
|
321
|
+
test(`should sort badges with multiple values last`, () => {
|
|
322
|
+
const badgeA = new Badge(badgeDataFixture.create({
|
|
323
|
+
requirements: [
|
|
324
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'a' } }),
|
|
325
|
+
],
|
|
326
|
+
}))
|
|
327
|
+
const badgeB = new Badge(badgeDataFixture.create({
|
|
328
|
+
requirements: [
|
|
329
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'b' } }),
|
|
330
|
+
badgeRequirementDataFixture.create({ location: { zoneKey: 'c' } }),
|
|
331
|
+
],
|
|
332
|
+
}))
|
|
333
|
+
expect([badgeA, badgeB].sort(compareByZoneKey)).toStrictEqual([badgeA, badgeB])
|
|
334
|
+
expect([badgeB, badgeA].sort(compareByZoneKey)).toStrictEqual([badgeA, badgeB])
|
|
335
|
+
})
|
|
336
|
+
})
|
|
216
337
|
})
|
|
@@ -4,6 +4,7 @@ import { archetypeDataFixture } from '../api/archetype-data.fixture'
|
|
|
4
4
|
import { badgeDataFixture } from '../api/badge-data.fixture'
|
|
5
5
|
import { zoneDataFixture } from '../api/zone-data.fixture'
|
|
6
6
|
import { contactDataFixture } from '../api/contact-data.fixture'
|
|
7
|
+
import { missionDataFixture } from '../api/mission-data.fixture'
|
|
7
8
|
|
|
8
9
|
describe(CohContentDatabase.name, () => {
|
|
9
10
|
test('should load a basic bundle', () => {
|
|
@@ -15,7 +16,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
15
16
|
const data = contentBundleFixture
|
|
16
17
|
.omit('servers')
|
|
17
18
|
.create()
|
|
18
|
-
expect(
|
|
19
|
+
expect(new CohContentDatabase(data).servers).toHaveLength(0)
|
|
19
20
|
})
|
|
20
21
|
|
|
21
22
|
test(`should load values from bundle`, () => {
|
|
@@ -40,13 +41,13 @@ describe(CohContentDatabase.name, () => {
|
|
|
40
41
|
const data = contentBundleFixture
|
|
41
42
|
.omit('archetypes')
|
|
42
43
|
.create()
|
|
43
|
-
expect(
|
|
44
|
+
expect(new CohContentDatabase(data).archetypes).toHaveLength(0)
|
|
44
45
|
})
|
|
45
46
|
|
|
46
47
|
test(`should load data from bundle`, () => {
|
|
47
48
|
const data = contentBundleFixture
|
|
48
49
|
.create({ archetypes: [archetypeDataFixture.create({ key: 'foo' })] })
|
|
49
|
-
expect(
|
|
50
|
+
expect(new CohContentDatabase(data).getArchetype('foo')).not.toBeUndefined()
|
|
50
51
|
})
|
|
51
52
|
})
|
|
52
53
|
|
|
@@ -65,7 +66,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
65
66
|
const data = contentBundleFixture
|
|
66
67
|
.omit('badges')
|
|
67
68
|
.create()
|
|
68
|
-
expect(
|
|
69
|
+
expect(new CohContentDatabase(data).badges).toHaveLength(0)
|
|
69
70
|
})
|
|
70
71
|
})
|
|
71
72
|
|
|
@@ -84,7 +85,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
84
85
|
const data = contentBundleFixture
|
|
85
86
|
.omit('zones')
|
|
86
87
|
.create()
|
|
87
|
-
expect(
|
|
88
|
+
expect(new CohContentDatabase(data).zones).toHaveLength(0)
|
|
88
89
|
})
|
|
89
90
|
})
|
|
90
91
|
|
|
@@ -103,7 +104,26 @@ describe(CohContentDatabase.name, () => {
|
|
|
103
104
|
const data = contentBundleFixture
|
|
104
105
|
.omit('contacts')
|
|
105
106
|
.create()
|
|
106
|
-
expect(
|
|
107
|
+
expect(new CohContentDatabase(data).contacts).toHaveLength(0)
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
describe('missions', () => {
|
|
112
|
+
test(`should throw an error on duplicate mission`, () => {
|
|
113
|
+
const data = contentBundleFixture.create({
|
|
114
|
+
missions: [
|
|
115
|
+
missionDataFixture.create({ key: 'foo' }),
|
|
116
|
+
missionDataFixture.create({ key: 'foo' }),
|
|
117
|
+
],
|
|
118
|
+
})
|
|
119
|
+
expect(() => new CohContentDatabase(data)).toThrow(`Duplicate mission key 'foo'`)
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
test(`should accept an undefined field`, () => {
|
|
123
|
+
const data = contentBundleFixture
|
|
124
|
+
.omit('missions')
|
|
125
|
+
.create()
|
|
126
|
+
expect(new CohContentDatabase(data).missions).toHaveLength(0)
|
|
107
127
|
})
|
|
108
128
|
})
|
|
109
129
|
|
|
@@ -116,12 +136,13 @@ describe(CohContentDatabase.name, () => {
|
|
|
116
136
|
expect(new CohContentDatabase(data).getArchetype('foo')).not.toBeUndefined()
|
|
117
137
|
})
|
|
118
138
|
|
|
119
|
-
test(`should
|
|
120
|
-
const data = contentBundleFixture.create({
|
|
121
|
-
|
|
122
|
-
|
|
139
|
+
test(`should return undefined for unknown archetype`, () => {
|
|
140
|
+
const data = contentBundleFixture.create({ archetypes: [] })
|
|
141
|
+
expect(new CohContentDatabase(data).getArchetype('foo')).toBeUndefined()
|
|
142
|
+
})
|
|
123
143
|
|
|
124
|
-
|
|
144
|
+
test(`should return undefined for undefined key`, () => {
|
|
145
|
+
expect(new CohContentDatabase(contentBundleFixture.create({ archetypes: [] })).getArchetype()).toBeUndefined()
|
|
125
146
|
})
|
|
126
147
|
})
|
|
127
148
|
|
|
@@ -134,30 +155,13 @@ describe(CohContentDatabase.name, () => {
|
|
|
134
155
|
expect(new CohContentDatabase(data).getZone('foo')).not.toBeUndefined()
|
|
135
156
|
})
|
|
136
157
|
|
|
137
|
-
test(`should
|
|
138
|
-
const data = contentBundleFixture.create({
|
|
139
|
-
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
expect(() => new CohContentDatabase(data).getZone('foo')).toThrow(`Unknown zone key 'foo'`)
|
|
143
|
-
})
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
describe('zoneExists', () => {
|
|
147
|
-
test(`should return true for a zone that exists`, () => {
|
|
148
|
-
const data = contentBundleFixture.create({
|
|
149
|
-
zones: [zoneDataFixture.create({ key: 'foo' })],
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
expect(new CohContentDatabase(data).zoneExists('foo')).toBeTruthy()
|
|
158
|
+
test(`should return undefined for unknown zone`, () => {
|
|
159
|
+
const data = contentBundleFixture.create({ zones: [] })
|
|
160
|
+
expect(new CohContentDatabase(data).getZone('foo')).toBeUndefined()
|
|
153
161
|
})
|
|
154
162
|
|
|
155
|
-
test(`should return
|
|
156
|
-
|
|
157
|
-
zones: [],
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
expect(new CohContentDatabase(data).zoneExists('foo')).toBeFalsy()
|
|
163
|
+
test(`should return undefined for undefined key`, () => {
|
|
164
|
+
expect(new CohContentDatabase(contentBundleFixture.create({ zones: [] })).getZone()).toBeUndefined()
|
|
161
165
|
})
|
|
162
166
|
})
|
|
163
167
|
|
|
@@ -170,30 +174,32 @@ describe(CohContentDatabase.name, () => {
|
|
|
170
174
|
expect(new CohContentDatabase(data).getContact('foo')).not.toBeUndefined()
|
|
171
175
|
})
|
|
172
176
|
|
|
173
|
-
test(`should
|
|
174
|
-
const data = contentBundleFixture.create({
|
|
175
|
-
|
|
176
|
-
|
|
177
|
+
test(`should return undefined for unknown contact`, () => {
|
|
178
|
+
const data = contentBundleFixture.create({ contacts: [] })
|
|
179
|
+
expect(new CohContentDatabase(data).getContact('foo')).toBeUndefined()
|
|
180
|
+
})
|
|
177
181
|
|
|
178
|
-
|
|
182
|
+
test(`should return undefined for undefined key`, () => {
|
|
183
|
+
expect(new CohContentDatabase(contentBundleFixture.create({ contacts: [] })).getContact()).toBeUndefined()
|
|
179
184
|
})
|
|
180
185
|
})
|
|
181
186
|
|
|
182
|
-
describe('
|
|
183
|
-
test(`should
|
|
187
|
+
describe('getMission', () => {
|
|
188
|
+
test(`should retrieve mission from the index`, () => {
|
|
184
189
|
const data = contentBundleFixture.create({
|
|
185
|
-
|
|
190
|
+
missions: [missionDataFixture.create({ key: 'foo' })],
|
|
186
191
|
})
|
|
187
192
|
|
|
188
|
-
expect(new CohContentDatabase(data).
|
|
193
|
+
expect(new CohContentDatabase(data).getMission('foo')).not.toBeUndefined()
|
|
189
194
|
})
|
|
190
195
|
|
|
191
|
-
test(`should return
|
|
192
|
-
const data = contentBundleFixture.create({
|
|
193
|
-
|
|
194
|
-
|
|
196
|
+
test(`should return undefined for unknown mission`, () => {
|
|
197
|
+
const data = contentBundleFixture.create({ missions: [] })
|
|
198
|
+
expect(new CohContentDatabase(data).getMission('foo')).toBeUndefined()
|
|
199
|
+
})
|
|
195
200
|
|
|
196
|
-
|
|
201
|
+
test(`should return undefined for undefined key`, () => {
|
|
202
|
+
expect(new CohContentDatabase(contentBundleFixture.create({ missions: [] })).getMission()).toBeUndefined()
|
|
197
203
|
})
|
|
198
204
|
})
|
|
199
205
|
|
|
@@ -206,30 +212,13 @@ describe(CohContentDatabase.name, () => {
|
|
|
206
212
|
expect(new CohContentDatabase(data).getBadge('foo')).not.toBeUndefined()
|
|
207
213
|
})
|
|
208
214
|
|
|
209
|
-
test(`should
|
|
210
|
-
const data = contentBundleFixture.create({
|
|
211
|
-
|
|
212
|
-
})
|
|
213
|
-
|
|
214
|
-
expect(() => new CohContentDatabase(data).getBadge('foo')).toThrow('Unknown badge key [foo]')
|
|
215
|
-
})
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
describe('badgeExists', () => {
|
|
219
|
-
test(`should return true for a badge that exists`, () => {
|
|
220
|
-
const data = contentBundleFixture.create({
|
|
221
|
-
badges: [badgeDataFixture.create({ key: 'foo' })],
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
expect(new CohContentDatabase(data).badgeExists('foo')).toBeTruthy()
|
|
215
|
+
test(`should return undefined for unknown badge`, () => {
|
|
216
|
+
const data = contentBundleFixture.create({ badges: [] })
|
|
217
|
+
expect(new CohContentDatabase(data).getBadge('foo')).toBeUndefined()
|
|
225
218
|
})
|
|
226
219
|
|
|
227
|
-
test(`should return
|
|
228
|
-
|
|
229
|
-
badges: [],
|
|
230
|
-
})
|
|
231
|
-
|
|
232
|
-
expect(new CohContentDatabase(data).badgeExists('foo')).toBeFalsy()
|
|
220
|
+
test(`should return undefined for undefined key`, () => {
|
|
221
|
+
expect(new CohContentDatabase(contentBundleFixture.create({ badges: [] })).getBadge()).toBeUndefined()
|
|
233
222
|
})
|
|
234
223
|
})
|
|
235
224
|
|
|
@@ -9,86 +9,87 @@ describe(Contact.name, () => {
|
|
|
9
9
|
})
|
|
10
10
|
|
|
11
11
|
describe('key', () => {
|
|
12
|
-
test(`should
|
|
12
|
+
test(`should be set from the data`, () => {
|
|
13
13
|
const contact = new Contact(contactDataFixture.create({ key: 'foo' }))
|
|
14
14
|
expect(contact.key).toEqual('foo')
|
|
15
15
|
})
|
|
16
16
|
})
|
|
17
17
|
|
|
18
18
|
describe('name', () => {
|
|
19
|
-
test(`should
|
|
19
|
+
test(`should be set from the data`, () => {
|
|
20
20
|
const contact = new Contact(contactDataFixture.create({ name: 'foo' }))
|
|
21
21
|
expect(contact.name).toEqual('foo')
|
|
22
22
|
})
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
describe('title', () => {
|
|
26
|
-
test(`should
|
|
26
|
+
test(`should be set from the data`, () => {
|
|
27
27
|
const contact = new Contact(contactDataFixture.create({ title: 'foo' }))
|
|
28
28
|
expect(contact.title).toEqual('foo')
|
|
29
29
|
})
|
|
30
30
|
|
|
31
|
-
test(`should
|
|
31
|
+
test(`should be optional`, () => {
|
|
32
32
|
const contact = new Contact(contactDataFixture.omit('title').create())
|
|
33
33
|
expect(contact.title).toBeUndefined()
|
|
34
34
|
})
|
|
35
35
|
})
|
|
36
36
|
|
|
37
|
-
describe('
|
|
38
|
-
test(`should
|
|
39
|
-
const contact = new Contact(contactDataFixture.create({
|
|
40
|
-
expect(contact.
|
|
37
|
+
describe('morality', () => {
|
|
38
|
+
test(`should be set from the data`, () => {
|
|
39
|
+
const contact = new Contact(contactDataFixture.create({ morality: ['hero'] }))
|
|
40
|
+
expect(contact.morality?.hero).toBeTruthy()
|
|
41
|
+
expect(contact.morality?.vigilante).toBeFalsy()
|
|
41
42
|
})
|
|
42
43
|
|
|
43
|
-
test(`should
|
|
44
|
-
const contact = new Contact(contactDataFixture.omit('
|
|
45
|
-
expect(contact.
|
|
44
|
+
test(`should be optional`, () => {
|
|
45
|
+
const contact = new Contact(contactDataFixture.omit('morality').create())
|
|
46
|
+
expect(contact.morality?.all).toBeTruthy()
|
|
46
47
|
})
|
|
47
48
|
})
|
|
48
49
|
|
|
49
|
-
describe('
|
|
50
|
-
test(`should
|
|
51
|
-
const contact = new Contact(contactDataFixture.create({
|
|
52
|
-
expect(contact.
|
|
50
|
+
describe('zoneKey', () => {
|
|
51
|
+
test(`should be set from the data`, () => {
|
|
52
|
+
const contact = new Contact(contactDataFixture.create({ location: { zoneKey: 'atlas-park', coords: [1, -2, 3.5] } }))
|
|
53
|
+
expect(contact.location).toEqual({ zoneKey: 'atlas-park', coords: [1, -2, 3.5] })
|
|
53
54
|
})
|
|
54
55
|
|
|
55
|
-
test(`should
|
|
56
|
-
const contact = new Contact(contactDataFixture.omit('
|
|
57
|
-
expect(contact.
|
|
56
|
+
test(`should be optional`, () => {
|
|
57
|
+
const contact = new Contact(contactDataFixture.omit('location').create())
|
|
58
|
+
expect(contact.location).toBeUndefined()
|
|
58
59
|
})
|
|
59
60
|
})
|
|
60
61
|
|
|
61
62
|
describe('levelRange', () => {
|
|
62
|
-
test(`should
|
|
63
|
+
test(`should be set from the data`, () => {
|
|
63
64
|
const contact = new Contact(contactDataFixture.create({ levelRange: [1, 2] }))
|
|
64
65
|
expect(contact.levelRange).toStrictEqual([1, 2])
|
|
65
66
|
})
|
|
66
67
|
|
|
67
|
-
test(`should
|
|
68
|
+
test(`should be optional`, () => {
|
|
68
69
|
const contact = new Contact(contactDataFixture.omit('levelRange').create())
|
|
69
70
|
expect(contact.levelRange).toBeUndefined()
|
|
70
71
|
})
|
|
71
72
|
})
|
|
72
73
|
|
|
73
74
|
describe('notes', () => {
|
|
74
|
-
test(`should
|
|
75
|
+
test(`should be set from the data`, () => {
|
|
75
76
|
const contact = new Contact(contactDataFixture.create({ notes: 'foo' }))
|
|
76
77
|
expect(contact.notes).toEqual('foo')
|
|
77
78
|
})
|
|
78
79
|
|
|
79
|
-
test(`should
|
|
80
|
+
test(`should be optional`, () => {
|
|
80
81
|
const contact = new Contact(contactDataFixture.omit('notes').create())
|
|
81
82
|
expect(contact.notes).toBeUndefined()
|
|
82
83
|
})
|
|
83
84
|
})
|
|
84
85
|
|
|
85
86
|
describe('links', () => {
|
|
86
|
-
test(`should
|
|
87
|
+
test(`should be set from the data`, () => {
|
|
87
88
|
const contact = new Contact(contactDataFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
|
|
88
89
|
expect(contact.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
|
|
89
90
|
})
|
|
90
91
|
|
|
91
|
-
test(`should
|
|
92
|
+
test(`should be optional`, () => {
|
|
92
93
|
const contact = new Contact(contactDataFixture.omit('links').create())
|
|
93
94
|
expect(contact.links).toHaveLength(0)
|
|
94
95
|
})
|