coh-content-db 2.0.0-rc.5 → 2.0.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/coh-content-db.d.ts +203 -156
- package/dist/coh-content-db.js +263 -197
- package/dist/coh-content-db.js.map +1 -1
- package/dist/coh-content-db.mjs +256 -191
- package/dist/coh-content-db.mjs.map +1 -1
- package/package.json +1 -1
- package/src/main/api/badge-data.ts +16 -9
- package/src/main/api/{badge-partial-data.ts → badge-requirement-data.ts} +24 -8
- package/src/main/api/badge-requirement-type.ts +11 -0
- package/src/main/api/contact-data.ts +46 -0
- package/src/main/api/content-bundle.ts +10 -4
- package/src/main/api/zone-data.ts +20 -0
- package/src/main/changelog.ts +5 -1
- package/src/main/db/badge-index.ts +17 -11
- package/src/main/db/{badge-partial.ts → badge-requirement.ts} +30 -11
- package/src/main/db/badge-search-options.ts +2 -2
- package/src/main/db/badge.ts +48 -36
- package/src/main/db/bundle-metadata.ts +3 -3
- package/src/main/db/coh-content-database.ts +51 -18
- package/src/main/db/contact.ts +59 -0
- package/src/main/db/zone.ts +28 -0
- package/src/main/index.ts +8 -10
- package/src/main/util.ts +44 -13
- package/src/test/api/badge-data.fixture.ts +9 -7
- package/src/test/api/badge-requirement-data.fixture.ts +17 -0
- package/src/test/api/badge-requirement-type.test.ts +31 -0
- package/src/test/api/contact-data.fixture.ts +13 -0
- package/src/test/api/content-bundle.fixture.ts +2 -2
- package/src/test/api/content-bundle.test.ts +1 -1
- package/src/test/api/zone-data.fixture.ts +8 -0
- package/src/test/db/badge-index.test.ts +73 -41
- package/src/test/db/badge-requirement.test.ts +180 -0
- package/src/test/db/badge.test.ts +190 -15
- package/src/test/db/coh-content-database.test.ts +110 -18
- package/src/test/db/contact.test.ts +96 -0
- package/src/test/db/zone.test.ts +36 -0
- package/src/test/index.test.ts +4 -2
- package/src/test/util.test.ts +59 -22
- package/src/main/api/badge-partial-type.ts +0 -8
- package/src/main/api/game-map-data.ts +0 -26
- 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/db/game-map.ts +0 -33
- package/src/main/db/vidiot-map-point-of-interest.ts +0 -39
- 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/vidiot-map-point-of-interest.fixture.ts +0 -10
- package/src/test/api/vidiot-map.fixture.ts +0 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Badge } 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,208 @@ describe(Badge.name, () => {
|
|
|
9
9
|
})
|
|
10
10
|
})
|
|
11
11
|
|
|
12
|
-
describe('
|
|
13
|
-
test(
|
|
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('alignment', () => {
|
|
34
|
+
test('should be set from the data', () => {
|
|
35
|
+
const badge = new Badge(badgeDataFixture.create({ alignment: ['H', 'V'] }))
|
|
36
|
+
expect(badge.alignment.hero).toBeTruthy()
|
|
37
|
+
expect(badge.alignment.villain).toBeTruthy()
|
|
38
|
+
expect(badge.alignment.praetorian).toBeFalsy()
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
describe('badgeText', () => {
|
|
43
|
+
test('should be set from the data', () => {
|
|
44
|
+
const badge = new Badge(badgeDataFixture.create({ badgeText: [{ value: 'foo' }] }))
|
|
45
|
+
expect(badge.badgeText.default).toEqual({ value: 'foo' })
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test('should be optional', () => {
|
|
49
|
+
const badge = new Badge(badgeDataFixture.omit('badgeText').create())
|
|
50
|
+
expect(badge.badgeText.default).toBeUndefined()
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
describe('acquisition', () => {
|
|
55
|
+
test('should be set from the data', () => {
|
|
56
|
+
const badge = new Badge(badgeDataFixture.create({ acquisition: 'Quest Reward' }))
|
|
57
|
+
expect(badge.acquisition).toEqual('Quest Reward')
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test('should be optional', () => {
|
|
61
|
+
const badge = new Badge(badgeDataFixture.omit('acquisition').create())
|
|
62
|
+
expect(badge.acquisition).toBeUndefined()
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
describe('icon', () => {
|
|
67
|
+
test('should be set from the data', () => {
|
|
68
|
+
const badge = new Badge(badgeDataFixture.create({ icon: [{ value: 'foo' }] }))
|
|
69
|
+
expect(badge.icon.default).toEqual({ value: 'foo' })
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
test('should be optional', () => {
|
|
73
|
+
const badge = new Badge(badgeDataFixture.omit('icon').create())
|
|
74
|
+
expect(badge.icon.default).toBeUndefined()
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
describe('notes', () => {
|
|
79
|
+
test('should be set from the data', () => {
|
|
80
|
+
const badge = new Badge(badgeDataFixture.create({ notes: 'foo' }))
|
|
81
|
+
expect(badge.notes).toEqual('foo')
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
test('should be optional', () => {
|
|
85
|
+
const badge = new Badge(badgeDataFixture.omit('notes').create())
|
|
86
|
+
expect(badge.notes).toBeUndefined()
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
describe('links', () => {
|
|
91
|
+
test('should be set from the data', () => {
|
|
92
|
+
const badge = new Badge(badgeDataFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
|
|
93
|
+
expect(badge.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
test('should be optional', () => {
|
|
97
|
+
const badge = new Badge(badgeDataFixture.omit('links').create())
|
|
98
|
+
expect(badge.links).toHaveLength(0)
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
describe('zoneKey', () => {
|
|
103
|
+
test('should be set from the data', () => {
|
|
104
|
+
const badge = new Badge(badgeDataFixture.create({ zoneKey: 'foo' }))
|
|
105
|
+
expect(badge.zoneKey).toEqual('foo')
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
test('should be optional', () => {
|
|
109
|
+
const badge = new Badge(badgeDataFixture.omit('zoneKey').create())
|
|
110
|
+
expect(badge.zoneKey).toBeUndefined()
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
describe('loc', () => {
|
|
115
|
+
test('should be set from the data', () => {
|
|
116
|
+
const badge = new Badge(badgeDataFixture.create({ loc: [1, 2, 3] }))
|
|
117
|
+
expect(badge.loc).toStrictEqual([1, 2, 3])
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test('should be optional', () => {
|
|
121
|
+
const badge = new Badge(badgeDataFixture.omit('loc').create())
|
|
122
|
+
expect(badge.loc).toBeUndefined()
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
describe('effect', () => {
|
|
127
|
+
test('should be set from the data', () => {
|
|
128
|
+
const badge = new Badge(badgeDataFixture.create({ effect: 'foo' }))
|
|
129
|
+
expect(badge.effect).toEqual('foo')
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
test('should be optional', () => {
|
|
133
|
+
const badge = new Badge(badgeDataFixture.omit('effect').create())
|
|
134
|
+
expect(badge.effect).toBeUndefined()
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
describe('vidiotMapKey', () => {
|
|
139
|
+
test('should be set from the data', () => {
|
|
140
|
+
const badge = new Badge(badgeDataFixture.create({ vidiotMapKey: 'foo' }))
|
|
141
|
+
expect(badge.vidiotMapKey).toEqual('foo')
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
test('should be optional', () => {
|
|
145
|
+
const badge = new Badge(badgeDataFixture.omit('vidiotMapKey').create())
|
|
146
|
+
expect(badge.vidiotMapKey).toBeUndefined()
|
|
147
|
+
})
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
describe('setTitle', () => {
|
|
151
|
+
test('should be set from the data', () => {
|
|
152
|
+
const badge = new Badge(badgeDataFixture.create({ setTitle: { id: 123, praetorianId: 456 } }))
|
|
153
|
+
expect(badge.setTitle).toStrictEqual({ id: 123, praetorianId: 456 })
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
test('should be optional', () => {
|
|
157
|
+
const badge = new Badge(badgeDataFixture.omit('setTitle').create())
|
|
158
|
+
expect(badge.setTitle).toBeUndefined()
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
describe('ignoreInTotals', () => {
|
|
163
|
+
test('should be set from the data', () => {
|
|
164
|
+
const badge = new Badge(badgeDataFixture.create({ ignoreInTotals: true }))
|
|
165
|
+
expect(badge.ignoreInTotals).toEqual(true)
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
test('should default to false', () => {
|
|
169
|
+
const badge = new Badge(badgeDataFixture.omit('ignoreInTotals').create())
|
|
170
|
+
expect(badge.ignoreInTotals).toEqual(false)
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
describe('requirements', () => {
|
|
175
|
+
test(`should throw an error on duplicate key in same group`, () => {
|
|
176
|
+
const data = badgeDataFixture.create({
|
|
177
|
+
key: 'badge',
|
|
178
|
+
requirements: [[
|
|
179
|
+
badgeRequirementDataFixture.create({ key: 'foo' }),
|
|
180
|
+
badgeRequirementDataFixture.create({ key: 'foo' }),
|
|
181
|
+
]],
|
|
182
|
+
})
|
|
183
|
+
expect(() => new Badge(data)).toThrow('Duplicate badge requirement key [badge:foo] in group [1]')
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
test(`should not throw an error on duplicate key in different group`, () => {
|
|
14
187
|
const data = badgeDataFixture.create({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
],
|
|
188
|
+
key: 'badge',
|
|
189
|
+
requirements: [[
|
|
190
|
+
badgeRequirementDataFixture.create({ key: 'foo' }),
|
|
191
|
+
], [
|
|
192
|
+
badgeRequirementDataFixture.create({ key: 'foo' }),
|
|
193
|
+
]],
|
|
19
194
|
})
|
|
20
|
-
|
|
195
|
+
new Badge(data)
|
|
21
196
|
})
|
|
22
197
|
})
|
|
23
198
|
|
|
24
|
-
describe('
|
|
25
|
-
test(`should retrieve
|
|
199
|
+
describe('getRequirement', () => {
|
|
200
|
+
test(`should retrieve requirement from the index`, () => {
|
|
26
201
|
const data = badgeDataFixture.create({
|
|
27
|
-
|
|
202
|
+
requirements: [[badgeRequirementDataFixture.create({ key: 'foo' })]],
|
|
28
203
|
})
|
|
29
204
|
|
|
30
|
-
expect(new Badge(data).
|
|
205
|
+
expect(new Badge(data).getRequirement('foo')).not.toBeUndefined()
|
|
31
206
|
})
|
|
32
207
|
|
|
33
|
-
test(`should throw error for unknown
|
|
208
|
+
test(`should throw error for unknown requirement`, () => {
|
|
34
209
|
const data = badgeDataFixture.create({
|
|
35
|
-
|
|
210
|
+
requirements: [],
|
|
36
211
|
})
|
|
37
212
|
|
|
38
|
-
expect(() => new Badge(data).
|
|
213
|
+
expect(() => new Badge(data).getRequirement('foo')).toThrow('Unknown badge requirement key [foo]')
|
|
39
214
|
})
|
|
40
215
|
})
|
|
41
216
|
})
|
|
@@ -2,7 +2,8 @@ import { CohContentDatabase } from '../../main'
|
|
|
2
2
|
import { contentBundleFixture } from '../api/content-bundle.fixture'
|
|
3
3
|
import { archetypeDataFixture } from '../api/archetype-data.fixture'
|
|
4
4
|
import { badgeDataFixture } from '../api/badge-data.fixture'
|
|
5
|
-
import {
|
|
5
|
+
import { zoneDataFixture } from '../api/zone-data.fixture'
|
|
6
|
+
import { contactDataFixture } from '../api/contact-data.fixture'
|
|
6
7
|
|
|
7
8
|
describe(CohContentDatabase.name, () => {
|
|
8
9
|
test('should load a basic bundle', () => {
|
|
@@ -32,7 +33,7 @@ describe(CohContentDatabase.name, () => {
|
|
|
32
33
|
archetypeDataFixture.create({ key: 'foo' }),
|
|
33
34
|
],
|
|
34
35
|
})
|
|
35
|
-
expect(() => new CohContentDatabase(data)).toThrow(
|
|
36
|
+
expect(() => new CohContentDatabase(data)).toThrow(`Duplicate archetype key 'foo'`)
|
|
36
37
|
})
|
|
37
38
|
|
|
38
39
|
test(`should accept an undefined field`, () => {
|
|
@@ -68,22 +69,41 @@ describe(CohContentDatabase.name, () => {
|
|
|
68
69
|
})
|
|
69
70
|
})
|
|
70
71
|
|
|
71
|
-
describe('
|
|
72
|
-
test(`should throw an error on duplicate
|
|
72
|
+
describe('zones', () => {
|
|
73
|
+
test(`should throw an error on duplicate zone`, () => {
|
|
73
74
|
const data = contentBundleFixture.create({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
zones: [
|
|
76
|
+
zoneDataFixture.create({ key: 'foo' }),
|
|
77
|
+
zoneDataFixture.create({ key: 'foo' }),
|
|
77
78
|
],
|
|
78
79
|
})
|
|
79
|
-
expect(() => new CohContentDatabase(data)).toThrow(
|
|
80
|
+
expect(() => new CohContentDatabase(data)).toThrow(`Duplicate zone key 'foo'`)
|
|
80
81
|
})
|
|
81
82
|
|
|
82
83
|
test(`should accept an undefined field`, () => {
|
|
83
84
|
const data = contentBundleFixture
|
|
84
|
-
.omit('
|
|
85
|
+
.omit('zones')
|
|
85
86
|
.create()
|
|
86
|
-
expect(() => new CohContentDatabase(data).
|
|
87
|
+
expect(() => new CohContentDatabase(data).zones).toHaveLength(0)
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
describe('contacts', () => {
|
|
92
|
+
test(`should throw an error on duplicate contact`, () => {
|
|
93
|
+
const data = contentBundleFixture.create({
|
|
94
|
+
contacts: [
|
|
95
|
+
contactDataFixture.create({ key: 'foo' }),
|
|
96
|
+
contactDataFixture.create({ key: 'foo' }),
|
|
97
|
+
],
|
|
98
|
+
})
|
|
99
|
+
expect(() => new CohContentDatabase(data)).toThrow(`Duplicate contact key 'foo'`)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
test(`should accept an undefined field`, () => {
|
|
103
|
+
const data = contentBundleFixture
|
|
104
|
+
.omit('contacts')
|
|
105
|
+
.create()
|
|
106
|
+
expect(() => new CohContentDatabase(data).contacts).toHaveLength(0)
|
|
87
107
|
})
|
|
88
108
|
})
|
|
89
109
|
|
|
@@ -101,25 +121,79 @@ describe(CohContentDatabase.name, () => {
|
|
|
101
121
|
archetypes: [],
|
|
102
122
|
})
|
|
103
123
|
|
|
104
|
-
expect(() => new CohContentDatabase(data).getArchetype('foo')).toThrow(
|
|
124
|
+
expect(() => new CohContentDatabase(data).getArchetype('foo')).toThrow(`Unknown archetype key 'foo'`)
|
|
105
125
|
})
|
|
106
126
|
})
|
|
107
127
|
|
|
108
|
-
describe('
|
|
109
|
-
test(`should retrieve
|
|
128
|
+
describe('getZone', () => {
|
|
129
|
+
test(`should retrieve zone from the index`, () => {
|
|
110
130
|
const data = contentBundleFixture.create({
|
|
111
|
-
|
|
131
|
+
zones: [zoneDataFixture.create({ key: 'foo' })],
|
|
112
132
|
})
|
|
113
133
|
|
|
114
|
-
expect(new CohContentDatabase(data).
|
|
134
|
+
expect(new CohContentDatabase(data).getZone('foo')).not.toBeUndefined()
|
|
115
135
|
})
|
|
116
136
|
|
|
117
|
-
test(`should throw error for unknown
|
|
137
|
+
test(`should throw error for unknown zone`, () => {
|
|
118
138
|
const data = contentBundleFixture.create({
|
|
119
|
-
|
|
139
|
+
zones: [],
|
|
120
140
|
})
|
|
121
141
|
|
|
122
|
-
expect(() => new CohContentDatabase(data).
|
|
142
|
+
expect(() => new CohContentDatabase(data).getZone('foo')).toThrow(`Unknown zone key 'foo'`)
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
describe('zoneExists', () => {
|
|
147
|
+
test(`should return true for a zone that exists`, () => {
|
|
148
|
+
const data = contentBundleFixture.create({
|
|
149
|
+
zones: [zoneDataFixture.create({ key: 'foo' })],
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
expect(new CohContentDatabase(data).zoneExists('foo')).toBeTruthy()
|
|
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()
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
describe('getContact', () => {
|
|
165
|
+
test(`should retrieve contact from the index`, () => {
|
|
166
|
+
const data = contentBundleFixture.create({
|
|
167
|
+
contacts: [contactDataFixture.create({ key: 'foo' })],
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
expect(new CohContentDatabase(data).getContact('foo')).not.toBeUndefined()
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
test(`should throw error for unknown contact`, () => {
|
|
174
|
+
const data = contentBundleFixture.create({
|
|
175
|
+
contacts: [],
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
expect(() => new CohContentDatabase(data).getContact('foo')).toThrow(`Unknown contact key 'foo'`)
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
|
|
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()
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
test(`should return false for a contact that does not exist`, () => {
|
|
192
|
+
const data = contentBundleFixture.create({
|
|
193
|
+
contacts: [],
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
expect(new CohContentDatabase(data).contactExists('foo')).toBeFalsy()
|
|
123
197
|
})
|
|
124
198
|
})
|
|
125
199
|
|
|
@@ -141,6 +215,24 @@ describe(CohContentDatabase.name, () => {
|
|
|
141
215
|
})
|
|
142
216
|
})
|
|
143
217
|
|
|
218
|
+
describe('badgeExists', () => {
|
|
219
|
+
test(`should return true for a badge that exists`, () => {
|
|
220
|
+
const data = contentBundleFixture.create({
|
|
221
|
+
badges: [badgeDataFixture.create({ key: 'foo' })],
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
expect(new CohContentDatabase(data).badgeExists('foo')).toBeTruthy()
|
|
225
|
+
})
|
|
226
|
+
|
|
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()
|
|
233
|
+
})
|
|
234
|
+
})
|
|
235
|
+
|
|
144
236
|
describe('searchBadges', () => {
|
|
145
237
|
test(`should search the badge list`, () => {
|
|
146
238
|
const data = contentBundleFixture.create({
|
|
@@ -0,0 +1,96 @@
|
|
|
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 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 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 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 should be optional`, () => {
|
|
32
|
+
const contact = new Contact(contactDataFixture.omit('title').create())
|
|
33
|
+
expect(contact.title).toBeUndefined()
|
|
34
|
+
})
|
|
35
|
+
})
|
|
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')
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test(`should should be optional`, () => {
|
|
44
|
+
const contact = new Contact(contactDataFixture.omit('zoneKey').create())
|
|
45
|
+
expect(contact.zoneKey).toBeUndefined()
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
|
|
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])
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test(`should should be optional`, () => {
|
|
56
|
+
const contact = new Contact(contactDataFixture.omit('loc').create())
|
|
57
|
+
expect(contact.loc).toBeUndefined()
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
describe('levelRange', () => {
|
|
62
|
+
test(`should should be set from the data`, () => {
|
|
63
|
+
const contact = new Contact(contactDataFixture.create({ levelRange: [1, 2] }))
|
|
64
|
+
expect(contact.levelRange).toStrictEqual([1, 2])
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test(`should should be optional`, () => {
|
|
68
|
+
const contact = new Contact(contactDataFixture.omit('levelRange').create())
|
|
69
|
+
expect(contact.levelRange).toBeUndefined()
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
describe('notes', () => {
|
|
74
|
+
test(`should should be set from the data`, () => {
|
|
75
|
+
const contact = new Contact(contactDataFixture.create({ notes: 'foo' }))
|
|
76
|
+
expect(contact.notes).toEqual('foo')
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
test(`should should be optional`, () => {
|
|
80
|
+
const contact = new Contact(contactDataFixture.omit('notes').create())
|
|
81
|
+
expect(contact.notes).toBeUndefined()
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
describe('links', () => {
|
|
86
|
+
test(`should should be set from the data`, () => {
|
|
87
|
+
const contact = new Contact(contactDataFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
|
|
88
|
+
expect(contact.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
test(`should should be optional`, () => {
|
|
92
|
+
const contact = new Contact(contactDataFixture.omit('links').create())
|
|
93
|
+
expect(contact.links).toHaveLength(0)
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
})
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Zone } from '../../main'
|
|
2
|
+
import { zoneDataFixture } from '../api/zone-data.fixture'
|
|
3
|
+
|
|
4
|
+
describe(Zone.name, () => {
|
|
5
|
+
describe('Constructor', () => {
|
|
6
|
+
test(`should accept the test fixture`, () => {
|
|
7
|
+
new Zone(zoneDataFixture.create())
|
|
8
|
+
})
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
describe('key', () => {
|
|
12
|
+
test(`should should be set from the data`, () => {
|
|
13
|
+
const zone = new Zone(zoneDataFixture.create({ key: 'foo' }))
|
|
14
|
+
expect(zone.key).toEqual('foo')
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
describe('name', () => {
|
|
19
|
+
test(`should should be set from the data`, () => {
|
|
20
|
+
const zone = new Zone(zoneDataFixture.create({ name: 'foo' }))
|
|
21
|
+
expect(zone.name).toEqual('foo')
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
describe('links', () => {
|
|
26
|
+
test(`should should be set from the data`, () => {
|
|
27
|
+
const zone = new Zone(zoneDataFixture.create({ links: [{ title: 'foo', href: 'bar' }] }))
|
|
28
|
+
expect(zone.links).toStrictEqual([{ title: 'foo', href: 'bar' }])
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test(`should should be optional`, () => {
|
|
32
|
+
const zone = new Zone(zoneDataFixture.omit('links').create())
|
|
33
|
+
expect(zone.links).toHaveLength(0)
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
})
|
package/src/test/index.test.ts
CHANGED
|
@@ -7,6 +7,8 @@ test('should export the changelog', () => {
|
|
|
7
7
|
test('should export badge reference utils', () => {
|
|
8
8
|
expect(index).toHaveProperty('badgeUri')
|
|
9
9
|
expect(index).toHaveProperty('badgeLink')
|
|
10
|
-
expect(index).toHaveProperty('
|
|
11
|
-
expect(index).toHaveProperty('
|
|
10
|
+
expect(index).toHaveProperty('contactUri')
|
|
11
|
+
expect(index).toHaveProperty('contactLink')
|
|
12
|
+
expect(index).toHaveProperty('zoneUri')
|
|
13
|
+
expect(index).toHaveProperty('zoneLink')
|
|
12
14
|
})
|
package/src/test/util.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Badge, badgeLink, badgeUri,
|
|
1
|
+
import { Badge, badgeLink, badgeUri, Contact, contactLink, contactUri, Zone, zoneLink, zoneUri } from '../main'
|
|
2
2
|
import { badgeDataFixture } from './api/badge-data.fixture'
|
|
3
|
-
import {
|
|
3
|
+
import { zoneDataFixture } from './api/zone-data.fixture'
|
|
4
|
+
import { contactDataFixture } from './api/contact-data.fixture'
|
|
4
5
|
|
|
5
6
|
describe(badgeUri.name, () => {
|
|
6
7
|
test('should return the expected pattern', () => {
|
|
@@ -38,38 +39,74 @@ describe(badgeLink.name, () => {
|
|
|
38
39
|
})
|
|
39
40
|
})
|
|
40
41
|
|
|
41
|
-
describe(
|
|
42
|
+
describe(contactUri.name, () => {
|
|
42
43
|
test('should return the expected pattern', () => {
|
|
43
|
-
expect(
|
|
44
|
-
expect(
|
|
45
|
-
expect(
|
|
44
|
+
expect(contactUri('foo')).toBe('contact://foo')
|
|
45
|
+
expect(contactUri('bar')).toBe('contact://bar')
|
|
46
|
+
expect(contactUri('foo-bar')).toBe('contact://foo-bar')
|
|
46
47
|
})
|
|
47
48
|
|
|
48
|
-
test('should accept a
|
|
49
|
-
const
|
|
50
|
-
expect(
|
|
49
|
+
test('should accept a Contact object', () => {
|
|
50
|
+
const contact = new Contact(contactDataFixture.create({ key: 'foo' }))
|
|
51
|
+
expect(contactUri(contact)).toBe('contact://foo')
|
|
51
52
|
})
|
|
52
53
|
|
|
53
|
-
test('should accept a
|
|
54
|
-
const
|
|
55
|
-
expect(
|
|
54
|
+
test('should accept a ContactData object', () => {
|
|
55
|
+
const contact = contactDataFixture.create({ key: 'foo' })
|
|
56
|
+
expect(contactUri(contact)).toBe('contact://foo')
|
|
56
57
|
})
|
|
57
58
|
})
|
|
58
59
|
|
|
59
|
-
describe(
|
|
60
|
+
describe(contactLink.name, () => {
|
|
60
61
|
test('should return the expected pattern', () => {
|
|
61
|
-
expect(
|
|
62
|
-
expect(
|
|
63
|
-
expect(
|
|
62
|
+
expect(contactLink('foo')).toBe('[foo](contact://foo)')
|
|
63
|
+
expect(contactLink('bar')).toBe('[bar](contact://bar)')
|
|
64
|
+
expect(contactLink('foo-bar')).toBe('[foo-bar](contact://foo-bar)')
|
|
64
65
|
})
|
|
65
66
|
|
|
66
|
-
test('should accept a
|
|
67
|
-
const
|
|
68
|
-
expect(
|
|
67
|
+
test('should accept a Contact object', () => {
|
|
68
|
+
const contact = new Contact(contactDataFixture.create({ key: 'foo' }))
|
|
69
|
+
expect(contactLink(contact)).toBe('[foo](contact://foo)')
|
|
69
70
|
})
|
|
70
71
|
|
|
71
|
-
test('should accept a
|
|
72
|
-
const
|
|
73
|
-
expect(
|
|
72
|
+
test('should accept a ContactData object', () => {
|
|
73
|
+
const contact = contactDataFixture.create({ key: 'foo' })
|
|
74
|
+
expect(contactLink(contact)).toBe('[foo](contact://foo)')
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
describe(zoneUri.name, () => {
|
|
79
|
+
test('should return the expected pattern', () => {
|
|
80
|
+
expect(zoneUri('foo')).toBe('zone://foo')
|
|
81
|
+
expect(zoneUri('bar')).toBe('zone://bar')
|
|
82
|
+
expect(zoneUri('foo-bar')).toBe('zone://foo-bar')
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test('should accept a Zone object', () => {
|
|
86
|
+
const zone = new Zone(zoneDataFixture.create({ key: 'foo' }))
|
|
87
|
+
expect(zoneUri(zone)).toBe('zone://foo')
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
test('should accept a ZoneData object', () => {
|
|
91
|
+
const zone = zoneDataFixture.create({ key: 'foo' })
|
|
92
|
+
expect(zoneUri(zone)).toBe('zone://foo')
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
describe(zoneLink.name, () => {
|
|
97
|
+
test('should return the expected pattern', () => {
|
|
98
|
+
expect(zoneLink('foo')).toBe('[foo](zone://foo)')
|
|
99
|
+
expect(zoneLink('bar')).toBe('[bar](zone://bar)')
|
|
100
|
+
expect(zoneLink('foo-bar')).toBe('[foo-bar](zone://foo-bar)')
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
test('should accept a Zone object', () => {
|
|
104
|
+
const zone = new Zone(zoneDataFixture.create({ key: 'foo' }))
|
|
105
|
+
expect(zoneLink(zone)).toBe('[foo](zone://foo)')
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
test('should accept a ZoneData object', () => {
|
|
109
|
+
const zone = zoneDataFixture.create({ key: 'foo' })
|
|
110
|
+
expect(zoneLink(zone)).toBe('[foo](zone://foo)')
|
|
74
111
|
})
|
|
75
112
|
})
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export const BADGE_PARTIAL_TYPE = [
|
|
2
|
-
'PLAQUE',
|
|
3
|
-
'BADGE',
|
|
4
|
-
'INVENTION',
|
|
5
|
-
'INVENTION_PLUS_ONE', // Some invention badges require you to build x of two different invention levels, 'plus one of either level'.
|
|
6
|
-
] as const
|
|
7
|
-
|
|
8
|
-
export type BadgePartialType = typeof BADGE_PARTIAL_TYPE[number]
|