coh-content-db 2.0.0-rc.9 → 2.0.0

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.
Files changed (66) hide show
  1. package/.github/workflows/build.yml +3 -1
  2. package/CHANGELOG.md +11 -2
  3. package/README.md +33 -19
  4. package/dist/coh-content-db.d.ts +230 -170
  5. package/dist/coh-content-db.js +495 -296
  6. package/dist/coh-content-db.js.map +1 -1
  7. package/dist/coh-content-db.mjs +488 -294
  8. package/dist/coh-content-db.mjs.map +1 -1
  9. package/jest.config.mjs +1 -0
  10. package/package.json +14 -14
  11. package/src/main/api/badge-data.ts +13 -7
  12. package/src/main/api/bundle-data.ts +1 -1
  13. package/src/main/api/bundle-header-data.ts +13 -6
  14. package/src/main/api/contact-data.ts +2 -1
  15. package/src/main/api/level-range-data.ts +4 -0
  16. package/src/main/api/mission-data.ts +3 -29
  17. package/src/main/api/mission-flashback-data.ts +31 -0
  18. package/src/main/api/morality.ts +27 -9
  19. package/src/main/api/set-title-data.ts +4 -0
  20. package/src/main/api/variant-context.ts +11 -0
  21. package/src/main/api/{alternate-data.ts → variant-data.ts} +4 -4
  22. package/src/main/api/zone-data.ts +24 -0
  23. package/src/main/api/zone-type.ts +59 -0
  24. package/src/main/db/abstract-index.ts +12 -16
  25. package/src/main/db/badge-index.ts +53 -27
  26. package/src/main/db/badge-requirement.ts +1 -1
  27. package/src/main/db/badge-search-options.ts +15 -14
  28. package/src/main/db/badge.ts +46 -29
  29. package/src/main/db/bundle-header.ts +18 -10
  30. package/src/main/db/coh-content-database.ts +17 -17
  31. package/src/main/db/contact.ts +5 -4
  32. package/src/main/db/level-range.ts +15 -0
  33. package/src/main/db/mission.ts +11 -10
  34. package/src/main/db/paged.ts +7 -3
  35. package/src/main/db/set-title-ids.ts +10 -0
  36. package/src/main/db/variants.ts +84 -0
  37. package/src/main/db/zone.ts +29 -0
  38. package/src/main/index.ts +11 -4
  39. package/src/main/util/coalesce-to-array.ts +13 -0
  40. package/src/main/{util.ts → util/links.ts} +8 -22
  41. package/src/main/util/to-date.ts +9 -0
  42. package/src/test/api/alignment.test.ts +2 -2
  43. package/src/test/api/badge-data.fixture.ts +1 -0
  44. package/src/test/api/badge-data.test.ts +1 -0
  45. package/src/test/api/bundle-data.fixture.ts +3 -2
  46. package/src/test/api/bundle-header-data.fixture.ts +4 -2
  47. package/src/test/api/morality.test.ts +31 -0
  48. package/src/test/api/sex.test.ts +2 -2
  49. package/src/test/api/zone-data.fixture.ts +1 -0
  50. package/src/test/db/abstract-index.test.ts +12 -43
  51. package/src/test/db/badge-index.test.ts +197 -101
  52. package/src/test/db/badge.test.ts +122 -16
  53. package/src/test/db/bundle-header.test.ts +25 -12
  54. package/src/test/db/coh-content-database.test.ts +134 -175
  55. package/src/test/db/contact.test.ts +2 -1
  56. package/src/test/db/level-range.test.ts +47 -0
  57. package/src/test/db/mission.test.ts +8 -6
  58. package/src/test/db/morality-list.test.ts +1 -1
  59. package/src/test/db/set-title-ids.test.ts +19 -0
  60. package/src/test/db/{alternates.test.ts → variants.test.ts} +24 -24
  61. package/src/test/db/zone.test.ts +45 -0
  62. package/src/test/integration.test.ts +3 -3
  63. package/src/test/util/coalese-to-array.test.ts +17 -0
  64. package/src/test/{util.test.ts → util/links.test.ts} +5 -21
  65. package/src/test/util/to-date.test.ts +15 -0
  66. package/src/main/db/alternates.ts +0 -67
@@ -7,53 +7,27 @@ import { missionDataFixture } from '../api/mission-data.fixture'
7
7
  import { bundleDataFixture } from '../api/bundle-data.fixture'
8
8
 
9
9
  describe(CohContentDatabase.name, () => {
10
- describe('load', () => {
10
+ describe('Constructor', () => {
11
11
  test('should load a basic bundle', () => {
12
- const database = new CohContentDatabase()
13
- database.load({})
14
- })
15
-
16
- test('should reset the database if load is called again', () => {
17
- const database = new CohContentDatabase()
18
- database.load(bundleDataFixture.create({
19
- header: { name: 'Homecoming' },
20
- servers: ['Test'],
21
- archetypes: [archetypeDataFixture.create()],
22
- zones: [zoneDataFixture.create()],
23
- contacts: [contactDataFixture.create()],
24
- missions: [missionDataFixture.create()],
25
- badges: [badgeDataFixture.create()],
26
- }))
27
-
28
- expect(database.header?.name).toEqual('Homecoming')
29
- expect(database.servers).toHaveLength(1)
30
- expect(database.archetypes).toHaveLength(1)
31
- expect(database.zones).toHaveLength(1)
32
- expect(database.contacts).toHaveLength(1)
33
- expect(database.missions).toHaveLength(1)
34
- expect(database.badges).toHaveLength(1)
35
-
36
- database.load(bundleDataFixture.create({ header: { name: 'Reset' } }))
37
- expect(database.header?.name).toEqual('Reset')
38
- expect(database.servers).toHaveLength(0)
39
- expect(database.archetypes).toHaveLength(0)
40
- expect(database.zones).toHaveLength(0)
41
- expect(database.contacts).toHaveLength(0)
42
- expect(database.missions).toHaveLength(0)
43
- expect(database.badges).toHaveLength(0)
12
+ new CohContentDatabase(bundleDataFixture.create())
44
13
  })
45
14
  })
46
15
 
47
16
  describe('header', () => {
48
- test(`should be undefined if not initialized`, () => {
49
- const database = new CohContentDatabase()
50
- expect(database.header).toBeUndefined()
17
+ test(`should not accept an undefined field`, () => {
18
+ expect(() =>
19
+ new CohContentDatabase(
20
+ bundleDataFixture.omit('header').create(),
21
+ ),
22
+ ).toThrow('Missing header data')
51
23
  })
52
24
 
53
25
  test(`should load values from bundle`, () => {
54
- const database = new CohContentDatabase()
55
- database.load(bundleDataFixture
56
- .create({ header: { name: 'Homecoming' } }))
26
+ const database = new CohContentDatabase(
27
+ bundleDataFixture.create(
28
+ { header: { name: 'Homecoming' } },
29
+ ),
30
+ )
57
31
 
58
32
  expect(database.header?.name).toBe('Homecoming')
59
33
  })
@@ -61,153 +35,127 @@ describe(CohContentDatabase.name, () => {
61
35
 
62
36
  describe('servers', () => {
63
37
  test(`should accept an undefined field`, () => {
64
- const database = new CohContentDatabase()
65
- database.load(bundleDataFixture
66
- .omit('servers')
67
- .create())
68
-
69
- expect(database.servers).toHaveLength(0)
70
- })
71
-
72
- test(`should be empty if uninitialized`, () => {
73
- const database = new CohContentDatabase()
38
+ const database = new CohContentDatabase(
39
+ bundleDataFixture.omit('servers').create(),
40
+ )
74
41
  expect(database.servers).toHaveLength(0)
75
42
  })
76
43
 
77
44
  test(`should load values from bundle`, () => {
78
- const database = new CohContentDatabase()
79
- database.load(bundleDataFixture
80
- .create({ servers: ['Foo', 'Bar'] }))
81
-
45
+ const database = new CohContentDatabase(
46
+ bundleDataFixture
47
+ .create({ servers: ['Foo', 'Bar'] }),
48
+ )
82
49
  expect(database.servers).toStrictEqual(['Foo', 'Bar'])
83
50
  })
84
51
  })
85
52
 
86
53
  describe('archetypes', () => {
87
- test(`should throw an error on duplicate key`, () => {
88
- const database = new CohContentDatabase()
89
- expect(() => database.load(bundleDataFixture.create({
90
- archetypes: [
91
- archetypeDataFixture.create({ key: 'foo' }),
92
- archetypeDataFixture.create({ key: 'foo' }),
93
- ],
94
- }))).toThrow(`Duplicate key [foo]`)
95
- })
96
-
97
54
  test(`should accept an undefined field`, () => {
98
- const database = new CohContentDatabase()
99
- database.load(bundleDataFixture
55
+ const database = new CohContentDatabase(bundleDataFixture
100
56
  .omit('archetypes')
101
57
  .create())
102
58
  expect(database.archetypes).toHaveLength(0)
103
59
  })
104
60
 
105
61
  test(`should load data from bundle`, () => {
106
- const database = new CohContentDatabase()
107
- database.load(bundleDataFixture
108
- .create({ archetypes: [archetypeDataFixture.create({ key: 'foo' })] }))
62
+ const database = new CohContentDatabase(
63
+ bundleDataFixture
64
+ .create({ archetypes: [archetypeDataFixture.create({ key: 'foo' })] }),
65
+ )
109
66
  expect(database.getArchetype('foo')).not.toBeUndefined()
110
67
  })
111
68
  })
112
69
 
113
70
  describe('badges', () => {
114
- test(`should throw an error on duplicate key`, () => {
115
- const database = new CohContentDatabase()
116
- expect(() => database.load(bundleDataFixture.create({
117
- badges: [
118
- badgeDataFixture.create({ key: 'foo' }),
119
- badgeDataFixture.create({ key: 'foo' }),
120
- ],
121
- }))).toThrow('Duplicate key [foo]')
122
- })
123
-
124
71
  test(`should accept an undefined field`, () => {
125
- const database = new CohContentDatabase()
126
- database.load(bundleDataFixture
127
- .omit('badges')
128
- .create())
72
+ const database = new CohContentDatabase(
73
+ bundleDataFixture.omit('badges').create(),
74
+ )
129
75
  expect(database.badges).toHaveLength(0)
130
76
  })
131
- })
132
77
 
133
- describe('zones', () => {
134
- test(`should throw an error on duplicate zone`, () => {
135
- const database = new CohContentDatabase()
136
- expect(() => database.load(bundleDataFixture.create({
137
- zones: [
138
- zoneDataFixture.create({ key: 'foo' }),
139
- zoneDataFixture.create({ key: 'foo' }),
140
- ],
141
- }))).toThrow(`Duplicate key [foo]`)
78
+ test(`should load data from bundle`, () => {
79
+ const database = new CohContentDatabase(
80
+ bundleDataFixture
81
+ .create({ badges: [badgeDataFixture.create({ key: 'foo' })] }),
82
+ )
83
+ expect(database.getBadge('foo')).not.toBeUndefined()
142
84
  })
85
+ })
143
86
 
87
+ describe('zones', () => {
144
88
  test(`should accept an undefined field`, () => {
145
- const database = new CohContentDatabase()
146
- database.load(bundleDataFixture
147
- .omit('zones')
148
- .create())
89
+ const database = new CohContentDatabase(
90
+ bundleDataFixture.omit('zones').create(),
91
+ )
149
92
  expect(database.zones).toHaveLength(0)
150
93
  })
151
- })
152
94
 
153
- describe('contacts', () => {
154
- test(`should throw an error on duplicate contact`, () => {
155
- const database = new CohContentDatabase()
156
- expect(() => database.load(bundleDataFixture.create({
157
- contacts: [
158
- contactDataFixture.create({ key: 'foo' }),
159
- contactDataFixture.create({ key: 'foo' }),
160
- ],
161
- }))).toThrow(`Duplicate key [foo]`)
95
+ test(`should load data from bundle`, () => {
96
+ const database = new CohContentDatabase(
97
+ bundleDataFixture
98
+ .create({ zones: [zoneDataFixture.create({ key: 'foo' })] }),
99
+ )
100
+ expect(database.getZone('foo')).not.toBeUndefined()
162
101
  })
102
+ })
163
103
 
104
+ describe('contacts', () => {
164
105
  test(`should accept an undefined field`, () => {
165
- const database = new CohContentDatabase()
166
- database.load(bundleDataFixture
167
- .omit('contacts')
168
- .create())
106
+ const database = new CohContentDatabase(
107
+ bundleDataFixture.omit('contacts').create(),
108
+ )
169
109
  expect(database.contacts).toHaveLength(0)
170
110
  })
171
- })
172
111
 
173
- describe('missions', () => {
174
- test(`should throw an error on duplicate mission`, () => {
175
- const database = new CohContentDatabase()
176
- expect(() => database.load(bundleDataFixture.create({
177
- missions: [
178
- missionDataFixture.create({ key: 'foo' }),
179
- missionDataFixture.create({ key: 'foo' }),
180
- ],
181
- }))).toThrow(`Duplicate key [foo]`)
112
+ test(`should load data from bundle`, () => {
113
+ const database = new CohContentDatabase(
114
+ bundleDataFixture
115
+ .create({ contacts: [contactDataFixture.create({ key: 'foo' })] }),
116
+ )
117
+ expect(database.getContact('foo')).not.toBeUndefined()
182
118
  })
119
+ })
183
120
 
121
+ describe('missions', () => {
184
122
  test(`should accept an undefined field`, () => {
185
- const database = new CohContentDatabase()
186
- database.load(bundleDataFixture
187
- .omit('missions')
188
- .create())
123
+ const database = new CohContentDatabase(
124
+ bundleDataFixture.omit('missions').create(),
125
+ )
189
126
  expect(database.missions).toHaveLength(0)
190
127
  })
128
+
129
+ test(`should load data from bundle`, () => {
130
+ const database = new CohContentDatabase(
131
+ bundleDataFixture
132
+ .create({ missions: [missionDataFixture.create({ key: 'foo' })] }),
133
+ )
134
+ expect(database.getMission('foo')).not.toBeUndefined()
135
+ })
191
136
  })
192
137
 
193
138
  describe('getArchetype', () => {
194
139
  test(`should retrieve archetype from the index`, () => {
195
- const database = new CohContentDatabase()
196
- database.load(bundleDataFixture.create({
197
- archetypes: [archetypeDataFixture.create({ key: 'foo' })],
198
- }))
140
+ const database = new CohContentDatabase(
141
+ bundleDataFixture.create({
142
+ archetypes: [archetypeDataFixture.create({ key: 'foo' })],
143
+ }),
144
+ )
199
145
  expect(database.getArchetype('foo')).not.toBeUndefined()
200
146
  })
201
147
 
202
148
  test(`should return undefined for unknown archetype`, () => {
203
- const database = new CohContentDatabase()
204
- database.load(bundleDataFixture.create({ archetypes: [] }))
149
+ const database = new CohContentDatabase(
150
+ bundleDataFixture.create({ archetypes: [] }),
151
+ )
205
152
  expect(database.getArchetype('foo')).toBeUndefined()
206
153
  })
207
154
 
208
155
  test(`should return undefined for undefined key`, () => {
209
- const database = new CohContentDatabase()
210
- database.load(bundleDataFixture.create({ archetypes: [] }))
156
+ const database = new CohContentDatabase(
157
+ bundleDataFixture.create({ archetypes: [] }),
158
+ )
211
159
  const key = undefined
212
160
  expect(database.getArchetype(key)).toBeUndefined()
213
161
  })
@@ -215,23 +163,23 @@ describe(CohContentDatabase.name, () => {
215
163
 
216
164
  describe('getZone', () => {
217
165
  test(`should retrieve zone from the index`, () => {
218
- const database = new CohContentDatabase()
219
- database.load(bundleDataFixture.create({
220
- zones: [zoneDataFixture.create({ key: 'foo' })],
221
- }))
222
-
166
+ const database = new CohContentDatabase(
167
+ bundleDataFixture.create({
168
+ zones: [zoneDataFixture.create({ key: 'foo' })],
169
+ }),
170
+ )
223
171
  expect(database.getZone('foo')).not.toBeUndefined()
224
172
  })
225
173
 
226
174
  test(`should return undefined for unknown zone`, () => {
227
- const database = new CohContentDatabase()
228
- database.load(bundleDataFixture.create({ zones: [] }))
175
+ const database = new CohContentDatabase(bundleDataFixture.create({ zones: [] }))
229
176
  expect(database.getZone('foo')).toBeUndefined()
230
177
  })
231
178
 
232
179
  test(`should return undefined for undefined key`, () => {
233
- const database = new CohContentDatabase()
234
- database.load(bundleDataFixture.create({ zones: [] }))
180
+ const database = new CohContentDatabase(
181
+ bundleDataFixture.create({ zones: [] }),
182
+ )
235
183
  const key = undefined
236
184
  expect(database.getZone(key)).toBeUndefined()
237
185
  })
@@ -239,22 +187,25 @@ describe(CohContentDatabase.name, () => {
239
187
 
240
188
  describe('getContact', () => {
241
189
  test(`should retrieve contact from the index`, () => {
242
- const database = new CohContentDatabase()
243
- database.load(bundleDataFixture.create({
244
- contacts: [contactDataFixture.create({ key: 'foo' })],
245
- }))
190
+ const database = new CohContentDatabase(
191
+ bundleDataFixture.create({
192
+ contacts: [contactDataFixture.create({ key: 'foo' })],
193
+ }),
194
+ )
246
195
  expect(database.getContact('foo')).not.toBeUndefined()
247
196
  })
248
197
 
249
198
  test(`should return undefined for unknown contact`, () => {
250
- const database = new CohContentDatabase()
251
- database.load(bundleDataFixture.create({ contacts: [] }))
199
+ const database = new CohContentDatabase(
200
+ bundleDataFixture.create({ contacts: [] }),
201
+ )
252
202
  expect(database.getContact('foo')).toBeUndefined()
253
203
  })
254
204
 
255
205
  test(`should return undefined for undefined key`, () => {
256
- const database = new CohContentDatabase()
257
- database.load(bundleDataFixture.create({ contacts: [] }))
206
+ const database = new CohContentDatabase(
207
+ bundleDataFixture.create({ contacts: [] }),
208
+ )
258
209
  const key = undefined
259
210
  expect(database.getContact(key)).toBeUndefined()
260
211
  })
@@ -262,22 +213,25 @@ describe(CohContentDatabase.name, () => {
262
213
 
263
214
  describe('getMission', () => {
264
215
  test(`should retrieve mission from the index`, () => {
265
- const database = new CohContentDatabase()
266
- database.load(bundleDataFixture.create({
267
- missions: [missionDataFixture.create({ key: 'foo' })],
268
- }))
216
+ const database = new CohContentDatabase(
217
+ bundleDataFixture.create({
218
+ missions: [missionDataFixture.create({ key: 'foo' })],
219
+ }),
220
+ )
269
221
  expect(database.getMission('foo')).not.toBeUndefined()
270
222
  })
271
223
 
272
224
  test(`should return undefined for unknown mission`, () => {
273
- const database = new CohContentDatabase()
274
- database.load(bundleDataFixture.create({ missions: [] }))
225
+ const database = new CohContentDatabase(
226
+ bundleDataFixture.create({ missions: [] }),
227
+ )
275
228
  expect(database.getMission('foo')).toBeUndefined()
276
229
  })
277
230
 
278
231
  test(`should return undefined for undefined key`, () => {
279
- const database = new CohContentDatabase()
280
- database.load(bundleDataFixture.create({ missions: [] }))
232
+ const database = new CohContentDatabase(
233
+ bundleDataFixture.create({ missions: [] }),
234
+ )
281
235
  const key = undefined
282
236
  expect(database.getMission(key)).toBeUndefined()
283
237
  })
@@ -285,22 +239,25 @@ describe(CohContentDatabase.name, () => {
285
239
 
286
240
  describe('getBadge', () => {
287
241
  test(`should retrieve badge from the index`, () => {
288
- const database = new CohContentDatabase()
289
- database.load(bundleDataFixture.create({
290
- badges: [badgeDataFixture.create({ key: 'foo' })],
291
- }))
242
+ const database = new CohContentDatabase(
243
+ bundleDataFixture.create({
244
+ badges: [badgeDataFixture.create({ key: 'foo' })],
245
+ }),
246
+ )
292
247
  expect(database.getBadge('foo')).not.toBeUndefined()
293
248
  })
294
249
 
295
250
  test(`should return undefined for unknown badge`, () => {
296
- const database = new CohContentDatabase()
297
- database.load(bundleDataFixture.create({ badges: [] }))
251
+ const database = new CohContentDatabase(
252
+ bundleDataFixture.create({ badges: [] }),
253
+ )
298
254
  expect(database.getBadge('foo')).toBeUndefined()
299
255
  })
300
256
 
301
257
  test(`should return undefined for undefined key`, () => {
302
- const database = new CohContentDatabase()
303
- database.load(bundleDataFixture.create({ badges: [] }))
258
+ const database = new CohContentDatabase(
259
+ bundleDataFixture.create({ badges: [] }),
260
+ )
304
261
  const key = undefined
305
262
  expect(database.getBadge(key)).toBeUndefined()
306
263
  })
@@ -308,16 +265,18 @@ describe(CohContentDatabase.name, () => {
308
265
 
309
266
  describe('searchBadges', () => {
310
267
  test(`should search the badge list`, () => {
311
- const database = new CohContentDatabase()
312
- database.load(bundleDataFixture.create({
313
- badges: [
314
- badgeDataFixture.create({ key: 'foo', name: [{ value: 'Foo' }] }),
315
- badgeDataFixture.create({ key: 'bar', name: [{ value: 'Bar' }] }),
316
- ],
317
- }))
318
-
319
- const result = database.searchBadges({ query: { str: 'oo' } })
320
- expect(result.totalItems).toBe(1)
268
+ const database = new CohContentDatabase(
269
+ bundleDataFixture.create({
270
+ badges: [
271
+ badgeDataFixture.create({ key: 'foo', name: [{ value: 'Foo' }] }),
272
+ badgeDataFixture.create({ key: 'bar', name: [{ value: 'Bar' }] }),
273
+ ],
274
+ }),
275
+ )
276
+
277
+ const result = database.searchBadges({ query: { str: 'oo', fields: ['name'] } })
278
+ expect(result.matchedItemCount).toBe(1)
279
+ expect(result.totalItemCount).toBe(2)
321
280
  expect(result.items.map(x => x.key)).toStrictEqual(['foo'])
322
281
  })
323
282
  })
@@ -62,7 +62,8 @@ describe(Contact.name, () => {
62
62
  describe('levelRange', () => {
63
63
  test(`should be set from the data`, () => {
64
64
  const contact = new Contact(contactDataFixture.create({ levelRange: [1, 2] }))
65
- expect(contact.levelRange).toStrictEqual([1, 2])
65
+ expect(contact?.levelRange?.min).toEqual(1)
66
+ expect(contact?.levelRange?.max).toEqual(2)
66
67
  })
67
68
 
68
69
  test(`should be optional`, () => {
@@ -0,0 +1,47 @@
1
+ import { LevelRange } from '../../main'
2
+
3
+ describe(LevelRange.name, () => {
4
+ describe('Constructor', () => {
5
+ test('should accept a full array (5-10)', () => {
6
+ const range = new LevelRange([5, 10])
7
+ expect(range).toBeDefined()
8
+ expect(range.min).toEqual(5)
9
+ expect(range.max).toEqual(10)
10
+ })
11
+
12
+ test('should accept a partial array (15+)', () => {
13
+ const range = new LevelRange([15])
14
+ expect(range).toBeDefined()
15
+ expect(range.min).toEqual(15)
16
+ expect(range.max).toBeUndefined()
17
+ })
18
+
19
+ test('should not coalesce a explicit max of 50 (20-50)', () => {
20
+ const range = new LevelRange([20, 50])
21
+ expect(range).toBeDefined()
22
+ expect(range.min).toEqual(20)
23
+ expect(range.max).toEqual(50)
24
+ })
25
+
26
+ test('should accept a single-level range (1-1)', () => {
27
+ const range = new LevelRange([1, 1])
28
+ expect(range).toBeDefined()
29
+ expect(range.min).toEqual(1)
30
+ expect(range.max).toEqual(1)
31
+ })
32
+
33
+ test('should accept a zero value (0-0)', () => {
34
+ const range = new LevelRange([0, 0])
35
+ expect(range).toBeDefined()
36
+ expect(range.min).toEqual(0)
37
+ expect(range.max).toEqual(0)
38
+ })
39
+
40
+ test('should accept a number (5+)', () => {
41
+ const range = new LevelRange(5)
42
+ expect(range).toBeDefined()
43
+ expect(range.min).toEqual(5)
44
+ expect(range.max).toBeUndefined()
45
+ })
46
+ })
47
+ })
@@ -56,8 +56,9 @@ describe(Mission.name, () => {
56
56
 
57
57
  describe('levelRange', () => {
58
58
  test(`should be set from the data`, () => {
59
- const mission = new Mission(missionDataFixture.create({ levelRange: [1, 2] }))
60
- expect(mission.levelRange).toStrictEqual([1, 2])
59
+ const mission = new Mission(missionDataFixture.create({ levelRange: 25 }))
60
+ expect(mission?.levelRange?.min).toEqual(25)
61
+ expect(mission?.levelRange?.max).toBeUndefined()
61
62
  })
62
63
 
63
64
  test(`should be optional`, () => {
@@ -105,13 +106,14 @@ describe(Mission.name, () => {
105
106
 
106
107
  describe('levelRange', () => {
107
108
  test(`should be set from the data`, () => {
108
- const mission = new Mission(missionDataFixture.create({ flashback: { levelRange: [1, 2] } }))
109
- expect(mission.flashback?.levelRange).toStrictEqual([1, 2])
109
+ const mission = new Mission(missionDataFixture.create({ flashback: { levelRange: [1, 20] } }))
110
+ expect(mission.flashback?.levelRange?.min).toEqual(1)
111
+ expect(mission.flashback?.levelRange?.max).toEqual(20)
110
112
  })
111
113
 
112
- test(`should default to the mission value`, () => {
114
+ test(`should *not* default to the mission value due to Ouro level grouping`, () => {
113
115
  const mission = new Mission(missionDataFixture.create({ levelRange: [1, 2], flashback: missionFlashbackDataFixture.omit('levelRange').create() }))
114
- expect(mission.flashback?.levelRange).toStrictEqual([1, 2])
116
+ expect(mission.flashback?.levelRange).toBeUndefined()
115
117
  })
116
118
 
117
119
  test(`should be optional`, () => {
@@ -29,7 +29,7 @@ describe(MoralityList.name, () => {
29
29
  expect(new MoralityList().items).toStrictEqual(['hero', 'vigilante', 'villain', 'rogue', 'resistance', 'loyalist'])
30
30
  })
31
31
 
32
- test('should treat empty as no values', () => {
32
+ test('should treat explicit empty as no values', () => {
33
33
  expect(new MoralityList([]).items).toStrictEqual([])
34
34
  })
35
35
  })
@@ -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
+ })