coh-content-db 2.0.0-rc.1 → 2.0.0-rc.11

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 (100) hide show
  1. package/.editorconfig +10 -11
  2. package/.github/workflows/build.yml +4 -2
  3. package/.github/workflows/pull-request.yml +1 -1
  4. package/.github/workflows/release.yml +2 -2
  5. package/CHANGELOG.md +43 -0
  6. package/README.md +52 -24
  7. package/dist/coh-content-db.d.ts +678 -279
  8. package/dist/coh-content-db.js +828 -371
  9. package/dist/coh-content-db.js.map +1 -1
  10. package/dist/coh-content-db.mjs +803 -362
  11. package/dist/coh-content-db.mjs.map +1 -1
  12. package/eslint.config.mjs +1 -0
  13. package/package.json +1 -1
  14. package/src/main/api/alignment.ts +18 -2
  15. package/src/main/api/alternate-data.ts +2 -2
  16. package/src/main/api/badge-data.ts +20 -48
  17. package/src/main/api/badge-requirement-data.ts +64 -0
  18. package/src/main/api/badge-requirement-type.ts +32 -0
  19. package/src/main/api/badge-type.ts +15 -15
  20. package/src/main/api/bundle-data.ts +47 -0
  21. package/src/main/api/bundle-header-data.ts +37 -0
  22. package/src/main/api/contact-data.ts +48 -0
  23. package/src/main/api/enhancement-category.ts +26 -26
  24. package/src/main/api/location-data.ts +28 -0
  25. package/src/main/api/markdown-string.ts +4 -0
  26. package/src/main/api/mission-data.ts +83 -0
  27. package/src/main/api/mission-type.ts +2 -0
  28. package/src/main/api/morality.ts +31 -0
  29. package/src/main/api/sex.ts +8 -1
  30. package/src/main/api/zone-data.ts +20 -0
  31. package/src/main/db/abstract-index.ts +37 -0
  32. package/src/main/db/alignment-list.ts +54 -0
  33. package/src/main/db/alternates.ts +28 -42
  34. package/src/main/db/badge-index.ts +60 -0
  35. package/src/main/db/badge-requirement.ts +81 -0
  36. package/src/main/db/badge-search-options.ts +47 -0
  37. package/src/main/db/badge.ts +76 -71
  38. package/src/main/db/bundle-header.ts +44 -0
  39. package/src/main/db/coh-content-database.ts +123 -14
  40. package/src/main/db/contact.ts +62 -0
  41. package/src/main/db/location.ts +30 -0
  42. package/src/main/db/mission.ts +107 -0
  43. package/src/main/db/morality-list.ts +99 -0
  44. package/src/main/db/paged.ts +7 -0
  45. package/src/main/db/zone.ts +28 -0
  46. package/src/main/index.ts +23 -15
  47. package/src/main/util.ts +108 -7
  48. package/src/test/api/alignment.test.ts +38 -4
  49. package/src/test/api/badge-data.fixture.ts +1 -15
  50. package/src/test/api/badge-data.test.ts +4 -4
  51. package/src/test/api/badge-requirement-data.fixture.ts +7 -0
  52. package/src/test/api/badge-requirement-type.test.ts +31 -0
  53. package/src/test/api/badge-type.test.ts +5 -5
  54. package/src/test/api/bundle-data.fixture.ts +6 -0
  55. package/src/test/api/bundle-header-data.fixture.ts +6 -0
  56. package/src/test/api/contact-data.fixture.ts +7 -0
  57. package/src/test/api/enhancement-category.test.ts +5 -5
  58. package/src/test/api/mission-data.fixture.ts +12 -0
  59. package/src/test/api/sex.test.ts +33 -1
  60. package/src/test/api/zone-data.fixture.ts +8 -0
  61. package/src/test/db/abstract-index.test.ts +55 -0
  62. package/src/test/db/alignment-list.test.ts +200 -0
  63. package/src/test/db/alternates.test.ts +82 -117
  64. package/src/test/db/badge-index.test.ts +547 -0
  65. package/src/test/db/badge-requirement.test.ts +145 -0
  66. package/src/test/db/badge.test.ts +322 -14
  67. package/src/test/db/bundle-header.test.ts +76 -0
  68. package/src/test/db/coh-content-database.test.ts +264 -24
  69. package/src/test/db/contact.test.ts +97 -0
  70. package/src/test/db/location.test.ts +51 -0
  71. package/src/test/db/mission.test.ts +171 -0
  72. package/src/test/db/morality-list.test.ts +457 -0
  73. package/src/test/db/zone.test.ts +36 -0
  74. package/src/test/integration.test.ts +16 -0
  75. package/src/test/util.test.ts +144 -18
  76. package/src/main/api/badge-partial-data.ts +0 -65
  77. package/src/main/api/badge-partial-type.ts +0 -8
  78. package/src/main/api/change.ts +0 -14
  79. package/src/main/api/game-map-data.ts +0 -26
  80. package/src/main/api/plaque-type.ts +0 -6
  81. package/src/main/api/server-group-data.ts +0 -65
  82. package/src/main/api/vidiot-map-data.ts +0 -18
  83. package/src/main/api/vidiot-map-point-of-interest-data.ts +0 -30
  84. package/src/main/changelog.ts +0 -20
  85. package/src/main/db/badge-partial.ts +0 -35
  86. package/src/main/db/game-map.ts +0 -33
  87. package/src/main/db/server-group.ts +0 -112
  88. package/src/main/db/vidiot-map-point-of-interest.ts +0 -40
  89. package/src/main/db/vidiot-map.ts +0 -25
  90. package/src/test/api/badge-partial-data.fixture.ts +0 -17
  91. package/src/test/api/badge-partial-type.test.ts +0 -31
  92. package/src/test/api/game-map-data.fixture.ts +0 -10
  93. package/src/test/api/plaque-type.test.ts +0 -31
  94. package/src/test/api/server-group-data.fixture.ts +0 -23
  95. package/src/test/api/server-group-data.test.ts +0 -15
  96. package/src/test/api/vidiot-map-point-of-interest.fixture.ts +0 -10
  97. package/src/test/api/vidiot-map.fixture.ts +0 -9
  98. package/src/test/changelog.test.ts +0 -36
  99. package/src/test/db/server-group.test.ts +0 -124
  100. package/src/test/index.test.ts +0 -10
@@ -1,42 +1,282 @@
1
1
  import { CohContentDatabase } from '../../main'
2
- import { serverGroupDataFixture } from '../api/server-group-data.fixture'
2
+ import { archetypeDataFixture } from '../api/archetype-data.fixture'
3
+ import { badgeDataFixture } from '../api/badge-data.fixture'
4
+ import { zoneDataFixture } from '../api/zone-data.fixture'
5
+ import { contactDataFixture } from '../api/contact-data.fixture'
6
+ import { missionDataFixture } from '../api/mission-data.fixture'
7
+ import { bundleDataFixture } from '../api/bundle-data.fixture'
3
8
 
4
9
  describe(CohContentDatabase.name, () => {
5
- test('should be instantiable', () => {
6
- expect(new CohContentDatabase()).not.toBeNull()
10
+ describe('Constructor', () => {
11
+ test('should load a basic bundle', () => {
12
+ new CohContentDatabase(bundleDataFixture.create())
13
+ })
14
+ })
15
+
16
+ describe('header', () => {
17
+ test(`should accept an undefined field`, () => {
18
+ const database = new CohContentDatabase(
19
+ bundleDataFixture.omit('header').create(),
20
+ )
21
+ expect(database.header).toBeDefined()
22
+ expect(database.header?.name).toBeUndefined()
23
+ })
24
+
25
+ test(`should load values from bundle`, () => {
26
+ const database = new CohContentDatabase(
27
+ bundleDataFixture.create(
28
+ { header: { name: 'Homecoming' } },
29
+ ),
30
+ )
31
+
32
+ expect(database.header?.name).toBe('Homecoming')
33
+ })
34
+ })
35
+
36
+ describe('servers', () => {
37
+ test(`should accept an undefined field`, () => {
38
+ const database = new CohContentDatabase(
39
+ bundleDataFixture.omit('servers').create(),
40
+ )
41
+ expect(database.servers).toHaveLength(0)
42
+ })
43
+
44
+ test(`should load values from bundle`, () => {
45
+ const database = new CohContentDatabase(
46
+ bundleDataFixture
47
+ .create({ servers: ['Foo', 'Bar'] }),
48
+ )
49
+ expect(database.servers).toStrictEqual(['Foo', 'Bar'])
50
+ })
51
+ })
52
+
53
+ describe('archetypes', () => {
54
+ test(`should accept an undefined field`, () => {
55
+ const database = new CohContentDatabase(bundleDataFixture
56
+ .omit('archetypes')
57
+ .create())
58
+ expect(database.archetypes).toHaveLength(0)
59
+ })
60
+
61
+ test(`should load data from bundle`, () => {
62
+ const database = new CohContentDatabase(
63
+ bundleDataFixture
64
+ .create({ archetypes: [archetypeDataFixture.create({ key: 'foo' })] }),
65
+ )
66
+ expect(database.getArchetype('foo')).not.toBeUndefined()
67
+ })
68
+ })
69
+
70
+ describe('badges', () => {
71
+ test(`should accept an undefined field`, () => {
72
+ const database = new CohContentDatabase(
73
+ bundleDataFixture.omit('badges').create(),
74
+ )
75
+ expect(database.badges).toHaveLength(0)
76
+ })
77
+
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()
84
+ })
85
+ })
86
+
87
+ describe('zones', () => {
88
+ test(`should accept an undefined field`, () => {
89
+ const database = new CohContentDatabase(
90
+ bundleDataFixture.omit('zones').create(),
91
+ )
92
+ expect(database.zones).toHaveLength(0)
93
+ })
94
+
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()
101
+ })
7
102
  })
8
103
 
9
- describe(CohContentDatabase.prototype.loadServerGroupData.name, () => {
10
- test('should load an empty server group', () => {
11
- const database = new CohContentDatabase()
12
- database.loadServerGroupData(serverGroupDataFixture.create())
104
+ describe('contacts', () => {
105
+ test(`should accept an undefined field`, () => {
106
+ const database = new CohContentDatabase(
107
+ bundleDataFixture.omit('contacts').create(),
108
+ )
109
+ expect(database.contacts).toHaveLength(0)
110
+ })
111
+
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()
13
118
  })
14
119
  })
15
120
 
16
- describe(CohContentDatabase.prototype.listServerGroups.name, () => {
17
- test('should load two server groups', () => {
18
- const database = new CohContentDatabase()
19
- database.loadServerGroupData(serverGroupDataFixture.create({ key: 'sg1' }))
20
- database.loadServerGroupData(serverGroupDataFixture.create({ key: 'sg2' }))
121
+ describe('missions', () => {
122
+ test(`should accept an undefined field`, () => {
123
+ const database = new CohContentDatabase(
124
+ bundleDataFixture.omit('missions').create(),
125
+ )
126
+ expect(database.missions).toHaveLength(0)
127
+ })
21
128
 
22
- const sgs = database.listServerGroups()
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
+ })
136
+ })
23
137
 
24
- expect(sgs).toHaveLength(2)
138
+ describe('getArchetype', () => {
139
+ test(`should retrieve archetype from the index`, () => {
140
+ const database = new CohContentDatabase(
141
+ bundleDataFixture.create({
142
+ archetypes: [archetypeDataFixture.create({ key: 'foo' })],
143
+ }),
144
+ )
145
+ expect(database.getArchetype('foo')).not.toBeUndefined()
146
+ })
147
+
148
+ test(`should return undefined for unknown archetype`, () => {
149
+ const database = new CohContentDatabase(
150
+ bundleDataFixture.create({ archetypes: [] }),
151
+ )
152
+ expect(database.getArchetype('foo')).toBeUndefined()
153
+ })
154
+
155
+ test(`should return undefined for undefined key`, () => {
156
+ const database = new CohContentDatabase(
157
+ bundleDataFixture.create({ archetypes: [] }),
158
+ )
159
+ const key = undefined
160
+ expect(database.getArchetype(key)).toBeUndefined()
161
+ })
162
+ })
163
+
164
+ describe('getZone', () => {
165
+ test(`should retrieve zone from the index`, () => {
166
+ const database = new CohContentDatabase(
167
+ bundleDataFixture.create({
168
+ zones: [zoneDataFixture.create({ key: 'foo' })],
169
+ }),
170
+ )
171
+ expect(database.getZone('foo')).not.toBeUndefined()
172
+ })
173
+
174
+ test(`should return undefined for unknown zone`, () => {
175
+ const database = new CohContentDatabase(bundleDataFixture.create({ zones: [] }))
176
+ expect(database.getZone('foo')).toBeUndefined()
177
+ })
178
+
179
+ test(`should return undefined for undefined key`, () => {
180
+ const database = new CohContentDatabase(
181
+ bundleDataFixture.create({ zones: [] }),
182
+ )
183
+ const key = undefined
184
+ expect(database.getZone(key)).toBeUndefined()
185
+ })
186
+ })
187
+
188
+ describe('getContact', () => {
189
+ test(`should retrieve contact from the index`, () => {
190
+ const database = new CohContentDatabase(
191
+ bundleDataFixture.create({
192
+ contacts: [contactDataFixture.create({ key: 'foo' })],
193
+ }),
194
+ )
195
+ expect(database.getContact('foo')).not.toBeUndefined()
196
+ })
197
+
198
+ test(`should return undefined for unknown contact`, () => {
199
+ const database = new CohContentDatabase(
200
+ bundleDataFixture.create({ contacts: [] }),
201
+ )
202
+ expect(database.getContact('foo')).toBeUndefined()
203
+ })
204
+
205
+ test(`should return undefined for undefined key`, () => {
206
+ const database = new CohContentDatabase(
207
+ bundleDataFixture.create({ contacts: [] }),
208
+ )
209
+ const key = undefined
210
+ expect(database.getContact(key)).toBeUndefined()
211
+ })
212
+ })
213
+
214
+ describe('getMission', () => {
215
+ test(`should retrieve mission from the index`, () => {
216
+ const database = new CohContentDatabase(
217
+ bundleDataFixture.create({
218
+ missions: [missionDataFixture.create({ key: 'foo' })],
219
+ }),
220
+ )
221
+ expect(database.getMission('foo')).not.toBeUndefined()
222
+ })
223
+
224
+ test(`should return undefined for unknown mission`, () => {
225
+ const database = new CohContentDatabase(
226
+ bundleDataFixture.create({ missions: [] }),
227
+ )
228
+ expect(database.getMission('foo')).toBeUndefined()
229
+ })
230
+
231
+ test(`should return undefined for undefined key`, () => {
232
+ const database = new CohContentDatabase(
233
+ bundleDataFixture.create({ missions: [] }),
234
+ )
235
+ const key = undefined
236
+ expect(database.getMission(key)).toBeUndefined()
237
+ })
238
+ })
239
+
240
+ describe('getBadge', () => {
241
+ test(`should retrieve badge from the index`, () => {
242
+ const database = new CohContentDatabase(
243
+ bundleDataFixture.create({
244
+ badges: [badgeDataFixture.create({ key: 'foo' })],
245
+ }),
246
+ )
247
+ expect(database.getBadge('foo')).not.toBeUndefined()
248
+ })
249
+
250
+ test(`should return undefined for unknown badge`, () => {
251
+ const database = new CohContentDatabase(
252
+ bundleDataFixture.create({ badges: [] }),
253
+ )
254
+ expect(database.getBadge('foo')).toBeUndefined()
255
+ })
25
256
 
26
- for (const entry of sgs) {
27
- expect(['sg1', 'sg2']).toContain(entry.key)
28
- }
257
+ test(`should return undefined for undefined key`, () => {
258
+ const database = new CohContentDatabase(
259
+ bundleDataFixture.create({ badges: [] }),
260
+ )
261
+ const key = undefined
262
+ expect(database.getBadge(key)).toBeUndefined()
29
263
  })
30
264
  })
31
265
 
32
- describe(CohContentDatabase.prototype.getServerGroup.name, () => {
33
- test('should load a server group by key', () => {
34
- const database = new CohContentDatabase()
35
- database.loadServerGroupData(serverGroupDataFixture.create({ key: 'sg1' }))
266
+ describe('searchBadges', () => {
267
+ test(`should search the badge list`, () => {
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
+ )
36
276
 
37
- const sg = database.getServerGroup('sg1')
38
- expect(sg).not.toBeNull()
39
- expect(sg?.key).toEqual('sg1')
277
+ const result = database.searchBadges({ query: { str: 'oo', fields: ['name'] } })
278
+ expect(result.totalItems).toBe(1)
279
+ expect(result.items.map(x => x.key)).toStrictEqual(['foo'])
40
280
  })
41
281
  })
42
282
  })
@@ -0,0 +1,97 @@
1
+ import { Contact } from '../../main'
2
+ import { contactDataFixture } from '../api/contact-data.fixture'
3
+
4
+ describe(Contact.name, () => {
5
+ describe('Constructor', () => {
6
+ test(`should accept the test fixture`, () => {
7
+ new Contact(contactDataFixture.create())
8
+ })
9
+ })
10
+
11
+ describe('key', () => {
12
+ test(`should be set from the data`, () => {
13
+ const contact = new Contact(contactDataFixture.create({ key: 'foo' }))
14
+ expect(contact.key).toEqual('foo')
15
+ })
16
+ })
17
+
18
+ describe('name', () => {
19
+ test(`should be set from the data`, () => {
20
+ const contact = new Contact(contactDataFixture.create({ name: 'foo' }))
21
+ expect(contact.name).toEqual('foo')
22
+ })
23
+ })
24
+
25
+ describe('title', () => {
26
+ test(`should be set from the data`, () => {
27
+ const contact = new Contact(contactDataFixture.create({ title: 'foo' }))
28
+ expect(contact.title).toEqual('foo')
29
+ })
30
+
31
+ test(`should be optional`, () => {
32
+ const contact = new Contact(contactDataFixture.omit('title').create())
33
+ expect(contact.title).toBeUndefined()
34
+ })
35
+ })
36
+
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()
42
+ })
43
+
44
+ test(`should be optional`, () => {
45
+ const contact = new Contact(contactDataFixture.omit('morality').create())
46
+ expect(contact.morality?.all).toBeTruthy()
47
+ })
48
+ })
49
+
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] })
54
+ })
55
+
56
+ test(`should be optional`, () => {
57
+ const contact = new Contact(contactDataFixture.omit('location').create())
58
+ expect(contact.location).toBeUndefined()
59
+ })
60
+ })
61
+
62
+ describe('levelRange', () => {
63
+ test(`should be set from the data`, () => {
64
+ const contact = new Contact(contactDataFixture.create({ levelRange: [1, 2] }))
65
+ expect(contact.levelRange).toStrictEqual([1, 2])
66
+ })
67
+
68
+ test(`should be optional`, () => {
69
+ const contact = new Contact(contactDataFixture.omit('levelRange').create())
70
+ expect(contact.levelRange).toBeUndefined()
71
+ })
72
+ })
73
+
74
+ describe('notes', () => {
75
+ test(`should be set from the data`, () => {
76
+ const contact = new Contact(contactDataFixture.create({ notes: 'foo' }))
77
+ expect(contact.notes).toEqual('foo')
78
+ })
79
+
80
+ test(`should be optional`, () => {
81
+ const contact = new Contact(contactDataFixture.omit('notes').create())
82
+ expect(contact.notes).toBeUndefined()
83
+ })
84
+ })
85
+
86
+ describe('links', () => {
87
+ test(`should be set from the data`, () => {
88
+ const contact = new Contact(contactDataFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
89
+ expect(contact.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
90
+ })
91
+
92
+ test(`should be optional`, () => {
93
+ const contact = new Contact(contactDataFixture.omit('links').create())
94
+ expect(contact.links).toHaveLength(0)
95
+ })
96
+ })
97
+ })
@@ -0,0 +1,51 @@
1
+ import { Location } from '../../main'
2
+
3
+ describe(Location.name, () => {
4
+ describe('zoneKey', () => {
5
+ test(`should be set from the data`, () => {
6
+ const location = new Location({ zoneKey: 'foo' })
7
+ expect(location.zoneKey).toEqual('foo')
8
+ })
9
+
10
+ test(`should be optional`, () => {
11
+ const location = new Location({})
12
+ expect(location.zoneKey).toBeUndefined()
13
+ })
14
+ })
15
+
16
+ describe('coords', () => {
17
+ test(`should be set from the data`, () => {
18
+ const location = new Location({ coords: [1, 2, 3] })
19
+ expect(location.coords).toStrictEqual([1, 2, 3])
20
+ })
21
+
22
+ test(`should be optional`, () => {
23
+ const location = new Location({})
24
+ expect(location.coords).toBeUndefined()
25
+ })
26
+ })
27
+
28
+ describe('icon', () => {
29
+ test(`should be set from the data`, () => {
30
+ const location = new Location({ icon: 'plaque' })
31
+ expect(location.icon).toBe('plaque')
32
+ })
33
+
34
+ test(`should be optional`, () => {
35
+ const location = new Location({})
36
+ expect(location.icon).toBeUndefined()
37
+ })
38
+ })
39
+
40
+ describe('iconText', () => {
41
+ test(`should be set from the data`, () => {
42
+ const location = new Location({ iconText: '1' })
43
+ expect(location.iconText).toBe('1')
44
+ })
45
+
46
+ test(`should be optional`, () => {
47
+ const location = new Location({})
48
+ expect(location.iconText).toBeUndefined()
49
+ })
50
+ })
51
+ })
@@ -0,0 +1,171 @@
1
+ import { Mission } from '../../main'
2
+ import { missionDataFixture, missionFlashbackDataFixture } from '../api/mission-data.fixture'
3
+
4
+ describe(Mission.name, () => {
5
+ describe('Constructor', () => {
6
+ test(`should accept the test fixture`, () => {
7
+ new Mission(missionDataFixture.create())
8
+ })
9
+ })
10
+
11
+ describe('key', () => {
12
+ test(`should be set from the data`, () => {
13
+ const mission = new Mission(missionDataFixture.create({ key: 'foo' }))
14
+ expect(mission.key).toEqual('foo')
15
+ })
16
+ })
17
+
18
+ describe('name', () => {
19
+ test(`should be set from the data`, () => {
20
+ const mission = new Mission(missionDataFixture.create({ name: 'Foo' }))
21
+ expect(mission.name).toEqual('Foo')
22
+ })
23
+ })
24
+
25
+ describe('type', () => {
26
+ test(`should be set from the data`, () => {
27
+ const mission = new Mission(missionDataFixture.create({ type: 'story-arc' }))
28
+ expect(mission.type).toEqual('story-arc')
29
+ })
30
+ })
31
+
32
+ describe('morality', () => {
33
+ test(`should be set from the data`, () => {
34
+ const mission = new Mission(missionDataFixture.create({ morality: ['hero'] }))
35
+ expect(mission.morality?.hero).toBeTruthy()
36
+ expect(mission.morality?.vigilante).toBeFalsy()
37
+ })
38
+
39
+ test(`should be optional`, () => {
40
+ const mission = new Mission(missionDataFixture.omit('morality').create())
41
+ expect(mission.morality?.all).toBeTruthy()
42
+ })
43
+ })
44
+
45
+ describe('contactKeys', () => {
46
+ test(`should be set from the data`, () => {
47
+ const mission = new Mission(missionDataFixture.create({ contactKeys: 'foo' }))
48
+ expect(mission.contactKeys).toStrictEqual(['foo'])
49
+ })
50
+
51
+ test(`should be optional`, () => {
52
+ const mission = new Mission(missionDataFixture.omit('contactKeys').create())
53
+ expect(mission.contactKeys).toBeUndefined()
54
+ })
55
+ })
56
+
57
+ describe('levelRange', () => {
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])
61
+ })
62
+
63
+ test(`should be optional`, () => {
64
+ const mission = new Mission(missionDataFixture.omit('levelRange').create())
65
+ expect(mission.levelRange).toBeUndefined()
66
+ })
67
+ })
68
+
69
+ describe('notes', () => {
70
+ test(`should be set from the data`, () => {
71
+ const mission = new Mission(missionDataFixture.create({ notes: 'foo' }))
72
+ expect(mission.notes).toBe('foo')
73
+ })
74
+
75
+ test(`should be optional`, () => {
76
+ const mission = new Mission(missionDataFixture.omit('notes').create())
77
+ expect(mission.notes).toBeUndefined()
78
+ })
79
+ })
80
+
81
+ describe('links', () => {
82
+ test('should be set from the data', () => {
83
+ const badge = new Mission(missionDataFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
84
+ expect(badge.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
85
+ })
86
+
87
+ test('should be optional', () => {
88
+ const badge = new Mission(missionDataFixture.omit('links').create())
89
+ expect(badge.links).toHaveLength(0)
90
+ })
91
+ })
92
+
93
+ describe('flashback', () => {
94
+ test('should be undefined if omitted', () => {
95
+ const badge = new Mission(missionDataFixture.omit('flashback').create())
96
+ expect(badge.flashback).toBeFalsy()
97
+ })
98
+
99
+ describe('id', () => {
100
+ test(`should be set from the data`, () => {
101
+ const mission = new Mission(missionDataFixture.create({ flashback: { id: 'foo' } }))
102
+ expect(mission.flashback?.id).toBe('foo')
103
+ })
104
+ })
105
+
106
+ describe('levelRange', () => {
107
+ 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])
110
+ })
111
+
112
+ test(`should default to the mission value`, () => {
113
+ const mission = new Mission(missionDataFixture.create({ levelRange: [1, 2], flashback: missionFlashbackDataFixture.omit('levelRange').create() }))
114
+ expect(mission.flashback?.levelRange).toStrictEqual([1, 2])
115
+ })
116
+
117
+ test(`should be optional`, () => {
118
+ const mission = new Mission(missionDataFixture.omit('levelRange').create({ flashback: missionFlashbackDataFixture.omit('levelRange').create() }))
119
+ expect(mission.flashback?.levelRange).toBeUndefined()
120
+ })
121
+ })
122
+
123
+ describe('name', () => {
124
+ test(`should be set from the data`, () => {
125
+ const mission = new Mission(missionDataFixture.create({ flashback: { name: 'Foo' } }))
126
+ expect(mission.flashback?.name).toStrictEqual('Foo')
127
+ })
128
+
129
+ test(`should default to the mission value`, () => {
130
+ const mission = new Mission(missionDataFixture.create({ name: 'Foo', flashback: missionFlashbackDataFixture.omit('name').create() }))
131
+ expect(mission.flashback?.name).toStrictEqual('Foo')
132
+ })
133
+
134
+ test(`should be optional`, () => {
135
+ const mission = new Mission(missionDataFixture.omit('name').create({ flashback: missionFlashbackDataFixture.omit('name').create() }))
136
+ expect(mission.flashback?.name).toBeUndefined()
137
+ })
138
+ })
139
+
140
+ describe('morality', () => {
141
+ test(`should be set from the data`, () => {
142
+ const mission = new Mission(missionDataFixture.create({ flashback: { morality: ['hero'] } }))
143
+ expect(mission.flashback?.morality?.hero).toBeTruthy()
144
+ expect(mission.flashback?.morality?.vigilante).toBeFalsy()
145
+ })
146
+
147
+ test(`should default to the mission value`, () => {
148
+ const mission = new Mission(missionDataFixture.create({ morality: ['hero'], flashback: missionFlashbackDataFixture.omit('morality').create() }))
149
+ expect(mission.flashback?.morality?.hero).toBeTruthy()
150
+ expect(mission.flashback?.morality?.vigilante).toBeFalsy()
151
+ })
152
+
153
+ test(`should be optional`, () => {
154
+ const mission = new Mission(missionDataFixture.omit('morality').create({ flashback: missionFlashbackDataFixture.omit('morality').create() }))
155
+ expect(mission.morality?.all).toBeTruthy()
156
+ })
157
+ })
158
+
159
+ describe('notes', () => {
160
+ test(`should be set from the data`, () => {
161
+ const mission = new Mission(missionDataFixture.create({ flashback: { notes: 'foo' } }))
162
+ expect(mission.flashback?.notes).toStrictEqual('foo')
163
+ })
164
+
165
+ test(`should be optional`, () => {
166
+ const mission = new Mission(missionDataFixture.create({ flashback: missionFlashbackDataFixture.omit('notes').create() }))
167
+ expect(mission.flashback?.notes).toBeUndefined()
168
+ })
169
+ })
170
+ })
171
+ })