coh-content-db 2.0.0-rc.1 → 2.0.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +10 -11
- package/.github/workflows/build.yml +1 -1
- package/.github/workflows/pull-request.yml +1 -1
- package/.github/workflows/release.yml +2 -2
- package/CHANGELOG.md +42 -0
- package/README.md +52 -24
- package/dist/coh-content-db.d.ts +683 -279
- package/dist/coh-content-db.js +834 -377
- package/dist/coh-content-db.js.map +1 -1
- package/dist/coh-content-db.mjs +809 -368
- 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/alternate-data.ts +2 -2
- package/src/main/api/badge-data.ts +20 -48
- package/src/main/api/badge-requirement-data.ts +64 -0
- package/src/main/api/badge-requirement-type.ts +32 -0
- package/src/main/api/badge-type.ts +15 -15
- package/src/main/api/bundle-data.ts +47 -0
- package/src/main/api/bundle-header-data.ts +37 -0
- package/src/main/api/contact-data.ts +48 -0
- package/src/main/api/enhancement-category.ts +26 -26
- package/src/main/api/location-data.ts +28 -0
- package/src/main/api/markdown-string.ts +4 -0
- package/src/main/api/mission-data.ts +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 +20 -0
- package/src/main/db/abstract-index.ts +37 -0
- package/src/main/db/alignment-list.ts +54 -0
- package/src/main/db/alternates.ts +28 -42
- package/src/main/db/badge-index.ts +57 -0
- package/src/main/db/badge-requirement.ts +81 -0
- package/src/main/db/badge-search-options.ts +51 -0
- package/src/main/db/badge.ts +77 -71
- package/src/main/db/bundle-header.ts +44 -0
- package/src/main/db/coh-content-database.ts +123 -14
- package/src/main/db/contact.ts +62 -0
- 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/paged.ts +7 -0
- package/src/main/db/zone.ts +28 -0
- package/src/main/index.ts +23 -15
- package/src/main/util.ts +108 -7
- package/src/test/api/alignment.test.ts +38 -4
- package/src/test/api/badge-data.fixture.ts +1 -15
- package/src/test/api/badge-data.test.ts +4 -4
- package/src/test/api/badge-requirement-data.fixture.ts +7 -0
- package/src/test/api/badge-requirement-type.test.ts +31 -0
- package/src/test/api/badge-type.test.ts +5 -5
- package/src/test/api/bundle-data.fixture.ts +6 -0
- package/src/test/api/bundle-header-data.fixture.ts +6 -0
- package/src/test/api/contact-data.fixture.ts +7 -0
- package/src/test/api/enhancement-category.test.ts +5 -5
- package/src/test/api/mission-data.fixture.ts +12 -0
- package/src/test/api/sex.test.ts +33 -1
- package/src/test/api/zone-data.fixture.ts +8 -0
- package/src/test/db/abstract-index.test.ts +55 -0
- package/src/test/db/alignment-list.test.ts +200 -0
- package/src/test/db/alternates.test.ts +82 -117
- package/src/test/db/badge-index.test.ts +519 -0
- package/src/test/db/badge-requirement.test.ts +145 -0
- package/src/test/db/badge.test.ts +310 -14
- package/src/test/db/bundle-header.test.ts +76 -0
- package/src/test/db/coh-content-database.test.ts +264 -24
- package/src/test/db/contact.test.ts +97 -0
- 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 +36 -0
- package/src/test/integration.test.ts +16 -0
- package/src/test/util.test.ts +144 -18
- package/src/main/api/badge-partial-data.ts +0 -65
- package/src/main/api/badge-partial-type.ts +0 -8
- package/src/main/api/change.ts +0 -14
- package/src/main/api/game-map-data.ts +0 -26
- package/src/main/api/plaque-type.ts +0 -6
- package/src/main/api/server-group-data.ts +0 -65
- package/src/main/api/vidiot-map-data.ts +0 -18
- package/src/main/api/vidiot-map-point-of-interest-data.ts +0 -30
- package/src/main/changelog.ts +0 -20
- package/src/main/db/badge-partial.ts +0 -35
- package/src/main/db/game-map.ts +0 -33
- package/src/main/db/server-group.ts +0 -112
- package/src/main/db/vidiot-map-point-of-interest.ts +0 -40
- package/src/main/db/vidiot-map.ts +0 -25
- package/src/test/api/badge-partial-data.fixture.ts +0 -17
- package/src/test/api/badge-partial-type.test.ts +0 -31
- package/src/test/api/game-map-data.fixture.ts +0 -10
- package/src/test/api/plaque-type.test.ts +0 -31
- package/src/test/api/server-group-data.fixture.ts +0 -23
- package/src/test/api/server-group-data.test.ts +0 -15
- package/src/test/api/vidiot-map-point-of-interest.fixture.ts +0 -10
- package/src/test/api/vidiot-map.fixture.ts +0 -9
- package/src/test/changelog.test.ts +0 -36
- package/src/test/db/server-group.test.ts +0 -124
- package/src/test/index.test.ts +0 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Badge } from '../../main'
|
|
1
|
+
import { Badge, compareByDefaultName, compareByZoneKey } from '../../main'
|
|
2
2
|
import { badgeDataFixture } from '../api/badge-data.fixture'
|
|
3
|
-
import {
|
|
3
|
+
import { badgeRequirementDataFixture } from '../api/badge-requirement-data.fixture'
|
|
4
4
|
|
|
5
5
|
describe(Badge.name, () => {
|
|
6
6
|
describe('Constructor', () => {
|
|
@@ -9,33 +9,329 @@ describe(Badge.name, () => {
|
|
|
9
9
|
})
|
|
10
10
|
})
|
|
11
11
|
|
|
12
|
-
describe('
|
|
12
|
+
describe('key', () => {
|
|
13
|
+
test('should be set from the data', () => {
|
|
14
|
+
const badge = new Badge(badgeDataFixture.create({ key: 'badge123' }))
|
|
15
|
+
expect(badge.key).toEqual('badge123')
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
describe('type', () => {
|
|
20
|
+
test('should be set from the data', () => {
|
|
21
|
+
const badge = new Badge(badgeDataFixture.create({ type: 'achievement' }))
|
|
22
|
+
expect(badge.type).toEqual('achievement')
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
describe('name', () => {
|
|
27
|
+
test('should be set from the data', () => {
|
|
28
|
+
const badge = new Badge(badgeDataFixture.create({ name: [{ value: 'foo' }] }))
|
|
29
|
+
expect(badge.name.default).toEqual({ value: 'foo' })
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
describe('morality', () => {
|
|
34
|
+
test('should be set from the data', () => {
|
|
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()
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
describe('badgeText', () => {
|
|
53
|
+
test('should be set from the data', () => {
|
|
54
|
+
const badge = new Badge(badgeDataFixture.create({ badgeText: [{ value: 'foo' }] }))
|
|
55
|
+
expect(badge.badgeText.default).toEqual({ value: 'foo' })
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
test('should be optional', () => {
|
|
59
|
+
const badge = new Badge(badgeDataFixture.omit('badgeText').create())
|
|
60
|
+
expect(badge.badgeText.default).toBeUndefined()
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
describe('acquisition', () => {
|
|
65
|
+
test('should be set from the data', () => {
|
|
66
|
+
const badge = new Badge(badgeDataFixture.create({ acquisition: 'Quest Reward' }))
|
|
67
|
+
expect(badge.acquisition).toEqual('Quest Reward')
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
test('should be optional', () => {
|
|
71
|
+
const badge = new Badge(badgeDataFixture.omit('acquisition').create())
|
|
72
|
+
expect(badge.acquisition).toBeUndefined()
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
describe('icon', () => {
|
|
77
|
+
test('should be set from the data', () => {
|
|
78
|
+
const badge = new Badge(badgeDataFixture.create({ icon: [{ value: 'foo' }] }))
|
|
79
|
+
expect(badge.icon.default).toEqual({ value: 'foo' })
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
test('should be optional', () => {
|
|
83
|
+
const badge = new Badge(badgeDataFixture.omit('icon').create())
|
|
84
|
+
expect(badge.icon.default).toBeUndefined()
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
describe('notes', () => {
|
|
89
|
+
test('should be set from the data', () => {
|
|
90
|
+
const badge = new Badge(badgeDataFixture.create({ notes: 'foo' }))
|
|
91
|
+
expect(badge.notes).toEqual('foo')
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('should be optional', () => {
|
|
95
|
+
const badge = new Badge(badgeDataFixture.omit('notes').create())
|
|
96
|
+
expect(badge.notes).toBeUndefined()
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
describe('links', () => {
|
|
101
|
+
test('should be set from the data', () => {
|
|
102
|
+
const badge = new Badge(badgeDataFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
|
|
103
|
+
expect(badge.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
test('should be optional', () => {
|
|
107
|
+
const badge = new Badge(badgeDataFixture.omit('links').create())
|
|
108
|
+
expect(badge.links).toHaveLength(0)
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
describe('effect', () => {
|
|
113
|
+
test('should be set from the data', () => {
|
|
114
|
+
const badge = new Badge(badgeDataFixture.create({ effect: 'foo' }))
|
|
115
|
+
expect(badge.effect).toEqual('foo')
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
test('should be optional', () => {
|
|
119
|
+
const badge = new Badge(badgeDataFixture.omit('effect').create())
|
|
120
|
+
expect(badge.effect).toBeUndefined()
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
describe('setTitle', () => {
|
|
125
|
+
test('should be set from the data', () => {
|
|
126
|
+
const badge = new Badge(badgeDataFixture.create({ setTitleId: [123, 456] }))
|
|
127
|
+
expect(badge.setTitleId).toStrictEqual([123, 456])
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
test('should treat the praetorian id as optional', () => {
|
|
131
|
+
const badge = new Badge(badgeDataFixture.create({ setTitleId: [123] }))
|
|
132
|
+
expect(badge.setTitleId).toStrictEqual([123])
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
test('should be optional', () => {
|
|
136
|
+
const badge = new Badge(badgeDataFixture.omit('setTitleId').create())
|
|
137
|
+
expect(badge.setTitleId).toBeUndefined()
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
describe('ignoreInTotals', () => {
|
|
142
|
+
test('should be set from the data', () => {
|
|
143
|
+
const badge = new Badge(badgeDataFixture.create({ ignoreInTotals: true }))
|
|
144
|
+
expect(badge.ignoreInTotals).toEqual(true)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
test('should default to false', () => {
|
|
148
|
+
const badge = new Badge(badgeDataFixture.omit('ignoreInTotals').create())
|
|
149
|
+
expect(badge.ignoreInTotals).toEqual(false)
|
|
150
|
+
})
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
describe('requirements', () => {
|
|
13
154
|
test(`should throw an error on duplicate key`, () => {
|
|
14
155
|
const data = badgeDataFixture.create({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
156
|
+
key: 'badge',
|
|
157
|
+
requirements: [
|
|
158
|
+
badgeRequirementDataFixture.create({ key: 'foo' }),
|
|
159
|
+
badgeRequirementDataFixture.create({ key: 'foo' }),
|
|
18
160
|
],
|
|
19
161
|
})
|
|
20
|
-
expect(() => new Badge(data)).toThrow('Duplicate badge
|
|
162
|
+
expect(() => new Badge(data)).toThrow('Duplicate badge requirement key [badge:foo]')
|
|
21
163
|
})
|
|
22
164
|
})
|
|
23
165
|
|
|
24
|
-
describe('
|
|
25
|
-
test(`should retrieve
|
|
166
|
+
describe('getRequirement', () => {
|
|
167
|
+
test(`should retrieve requirement from the index`, () => {
|
|
26
168
|
const data = badgeDataFixture.create({
|
|
27
|
-
|
|
169
|
+
requirements: [badgeRequirementDataFixture.create({ key: 'foo' })],
|
|
28
170
|
})
|
|
29
171
|
|
|
30
|
-
expect(new Badge(data).
|
|
172
|
+
expect(new Badge(data).getRequirement('foo')).not.toBeUndefined()
|
|
31
173
|
})
|
|
32
174
|
|
|
33
|
-
test(`should throw error for unknown
|
|
175
|
+
test(`should throw error for unknown requirement`, () => {
|
|
34
176
|
const data = badgeDataFixture.create({
|
|
35
|
-
|
|
177
|
+
requirements: [],
|
|
36
178
|
})
|
|
37
179
|
|
|
38
|
-
expect(() => new Badge(data).
|
|
180
|
+
expect(() => new Badge(data).getRequirement('foo')).toThrow('Unknown badge requirement key [foo]')
|
|
181
|
+
})
|
|
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])
|
|
39
335
|
})
|
|
40
336
|
})
|
|
41
337
|
})
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { BundleHeader } from '../../main'
|
|
2
|
+
import { bundleHeaderDataFixture } from '../api/bundle-header-data.fixture'
|
|
3
|
+
|
|
4
|
+
describe(BundleHeader.name, () => {
|
|
5
|
+
describe('name', () => {
|
|
6
|
+
test(`should be set from the data`, () => {
|
|
7
|
+
const header = new BundleHeader(bundleHeaderDataFixture.create({ name: 'foo' }))
|
|
8
|
+
expect(header.name).toEqual('foo')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test(`should be optional`, () => {
|
|
12
|
+
const header = new BundleHeader(bundleHeaderDataFixture.omit('name').create())
|
|
13
|
+
expect(header.name).toBeUndefined()
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
describe('description', () => {
|
|
18
|
+
test(`should be set from the data`, () => {
|
|
19
|
+
const header = new BundleHeader(bundleHeaderDataFixture.create({ description: 'foo' }))
|
|
20
|
+
expect(header.description).toEqual('foo')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test(`should be optional`, () => {
|
|
24
|
+
const header = new BundleHeader(bundleHeaderDataFixture.omit('description').create())
|
|
25
|
+
expect(header.description).toBeUndefined()
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
describe('repositoryUrl', () => {
|
|
30
|
+
test(`should be set from the data`, () => {
|
|
31
|
+
const header = new BundleHeader(bundleHeaderDataFixture.create({ repositoryUrl: 'foo' }))
|
|
32
|
+
expect(header.repositoryUrl).toEqual('foo')
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test(`should be optional`, () => {
|
|
36
|
+
const header = new BundleHeader(bundleHeaderDataFixture.omit('repositoryUrl').create())
|
|
37
|
+
expect(header.repositoryUrl).toBeUndefined()
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
describe('changelogUrl', () => {
|
|
42
|
+
test(`should be set from the data`, () => {
|
|
43
|
+
const header = new BundleHeader(bundleHeaderDataFixture.create({ changelogUrl: 'foo' }))
|
|
44
|
+
expect(header.changelogUrl).toEqual('foo')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test(`should be optional`, () => {
|
|
48
|
+
const header = new BundleHeader(bundleHeaderDataFixture.omit('changelogUrl').create())
|
|
49
|
+
expect(header.changelogUrl).toBeUndefined()
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
describe('links', () => {
|
|
54
|
+
test(`should be set from the data`, () => {
|
|
55
|
+
const header = new BundleHeader(bundleHeaderDataFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
|
|
56
|
+
expect(header.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test(`should be optional`, () => {
|
|
60
|
+
const header = new BundleHeader(bundleHeaderDataFixture.omit('links').create())
|
|
61
|
+
expect(header.links).toHaveLength(0)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
describe('version', () => {
|
|
66
|
+
test(`should be set from the data`, () => {
|
|
67
|
+
const header = new BundleHeader(bundleHeaderDataFixture.create({ version: 'foo' }))
|
|
68
|
+
expect(header.version).toEqual('foo')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test(`should be optional`, () => {
|
|
72
|
+
const header = new BundleHeader(bundleHeaderDataFixture.omit('version').create())
|
|
73
|
+
expect(header.version).toBeUndefined()
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
})
|