coh-content-db 2.0.0-rc.6 → 2.0.0-rc.8

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