coh-content-db 2.0.0-rc.7 → 2.0.0-rc.9
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/.github/workflows/build.yml +1 -1
- package/.github/workflows/pull-request.yml +1 -1
- package/.github/workflows/release.yml +1 -1
- package/CHANGELOG.md +38 -0
- package/README.md +24 -7
- package/dist/coh-content-db.d.ts +108 -64
- package/dist/coh-content-db.js +232 -210
- package/dist/coh-content-db.js.map +1 -1
- package/dist/coh-content-db.mjs +232 -209
- package/dist/coh-content-db.mjs.map +1 -1
- package/package.json +1 -1
- package/src/main/api/{content-bundle.ts → bundle-data.ts} +5 -27
- package/src/main/api/bundle-header-data.ts +37 -0
- package/src/main/db/abstract-index.ts +41 -0
- package/src/main/db/badge-index.ts +7 -18
- package/src/main/db/bundle-header.ts +44 -0
- package/src/main/db/coh-content-database.ts +81 -72
- package/src/main/index.ts +3 -4
- package/src/test/api/bundle-data.fixture.ts +6 -0
- package/src/test/api/bundle-header-data.fixture.ts +6 -0
- package/src/test/db/abstract-index.test.ts +86 -0
- package/src/test/db/badge-index.test.ts +149 -122
- package/src/test/db/bundle-header.test.ts +76 -0
- package/src/test/db/coh-content-database.test.ts +164 -79
- package/src/test/integration.test.ts +16 -0
- package/src/main/api/change.ts +0 -17
- package/src/main/changelog.ts +0 -29
- package/src/main/db/bundle-metadata.ts +0 -39
- package/src/test/api/content-bundle.fixture.ts +0 -6
- package/src/test/api/content-bundle.test.ts +0 -14
- package/src/test/changelog.test.ts +0 -36
- package/src/test/db/bundle-metadata.test.ts +0 -67
- package/src/test/index.test.ts +0 -14
|
@@ -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
|
+
})
|
|
@@ -1,237 +1,322 @@
|
|
|
1
1
|
import { CohContentDatabase } from '../../main'
|
|
2
|
-
import { contentBundleFixture } from '../api/content-bundle.fixture'
|
|
3
2
|
import { archetypeDataFixture } from '../api/archetype-data.fixture'
|
|
4
3
|
import { badgeDataFixture } from '../api/badge-data.fixture'
|
|
5
4
|
import { zoneDataFixture } from '../api/zone-data.fixture'
|
|
6
5
|
import { contactDataFixture } from '../api/contact-data.fixture'
|
|
7
6
|
import { missionDataFixture } from '../api/mission-data.fixture'
|
|
7
|
+
import { bundleDataFixture } from '../api/bundle-data.fixture'
|
|
8
8
|
|
|
9
9
|
describe(CohContentDatabase.name, () => {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
describe('load', () => {
|
|
11
|
+
test('should load a basic bundle', () => {
|
|
12
|
+
const database = new CohContentDatabase()
|
|
13
|
+
database.load({})
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('should reset the database if load is called again', () => {
|
|
17
|
+
const database = new CohContentDatabase()
|
|
18
|
+
database.load(bundleDataFixture.create({
|
|
19
|
+
header: { name: 'Homecoming' },
|
|
20
|
+
servers: ['Test'],
|
|
21
|
+
archetypes: [archetypeDataFixture.create()],
|
|
22
|
+
zones: [zoneDataFixture.create()],
|
|
23
|
+
contacts: [contactDataFixture.create()],
|
|
24
|
+
missions: [missionDataFixture.create()],
|
|
25
|
+
badges: [badgeDataFixture.create()],
|
|
26
|
+
}))
|
|
27
|
+
|
|
28
|
+
expect(database.header?.name).toEqual('Homecoming')
|
|
29
|
+
expect(database.servers).toHaveLength(1)
|
|
30
|
+
expect(database.archetypes).toHaveLength(1)
|
|
31
|
+
expect(database.zones).toHaveLength(1)
|
|
32
|
+
expect(database.contacts).toHaveLength(1)
|
|
33
|
+
expect(database.missions).toHaveLength(1)
|
|
34
|
+
expect(database.badges).toHaveLength(1)
|
|
35
|
+
|
|
36
|
+
database.load(bundleDataFixture.create({ header: { name: 'Reset' } }))
|
|
37
|
+
expect(database.header?.name).toEqual('Reset')
|
|
38
|
+
expect(database.servers).toHaveLength(0)
|
|
39
|
+
expect(database.archetypes).toHaveLength(0)
|
|
40
|
+
expect(database.zones).toHaveLength(0)
|
|
41
|
+
expect(database.contacts).toHaveLength(0)
|
|
42
|
+
expect(database.missions).toHaveLength(0)
|
|
43
|
+
expect(database.badges).toHaveLength(0)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
describe('header', () => {
|
|
48
|
+
test(`should be undefined if not initialized`, () => {
|
|
49
|
+
const database = new CohContentDatabase()
|
|
50
|
+
expect(database.header).toBeUndefined()
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test(`should load values from bundle`, () => {
|
|
54
|
+
const database = new CohContentDatabase()
|
|
55
|
+
database.load(bundleDataFixture
|
|
56
|
+
.create({ header: { name: 'Homecoming' } }))
|
|
57
|
+
|
|
58
|
+
expect(database.header?.name).toBe('Homecoming')
|
|
59
|
+
})
|
|
12
60
|
})
|
|
13
61
|
|
|
14
62
|
describe('servers', () => {
|
|
15
63
|
test(`should accept an undefined field`, () => {
|
|
16
|
-
const
|
|
64
|
+
const database = new CohContentDatabase()
|
|
65
|
+
database.load(bundleDataFixture
|
|
17
66
|
.omit('servers')
|
|
18
|
-
.create()
|
|
19
|
-
|
|
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)
|
|
20
75
|
})
|
|
21
76
|
|
|
22
77
|
test(`should load values from bundle`, () => {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
78
|
+
const database = new CohContentDatabase()
|
|
79
|
+
database.load(bundleDataFixture
|
|
80
|
+
.create({ servers: ['Foo', 'Bar'] }))
|
|
81
|
+
|
|
82
|
+
expect(database.servers).toStrictEqual(['Foo', 'Bar'])
|
|
26
83
|
})
|
|
27
84
|
})
|
|
28
85
|
|
|
29
86
|
describe('archetypes', () => {
|
|
30
87
|
test(`should throw an error on duplicate key`, () => {
|
|
31
|
-
const
|
|
88
|
+
const database = new CohContentDatabase()
|
|
89
|
+
expect(() => database.load(bundleDataFixture.create({
|
|
32
90
|
archetypes: [
|
|
33
91
|
archetypeDataFixture.create({ key: 'foo' }),
|
|
34
92
|
archetypeDataFixture.create({ key: 'foo' }),
|
|
35
93
|
],
|
|
36
|
-
})
|
|
37
|
-
expect(() => new CohContentDatabase(data)).toThrow(`Duplicate archetype key 'foo'`)
|
|
94
|
+
}))).toThrow(`Duplicate key [foo]`)
|
|
38
95
|
})
|
|
39
96
|
|
|
40
97
|
test(`should accept an undefined field`, () => {
|
|
41
|
-
const
|
|
98
|
+
const database = new CohContentDatabase()
|
|
99
|
+
database.load(bundleDataFixture
|
|
42
100
|
.omit('archetypes')
|
|
43
|
-
.create()
|
|
44
|
-
expect(
|
|
101
|
+
.create())
|
|
102
|
+
expect(database.archetypes).toHaveLength(0)
|
|
45
103
|
})
|
|
46
104
|
|
|
47
105
|
test(`should load data from bundle`, () => {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
106
|
+
const database = new CohContentDatabase()
|
|
107
|
+
database.load(bundleDataFixture
|
|
108
|
+
.create({ archetypes: [archetypeDataFixture.create({ key: 'foo' })] }))
|
|
109
|
+
expect(database.getArchetype('foo')).not.toBeUndefined()
|
|
51
110
|
})
|
|
52
111
|
})
|
|
53
112
|
|
|
54
113
|
describe('badges', () => {
|
|
55
114
|
test(`should throw an error on duplicate key`, () => {
|
|
56
|
-
const
|
|
115
|
+
const database = new CohContentDatabase()
|
|
116
|
+
expect(() => database.load(bundleDataFixture.create({
|
|
57
117
|
badges: [
|
|
58
118
|
badgeDataFixture.create({ key: 'foo' }),
|
|
59
119
|
badgeDataFixture.create({ key: 'foo' }),
|
|
60
120
|
],
|
|
61
|
-
})
|
|
62
|
-
expect(() => new CohContentDatabase(data)).toThrow('Duplicate badge key [foo]')
|
|
121
|
+
}))).toThrow('Duplicate key [foo]')
|
|
63
122
|
})
|
|
64
123
|
|
|
65
124
|
test(`should accept an undefined field`, () => {
|
|
66
|
-
const
|
|
125
|
+
const database = new CohContentDatabase()
|
|
126
|
+
database.load(bundleDataFixture
|
|
67
127
|
.omit('badges')
|
|
68
|
-
.create()
|
|
69
|
-
expect(
|
|
128
|
+
.create())
|
|
129
|
+
expect(database.badges).toHaveLength(0)
|
|
70
130
|
})
|
|
71
131
|
})
|
|
72
132
|
|
|
73
133
|
describe('zones', () => {
|
|
74
134
|
test(`should throw an error on duplicate zone`, () => {
|
|
75
|
-
const
|
|
135
|
+
const database = new CohContentDatabase()
|
|
136
|
+
expect(() => database.load(bundleDataFixture.create({
|
|
76
137
|
zones: [
|
|
77
138
|
zoneDataFixture.create({ key: 'foo' }),
|
|
78
139
|
zoneDataFixture.create({ key: 'foo' }),
|
|
79
140
|
],
|
|
80
|
-
})
|
|
81
|
-
expect(() => new CohContentDatabase(data)).toThrow(`Duplicate zone key 'foo'`)
|
|
141
|
+
}))).toThrow(`Duplicate key [foo]`)
|
|
82
142
|
})
|
|
83
143
|
|
|
84
144
|
test(`should accept an undefined field`, () => {
|
|
85
|
-
const
|
|
145
|
+
const database = new CohContentDatabase()
|
|
146
|
+
database.load(bundleDataFixture
|
|
86
147
|
.omit('zones')
|
|
87
|
-
.create()
|
|
88
|
-
expect(
|
|
148
|
+
.create())
|
|
149
|
+
expect(database.zones).toHaveLength(0)
|
|
89
150
|
})
|
|
90
151
|
})
|
|
91
152
|
|
|
92
153
|
describe('contacts', () => {
|
|
93
154
|
test(`should throw an error on duplicate contact`, () => {
|
|
94
|
-
const
|
|
155
|
+
const database = new CohContentDatabase()
|
|
156
|
+
expect(() => database.load(bundleDataFixture.create({
|
|
95
157
|
contacts: [
|
|
96
158
|
contactDataFixture.create({ key: 'foo' }),
|
|
97
159
|
contactDataFixture.create({ key: 'foo' }),
|
|
98
160
|
],
|
|
99
|
-
})
|
|
100
|
-
expect(() => new CohContentDatabase(data)).toThrow(`Duplicate contact key 'foo'`)
|
|
161
|
+
}))).toThrow(`Duplicate key [foo]`)
|
|
101
162
|
})
|
|
102
163
|
|
|
103
164
|
test(`should accept an undefined field`, () => {
|
|
104
|
-
const
|
|
165
|
+
const database = new CohContentDatabase()
|
|
166
|
+
database.load(bundleDataFixture
|
|
105
167
|
.omit('contacts')
|
|
106
|
-
.create()
|
|
107
|
-
expect(
|
|
168
|
+
.create())
|
|
169
|
+
expect(database.contacts).toHaveLength(0)
|
|
108
170
|
})
|
|
109
171
|
})
|
|
110
172
|
|
|
111
173
|
describe('missions', () => {
|
|
112
174
|
test(`should throw an error on duplicate mission`, () => {
|
|
113
|
-
const
|
|
175
|
+
const database = new CohContentDatabase()
|
|
176
|
+
expect(() => database.load(bundleDataFixture.create({
|
|
114
177
|
missions: [
|
|
115
178
|
missionDataFixture.create({ key: 'foo' }),
|
|
116
179
|
missionDataFixture.create({ key: 'foo' }),
|
|
117
180
|
],
|
|
118
|
-
})
|
|
119
|
-
expect(() => new CohContentDatabase(data)).toThrow(`Duplicate mission key 'foo'`)
|
|
181
|
+
}))).toThrow(`Duplicate key [foo]`)
|
|
120
182
|
})
|
|
121
183
|
|
|
122
184
|
test(`should accept an undefined field`, () => {
|
|
123
|
-
const
|
|
185
|
+
const database = new CohContentDatabase()
|
|
186
|
+
database.load(bundleDataFixture
|
|
124
187
|
.omit('missions')
|
|
125
|
-
.create()
|
|
126
|
-
expect(
|
|
188
|
+
.create())
|
|
189
|
+
expect(database.missions).toHaveLength(0)
|
|
127
190
|
})
|
|
128
191
|
})
|
|
129
192
|
|
|
130
193
|
describe('getArchetype', () => {
|
|
131
194
|
test(`should retrieve archetype from the index`, () => {
|
|
132
|
-
const
|
|
195
|
+
const database = new CohContentDatabase()
|
|
196
|
+
database.load(bundleDataFixture.create({
|
|
133
197
|
archetypes: [archetypeDataFixture.create({ key: 'foo' })],
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
expect(new CohContentDatabase(data).getArchetype('foo')).not.toBeUndefined()
|
|
198
|
+
}))
|
|
199
|
+
expect(database.getArchetype('foo')).not.toBeUndefined()
|
|
137
200
|
})
|
|
138
201
|
|
|
139
202
|
test(`should return undefined for unknown archetype`, () => {
|
|
140
|
-
const
|
|
141
|
-
|
|
203
|
+
const database = new CohContentDatabase()
|
|
204
|
+
database.load(bundleDataFixture.create({ archetypes: [] }))
|
|
205
|
+
expect(database.getArchetype('foo')).toBeUndefined()
|
|
142
206
|
})
|
|
143
207
|
|
|
144
208
|
test(`should return undefined for undefined key`, () => {
|
|
145
|
-
|
|
209
|
+
const database = new CohContentDatabase()
|
|
210
|
+
database.load(bundleDataFixture.create({ archetypes: [] }))
|
|
211
|
+
const key = undefined
|
|
212
|
+
expect(database.getArchetype(key)).toBeUndefined()
|
|
146
213
|
})
|
|
147
214
|
})
|
|
148
215
|
|
|
149
216
|
describe('getZone', () => {
|
|
150
217
|
test(`should retrieve zone from the index`, () => {
|
|
151
|
-
const
|
|
218
|
+
const database = new CohContentDatabase()
|
|
219
|
+
database.load(bundleDataFixture.create({
|
|
152
220
|
zones: [zoneDataFixture.create({ key: 'foo' })],
|
|
153
|
-
})
|
|
221
|
+
}))
|
|
154
222
|
|
|
155
|
-
expect(
|
|
223
|
+
expect(database.getZone('foo')).not.toBeUndefined()
|
|
156
224
|
})
|
|
157
225
|
|
|
158
226
|
test(`should return undefined for unknown zone`, () => {
|
|
159
|
-
const
|
|
160
|
-
|
|
227
|
+
const database = new CohContentDatabase()
|
|
228
|
+
database.load(bundleDataFixture.create({ zones: [] }))
|
|
229
|
+
expect(database.getZone('foo')).toBeUndefined()
|
|
161
230
|
})
|
|
162
231
|
|
|
163
232
|
test(`should return undefined for undefined key`, () => {
|
|
164
|
-
|
|
233
|
+
const database = new CohContentDatabase()
|
|
234
|
+
database.load(bundleDataFixture.create({ zones: [] }))
|
|
235
|
+
const key = undefined
|
|
236
|
+
expect(database.getZone(key)).toBeUndefined()
|
|
165
237
|
})
|
|
166
238
|
})
|
|
167
239
|
|
|
168
240
|
describe('getContact', () => {
|
|
169
241
|
test(`should retrieve contact from the index`, () => {
|
|
170
|
-
const
|
|
242
|
+
const database = new CohContentDatabase()
|
|
243
|
+
database.load(bundleDataFixture.create({
|
|
171
244
|
contacts: [contactDataFixture.create({ key: 'foo' })],
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
expect(new CohContentDatabase(data).getContact('foo')).not.toBeUndefined()
|
|
245
|
+
}))
|
|
246
|
+
expect(database.getContact('foo')).not.toBeUndefined()
|
|
175
247
|
})
|
|
176
248
|
|
|
177
249
|
test(`should return undefined for unknown contact`, () => {
|
|
178
|
-
const
|
|
179
|
-
|
|
250
|
+
const database = new CohContentDatabase()
|
|
251
|
+
database.load(bundleDataFixture.create({ contacts: [] }))
|
|
252
|
+
expect(database.getContact('foo')).toBeUndefined()
|
|
180
253
|
})
|
|
181
254
|
|
|
182
255
|
test(`should return undefined for undefined key`, () => {
|
|
183
|
-
|
|
256
|
+
const database = new CohContentDatabase()
|
|
257
|
+
database.load(bundleDataFixture.create({ contacts: [] }))
|
|
258
|
+
const key = undefined
|
|
259
|
+
expect(database.getContact(key)).toBeUndefined()
|
|
184
260
|
})
|
|
185
261
|
})
|
|
186
262
|
|
|
187
263
|
describe('getMission', () => {
|
|
188
264
|
test(`should retrieve mission from the index`, () => {
|
|
189
|
-
const
|
|
265
|
+
const database = new CohContentDatabase()
|
|
266
|
+
database.load(bundleDataFixture.create({
|
|
190
267
|
missions: [missionDataFixture.create({ key: 'foo' })],
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
expect(new CohContentDatabase(data).getMission('foo')).not.toBeUndefined()
|
|
268
|
+
}))
|
|
269
|
+
expect(database.getMission('foo')).not.toBeUndefined()
|
|
194
270
|
})
|
|
195
271
|
|
|
196
272
|
test(`should return undefined for unknown mission`, () => {
|
|
197
|
-
const
|
|
198
|
-
|
|
273
|
+
const database = new CohContentDatabase()
|
|
274
|
+
database.load(bundleDataFixture.create({ missions: [] }))
|
|
275
|
+
expect(database.getMission('foo')).toBeUndefined()
|
|
199
276
|
})
|
|
200
277
|
|
|
201
278
|
test(`should return undefined for undefined key`, () => {
|
|
202
|
-
|
|
279
|
+
const database = new CohContentDatabase()
|
|
280
|
+
database.load(bundleDataFixture.create({ missions: [] }))
|
|
281
|
+
const key = undefined
|
|
282
|
+
expect(database.getMission(key)).toBeUndefined()
|
|
203
283
|
})
|
|
204
284
|
})
|
|
205
285
|
|
|
206
286
|
describe('getBadge', () => {
|
|
207
287
|
test(`should retrieve badge from the index`, () => {
|
|
208
|
-
const
|
|
288
|
+
const database = new CohContentDatabase()
|
|
289
|
+
database.load(bundleDataFixture.create({
|
|
209
290
|
badges: [badgeDataFixture.create({ key: 'foo' })],
|
|
210
|
-
})
|
|
211
|
-
|
|
212
|
-
expect(new CohContentDatabase(data).getBadge('foo')).not.toBeUndefined()
|
|
291
|
+
}))
|
|
292
|
+
expect(database.getBadge('foo')).not.toBeUndefined()
|
|
213
293
|
})
|
|
214
294
|
|
|
215
295
|
test(`should return undefined for unknown badge`, () => {
|
|
216
|
-
const
|
|
217
|
-
|
|
296
|
+
const database = new CohContentDatabase()
|
|
297
|
+
database.load(bundleDataFixture.create({ badges: [] }))
|
|
298
|
+
expect(database.getBadge('foo')).toBeUndefined()
|
|
218
299
|
})
|
|
219
300
|
|
|
220
301
|
test(`should return undefined for undefined key`, () => {
|
|
221
|
-
|
|
302
|
+
const database = new CohContentDatabase()
|
|
303
|
+
database.load(bundleDataFixture.create({ badges: [] }))
|
|
304
|
+
const key = undefined
|
|
305
|
+
expect(database.getBadge(key)).toBeUndefined()
|
|
222
306
|
})
|
|
223
307
|
})
|
|
224
308
|
|
|
225
309
|
describe('searchBadges', () => {
|
|
226
310
|
test(`should search the badge list`, () => {
|
|
227
|
-
const
|
|
311
|
+
const database = new CohContentDatabase()
|
|
312
|
+
database.load(bundleDataFixture.create({
|
|
228
313
|
badges: [
|
|
229
314
|
badgeDataFixture.create({ key: 'foo', name: [{ value: 'Foo' }] }),
|
|
230
315
|
badgeDataFixture.create({ key: 'bar', name: [{ value: 'Bar' }] }),
|
|
231
316
|
],
|
|
232
|
-
})
|
|
317
|
+
}))
|
|
233
318
|
|
|
234
|
-
const result =
|
|
319
|
+
const result = database.searchBadges({ query: { str: 'oo' } })
|
|
235
320
|
expect(result.totalItems).toBe(1)
|
|
236
321
|
expect(result.items.map(x => x.key)).toStrictEqual(['foo'])
|
|
237
322
|
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BundleData } from '../main'
|
|
2
|
+
import { TEST_BADGE } from './api/badge-data.test'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* If you change this test, update the example in the README as well
|
|
6
|
+
*/
|
|
7
|
+
export const TEST_BUNDLE: BundleData = {
|
|
8
|
+
header: { name: 'My Content Bundle' },
|
|
9
|
+
badges: [TEST_BADGE],
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe('BundleData', () => {
|
|
13
|
+
test('should be a usable interface', () => {
|
|
14
|
+
expect(TEST_BUNDLE).not.toBeUndefined()
|
|
15
|
+
})
|
|
16
|
+
})
|
package/src/main/api/change.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { MarkdownString } from './markdown-string'
|
|
2
|
-
|
|
3
|
-
export interface Change {
|
|
4
|
-
/**
|
|
5
|
-
* The version number in {@link http://semver.org|semver} format.
|
|
6
|
-
*/
|
|
7
|
-
version: string
|
|
8
|
-
/**
|
|
9
|
-
* Date of the change.
|
|
10
|
-
*/
|
|
11
|
-
date: Date
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Description of the change.
|
|
15
|
-
*/
|
|
16
|
-
description: MarkdownString
|
|
17
|
-
}
|
package/src/main/changelog.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Change } from './api/change'
|
|
2
|
-
|
|
3
|
-
export const CHANGELOG: Change[] = [
|
|
4
|
-
{
|
|
5
|
-
version: '2.0.0',
|
|
6
|
-
date: new Date('2025-03-12'),
|
|
7
|
-
description: ''
|
|
8
|
-
+ '* Replaced redundant interfaces with their concrete equivalents.\n'
|
|
9
|
-
+ `* Server groups are now referred to as 'forks'.\n`
|
|
10
|
-
+ '* Replaced enums with union types and changed values to `kebab-case`.\n'
|
|
11
|
-
+ '* `IServerGroupData` is now `ContentBundle` and each database instance is now designed to accept only a single bundle.\n'
|
|
12
|
-
+ '* `GameMap` is now `Zone`.\n'
|
|
13
|
-
+ '* Removed the `serverGroup` property from entities to simplify the object tree given that only a single context can exist per db now.\n'
|
|
14
|
-
+ '* Added a simple indexing and search function for badge names, text and acquisition info.\n'
|
|
15
|
-
+ '* Zone and badge references now follow a standard Markdown link format with a `badge://` or `map://` protocol.\n'
|
|
16
|
-
+ '* Badge partials are now known as badge requirements.\n'
|
|
17
|
-
+ '* Removed the `VidiotMap` API as it was never used or fleshed out properly.\n'
|
|
18
|
-
+ '* Added formal support for Missions and Contacts in badge requirements.\n'
|
|
19
|
-
+ '* Move exploration badge locations into badge requirement list.\n'
|
|
20
|
-
+ '* Standardized pluralization of some field names (name, icon).\n'
|
|
21
|
-
+ '* Combined `settitle` ids into a single tuple field.\n'
|
|
22
|
-
+ '* Change from GNU to The Unlicense.\n'
|
|
23
|
-
+ '* Removed all third-party dependencies.\n'
|
|
24
|
-
+ '* Moved from webpack to rollup for packaging.\n'
|
|
25
|
-
+ '* Add eslint for linting.\n'
|
|
26
|
-
+ '* Add jest for unit tests.\n'
|
|
27
|
-
+ '* Added GitHub Actions for CI.\n',
|
|
28
|
-
},
|
|
29
|
-
]
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { ContentBundle } from '../api/content-bundle'
|
|
2
|
-
import { Change } from '../api/change'
|
|
3
|
-
import { Link } from '../api/link'
|
|
4
|
-
import { MarkdownString } from '../api/markdown-string'
|
|
5
|
-
|
|
6
|
-
export class BundleMetadata {
|
|
7
|
-
/**
|
|
8
|
-
* Name of the content bundle.
|
|
9
|
-
*/
|
|
10
|
-
readonly name: string
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Description of the fork.
|
|
14
|
-
*/
|
|
15
|
-
readonly description?: MarkdownString
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Repository where the db content package is maintained.
|
|
19
|
-
*/
|
|
20
|
-
readonly repository?: string
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* List of external links. Wiki, forums, etc.
|
|
24
|
-
*/
|
|
25
|
-
readonly links: Link[]
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Change log for this data package.
|
|
29
|
-
*/
|
|
30
|
-
readonly changelog: Change[]
|
|
31
|
-
|
|
32
|
-
constructor(bundle: ContentBundle) {
|
|
33
|
-
this.name = bundle.name
|
|
34
|
-
this.description = bundle.description
|
|
35
|
-
this.repository = bundle.repository
|
|
36
|
-
this.links = bundle.links ?? []
|
|
37
|
-
this.changelog = bundle.changelog ?? []
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ContentBundle } from '../../main'
|
|
2
|
-
import { TEST_BADGE } from './badge-data.test'
|
|
3
|
-
|
|
4
|
-
// If you change this test, update the example in the README as well
|
|
5
|
-
export const TEST_BUNDLE: ContentBundle = {
|
|
6
|
-
name: 'My Content Bundle',
|
|
7
|
-
badges: [TEST_BADGE],
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
describe('ContentBundle', () => {
|
|
11
|
-
test('should be a usable interface', () => {
|
|
12
|
-
expect(TEST_BUNDLE).not.toBeUndefined()
|
|
13
|
-
})
|
|
14
|
-
})
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { CHANGELOG } from '../main'
|
|
2
|
-
|
|
3
|
-
describe('CHANGELOG', () => {
|
|
4
|
-
test('should be extant', () => {
|
|
5
|
-
expect(CHANGELOG).not.toBeUndefined()
|
|
6
|
-
expect(CHANGELOG).not.toBeUndefined()
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
test('should be an array', () => {
|
|
10
|
-
expect(Array.isArray(CHANGELOG)).toBeTruthy()
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test('should have only semver versions', () => {
|
|
14
|
-
// semver.org - https://regex101.com/r/vkijKf/1/
|
|
15
|
-
const pattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
|
|
16
|
-
|
|
17
|
-
for (const change of CHANGELOG) {
|
|
18
|
-
expect(pattern.test(change.version)).toBeTruthy()
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
test('should have dates', () => {
|
|
23
|
-
for (const change of CHANGELOG) {
|
|
24
|
-
const date = change.date
|
|
25
|
-
expect(date).not.toBeUndefined()
|
|
26
|
-
expect(date).not.toBeUndefined()
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test('should have descriptions', () => {
|
|
31
|
-
for (const change of CHANGELOG) {
|
|
32
|
-
expect(change).not.toBeUndefined()
|
|
33
|
-
expect(change).not.toBeUndefined()
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
})
|