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.
- package/.github/workflows/build.yml +1 -1
- package/.github/workflows/pull-request.yml +1 -1
- package/.github/workflows/release.yml +1 -1
- package/README.md +3 -3
- package/dist/coh-content-db.d.ts +444 -194
- package/dist/coh-content-db.js +720 -413
- package/dist/coh-content-db.js.map +1 -1
- package/dist/coh-content-db.mjs +708 -412
- 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/badge-data.ts +12 -42
- package/src/main/api/badge-requirement-data.ts +17 -35
- package/src/main/api/badge-requirement-type.ts +28 -7
- package/src/main/api/badge-type.ts +15 -15
- package/src/main/api/contact-data.ts +7 -5
- package/src/main/api/content-bundle.ts +6 -0
- package/src/main/api/enhancement-category.ts +26 -26
- package/src/main/api/location-data.ts +28 -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 +1 -1
- package/src/main/changelog.ts +5 -4
- package/src/main/db/abstract-index.ts +41 -0
- package/src/main/db/alignment-list.ts +54 -0
- package/src/main/db/alternates.ts +15 -32
- package/src/main/db/badge-index.ts +14 -50
- package/src/main/db/badge-requirement.ts +22 -43
- package/src/main/db/badge-search-options.ts +4 -4
- package/src/main/db/badge.ts +53 -54
- package/src/main/db/bundle-metadata.ts +8 -2
- package/src/main/db/coh-content-database.ts +80 -67
- package/src/main/db/contact.ts +17 -14
- 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/zone.ts +1 -1
- package/src/main/index.ts +8 -3
- package/src/main/util.ts +43 -3
- package/src/test/api/alignment.test.ts +38 -4
- package/src/test/api/badge-data.fixture.ts +1 -17
- package/src/test/api/badge-data.test.ts +3 -3
- package/src/test/api/badge-requirement-data.fixture.ts +1 -11
- package/src/test/api/badge-requirement-type.test.ts +3 -3
- package/src/test/api/badge-type.test.ts +5 -5
- package/src/test/api/contact-data.fixture.ts +0 -6
- package/src/test/api/content-bundle.fixture.ts +1 -17
- 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 +1 -1
- package/src/test/db/abstract-index.test.ts +86 -0
- package/src/test/db/alignment-list.test.ts +200 -0
- package/src/test/db/alternates.test.ts +60 -56
- package/src/test/db/badge-index.test.ts +220 -183
- package/src/test/db/badge-requirement.test.ts +35 -70
- package/src/test/db/badge.test.ts +185 -64
- package/src/test/db/bundle-metadata.test.ts +17 -0
- package/src/test/db/coh-content-database.test.ts +193 -119
- package/src/test/db/contact.test.ts +25 -24
- 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 +4 -4
- package/src/test/util.test.ts +54 -1
- package/src/main/api/plaque-type.ts +0 -6
- package/src/main/db/alignments.ts +0 -17
- package/src/test/api/alignments.test.ts +0 -40
- package/src/test/api/plaque-type.test.ts +0 -31
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { AbstractIndex } from '../../main/db/abstract-index'
|
|
2
|
+
|
|
3
|
+
interface TestObject {
|
|
4
|
+
key: string
|
|
5
|
+
otherValue: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
describe(AbstractIndex.name, () => {
|
|
9
|
+
describe('Constructor', () => {
|
|
10
|
+
test(`should accept the key field`, () => {
|
|
11
|
+
new AbstractIndex<TestObject>('key')
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
describe('value', () => {
|
|
16
|
+
test(`should return the original values`, () => {
|
|
17
|
+
const values = [
|
|
18
|
+
{ key: '1', otherValue: 1 },
|
|
19
|
+
{ key: '2', otherValue: 2 },
|
|
20
|
+
]
|
|
21
|
+
const index = new AbstractIndex<TestObject>('key')
|
|
22
|
+
index.load(values)
|
|
23
|
+
|
|
24
|
+
expect(index.values).toStrictEqual(values)
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
describe('get', () => {
|
|
29
|
+
test(`should return the indexed value on match`, () => {
|
|
30
|
+
const index = new AbstractIndex<TestObject>('key')
|
|
31
|
+
index.load([
|
|
32
|
+
{ key: '1', otherValue: 1 },
|
|
33
|
+
{ key: '2', otherValue: 2 },
|
|
34
|
+
])
|
|
35
|
+
|
|
36
|
+
expect(index.get('2')).toStrictEqual({ key: '2', otherValue: 2 })
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test(`should return undefined on no match`, () => {
|
|
40
|
+
const index = new AbstractIndex<TestObject>('key')
|
|
41
|
+
|
|
42
|
+
expect(index.get('2')).toBeUndefined()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
test(`should return undefined on undefined key`, () => {
|
|
46
|
+
const index = new AbstractIndex<TestObject>('key')
|
|
47
|
+
const key = undefined
|
|
48
|
+
expect(index.get(key)).toBeUndefined()
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
describe('load', () => {
|
|
53
|
+
test(`should reset the index when used`, () => {
|
|
54
|
+
const index = new AbstractIndex<TestObject>('key')
|
|
55
|
+
index.load([
|
|
56
|
+
{ key: '1', otherValue: 1 },
|
|
57
|
+
{ key: '2', otherValue: 2 },
|
|
58
|
+
])
|
|
59
|
+
|
|
60
|
+
expect(index.get('2')).toStrictEqual({ key: '2', otherValue: 2 })
|
|
61
|
+
|
|
62
|
+
index.load([
|
|
63
|
+
{ key: '3', otherValue: 3 },
|
|
64
|
+
])
|
|
65
|
+
expect(index.get('1')).toBeUndefined()
|
|
66
|
+
expect(index.get('2')).toBeUndefined()
|
|
67
|
+
expect(index.get('3')).toStrictEqual({ key: '3', otherValue: 3 })
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
test(`should accept an undefined value`, () => {
|
|
71
|
+
const index = new AbstractIndex<TestObject>('key')
|
|
72
|
+
const values = undefined
|
|
73
|
+
index.load(values)
|
|
74
|
+
|
|
75
|
+
expect(index.values).toHaveLength(0)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test(`should throw an error on duplicate key`, () => {
|
|
79
|
+
const index = new AbstractIndex<TestObject>('key')
|
|
80
|
+
expect(() => index.load([
|
|
81
|
+
{ key: '1', otherValue: 1 },
|
|
82
|
+
{ key: '1', otherValue: 1 },
|
|
83
|
+
])).toThrow('Duplicate key [1]')
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
})
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { AlignmentList } from '../../main'
|
|
2
|
+
|
|
3
|
+
describe(AlignmentList.name, () => {
|
|
4
|
+
describe('items', () => {
|
|
5
|
+
test('should return the basic set', () => {
|
|
6
|
+
expect(new AlignmentList(['hero', 'villain']).items).toStrictEqual(['hero', 'villain'])
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test('should collapse extended values', () => {
|
|
10
|
+
expect(new AlignmentList(['primal']).items).toStrictEqual(['hero', 'villain'])
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('should not duplicate overlaps', () => {
|
|
14
|
+
expect(new AlignmentList(['primal', 'all', 'hero']).items).toStrictEqual(['hero', 'villain', 'praetorian'])
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
test('should have deterministic order', () => {
|
|
18
|
+
expect(new AlignmentList(['hero', 'villain']).items).toStrictEqual(['hero', 'villain'])
|
|
19
|
+
expect(new AlignmentList(['villain', 'hero']).items).toStrictEqual(['hero', 'villain'])
|
|
20
|
+
expect(new AlignmentList(['primal', 'all', 'hero']).items).toStrictEqual(['hero', 'villain', 'praetorian'])
|
|
21
|
+
expect(new AlignmentList(['hero', 'primal', 'all']).items).toStrictEqual(['hero', 'villain', 'praetorian'])
|
|
22
|
+
expect(new AlignmentList(['all', 'hero', 'primal']).items).toStrictEqual(['hero', 'villain', 'praetorian'])
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test('should treat undefined as all values', () => {
|
|
26
|
+
expect(new AlignmentList().items).toStrictEqual(['hero', 'villain', 'praetorian'])
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test('should treat empty as no values', () => {
|
|
30
|
+
expect(new AlignmentList([]).items).toStrictEqual([])
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
describe('values', () => {
|
|
35
|
+
test('should all be true when undefined', () => {
|
|
36
|
+
const alignments = new AlignmentList()
|
|
37
|
+
expect(alignments.hero).toBeTruthy()
|
|
38
|
+
expect(alignments.villain).toBeTruthy()
|
|
39
|
+
expect(alignments.praetorian).toBeTruthy()
|
|
40
|
+
expect(alignments.primal).toBeTruthy()
|
|
41
|
+
expect(alignments.all).toBeTruthy()
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test('should all be false when empty', () => {
|
|
45
|
+
const alignments = new AlignmentList([])
|
|
46
|
+
expect(alignments.hero).toBeFalsy()
|
|
47
|
+
expect(alignments.villain).toBeFalsy()
|
|
48
|
+
expect(alignments.praetorian).toBeFalsy()
|
|
49
|
+
expect(alignments.primal).toBeFalsy()
|
|
50
|
+
expect(alignments.all).toBeFalsy()
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
describe('hero', () => {
|
|
55
|
+
test('should detect a hero', () => {
|
|
56
|
+
expect(new AlignmentList(['hero', 'villain']).hero).toBeTruthy()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('should detect primal', () => {
|
|
60
|
+
expect(new AlignmentList(['primal']).hero).toBeTruthy()
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test('should detect all', () => {
|
|
64
|
+
expect(new AlignmentList(['all']).hero).toBeTruthy()
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test('should not falsely detect a hero', () => {
|
|
68
|
+
expect(new AlignmentList(['villain']).hero).toBeFalsy()
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
describe('villain', () => {
|
|
73
|
+
test('should detect a villain', () => {
|
|
74
|
+
expect(new AlignmentList(['hero', 'villain']).villain).toBeTruthy()
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
test('should detect primal', () => {
|
|
78
|
+
expect(new AlignmentList(['primal']).villain).toBeTruthy()
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
test('should detect all', () => {
|
|
82
|
+
expect(new AlignmentList(['all']).villain).toBeTruthy()
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test('should not falsely detect a villain', () => {
|
|
86
|
+
expect(new AlignmentList(['hero']).villain).toBeFalsy()
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
describe('praetorian', () => {
|
|
91
|
+
test('should detect a praetorian', () => {
|
|
92
|
+
expect(new AlignmentList(['hero', 'praetorian']).praetorian).toBeTruthy()
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
test('should not detect primal', () => {
|
|
96
|
+
expect(new AlignmentList(['primal']).praetorian).toBeFalsy()
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
test('should detect all', () => {
|
|
100
|
+
expect(new AlignmentList(['all']).praetorian).toBeTruthy()
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
test('should not falsely detect a praetorian', () => {
|
|
104
|
+
expect(new AlignmentList(['villain']).praetorian).toBeFalsy()
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
describe('primal', () => {
|
|
109
|
+
test('should detect hero and villain', () => {
|
|
110
|
+
expect(new AlignmentList(['hero', 'villain']).primal).toBeTruthy()
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
test('should detect primal', () => {
|
|
114
|
+
expect(new AlignmentList(['primal']).primal).toBeTruthy()
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
test('should detect all', () => {
|
|
118
|
+
expect(new AlignmentList(['all']).primal).toBeTruthy()
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
test('should not falsely detect a primal', () => {
|
|
122
|
+
expect(new AlignmentList(['villain']).primal).toBeFalsy()
|
|
123
|
+
expect(new AlignmentList(['praetorian']).primal).toBeFalsy()
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
describe('all', () => {
|
|
128
|
+
test('should detect when all are present', () => {
|
|
129
|
+
expect(new AlignmentList(['hero', 'villain', 'praetorian']).all).toBeTruthy()
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
test('should detect primal and praetorian', () => {
|
|
133
|
+
expect(new AlignmentList(['primal', 'praetorian']).all).toBeTruthy()
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
test('should detect all', () => {
|
|
137
|
+
expect(new AlignmentList(['all']).all).toBeTruthy()
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
test('should not falsely detect all', () => {
|
|
141
|
+
expect(new AlignmentList(['villain']).all).toBeFalsy()
|
|
142
|
+
expect(new AlignmentList(['praetorian']).all).toBeFalsy()
|
|
143
|
+
expect(new AlignmentList(['primal']).all).toBeFalsy()
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
describe('has', () => {
|
|
148
|
+
test('should return true if present', () => {
|
|
149
|
+
expect(new AlignmentList(['villain']).has('villain')).toBeTruthy()
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
test('should return false if absent', () => {
|
|
153
|
+
expect(new AlignmentList(['hero']).has('villain')).toBeFalsy()
|
|
154
|
+
expect(new AlignmentList(['hero', 'praetorian']).has('primal')).toBeFalsy()
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
test('should return false if undefined', () => {
|
|
158
|
+
expect(new AlignmentList(['hero']).has()).toBeFalsy()
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
test('should test hero correctly', () => {
|
|
162
|
+
expect(new AlignmentList(['hero']).has('hero')).toBeTruthy()
|
|
163
|
+
expect(new AlignmentList(['primal']).has('hero')).toBeTruthy()
|
|
164
|
+
expect(new AlignmentList(['all']).has('hero')).toBeTruthy()
|
|
165
|
+
|
|
166
|
+
expect(new AlignmentList(['villain']).has('hero')).toBeFalsy()
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
test('should test villain correctly', () => {
|
|
170
|
+
expect(new AlignmentList(['villain']).has('villain')).toBeTruthy()
|
|
171
|
+
expect(new AlignmentList(['primal']).has('villain')).toBeTruthy()
|
|
172
|
+
expect(new AlignmentList(['all']).has('villain')).toBeTruthy()
|
|
173
|
+
|
|
174
|
+
expect(new AlignmentList(['hero']).has('villain')).toBeFalsy()
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
test('should test praetorian correctly', () => {
|
|
178
|
+
expect(new AlignmentList(['praetorian']).has('praetorian')).toBeTruthy()
|
|
179
|
+
expect(new AlignmentList(['all']).has('praetorian')).toBeTruthy()
|
|
180
|
+
|
|
181
|
+
expect(new AlignmentList(['villain']).has('praetorian')).toBeFalsy()
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
test('should test primal correctly', () => {
|
|
185
|
+
expect(new AlignmentList(['hero', 'villain']).has('primal')).toBeTruthy()
|
|
186
|
+
expect(new AlignmentList(['primal']).has('primal')).toBeTruthy()
|
|
187
|
+
expect(new AlignmentList(['all']).has('primal')).toBeTruthy()
|
|
188
|
+
|
|
189
|
+
expect(new AlignmentList(['praetorian']).has('primal')).toBeFalsy()
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
test('should test all correctly', () => {
|
|
193
|
+
expect(new AlignmentList(['hero', 'villain', 'praetorian']).has('all')).toBeTruthy()
|
|
194
|
+
expect(new AlignmentList(['primal', 'praetorian']).has('all')).toBeTruthy()
|
|
195
|
+
expect(new AlignmentList(['all']).has('all')).toBeTruthy()
|
|
196
|
+
|
|
197
|
+
expect(new AlignmentList([]).has('all')).toBeFalsy()
|
|
198
|
+
})
|
|
199
|
+
})
|
|
200
|
+
})
|
|
@@ -6,11 +6,15 @@ describe(Alternates.name, () => {
|
|
|
6
6
|
new Alternates([
|
|
7
7
|
{ value: 'Default' },
|
|
8
8
|
{ sex: 'M', value: 'Male' },
|
|
9
|
-
{ alignment: '
|
|
10
|
-
{ alignment: '
|
|
11
|
-
{ alignment: '
|
|
9
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
10
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
11
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
12
12
|
])
|
|
13
13
|
})
|
|
14
|
+
|
|
15
|
+
test('should accept a single value', () => {
|
|
16
|
+
expect(new Alternates('foo').default?.value).toBe('foo')
|
|
17
|
+
})
|
|
14
18
|
})
|
|
15
19
|
|
|
16
20
|
describe('getValue', () => {
|
|
@@ -22,19 +26,19 @@ describe(Alternates.name, () => {
|
|
|
22
26
|
expect(new Alternates([
|
|
23
27
|
{ value: 'Default' },
|
|
24
28
|
{ sex: 'M', value: 'Male' },
|
|
25
|
-
{ alignment: '
|
|
26
|
-
{ alignment: '
|
|
27
|
-
{ alignment: '
|
|
29
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
30
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
31
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
28
32
|
]).getValue()).toBe('Default')
|
|
29
33
|
})
|
|
30
34
|
|
|
31
35
|
test('should return the least-specific value when no classifiers are provided, regardless of insert order', () => {
|
|
32
36
|
expect(new Alternates([
|
|
33
|
-
{ alignment: '
|
|
34
|
-
{ alignment: '
|
|
37
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
38
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
35
39
|
{ value: 'Default' },
|
|
36
40
|
{ sex: 'M', value: 'Male' },
|
|
37
|
-
{ alignment: '
|
|
41
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
38
42
|
]).getValue()).toBe('Default')
|
|
39
43
|
})
|
|
40
44
|
|
|
@@ -42,37 +46,37 @@ describe(Alternates.name, () => {
|
|
|
42
46
|
expect(new Alternates([
|
|
43
47
|
{ value: 'Default' },
|
|
44
48
|
{ sex: 'M', value: 'Male' },
|
|
45
|
-
{ alignment: '
|
|
46
|
-
{ alignment: '
|
|
47
|
-
{ alignment: '
|
|
48
|
-
]).getValue('
|
|
49
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
50
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
51
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
52
|
+
]).getValue('villain', 'M')).toBe('Male Villain')
|
|
49
53
|
})
|
|
50
54
|
|
|
51
55
|
test('should return the most specific match, regardless of insert order', () => {
|
|
52
56
|
expect(new Alternates([
|
|
53
|
-
{ alignment: '
|
|
57
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
54
58
|
{ sex: 'M', value: 'Male' },
|
|
55
|
-
{ alignment: '
|
|
56
|
-
{ alignment: '
|
|
59
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
60
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
57
61
|
{ value: 'Default' },
|
|
58
|
-
]).getValue('
|
|
62
|
+
]).getValue('villain', 'M')).toBe('Male Villain')
|
|
59
63
|
})
|
|
60
64
|
|
|
61
65
|
test('should return the lowest canonical value if there is no default', () => {
|
|
62
66
|
expect(new Alternates([
|
|
63
|
-
{ alignment: '
|
|
67
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
64
68
|
{ sex: 'M', value: 'Male' },
|
|
65
|
-
{ alignment: '
|
|
66
|
-
{ alignment: '
|
|
69
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
70
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
67
71
|
]).getValue()).toBe('Male')
|
|
68
72
|
})
|
|
69
73
|
|
|
70
74
|
test('should return the lowest canonical value if a specific is requested that does not exist', () => {
|
|
71
75
|
expect(new Alternates([
|
|
72
|
-
{ alignment: '
|
|
73
|
-
{ alignment: '
|
|
74
|
-
{ alignment: '
|
|
75
|
-
{ alignment: '
|
|
76
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
77
|
+
{ alignment: 'villain', value: 'Villain' },
|
|
78
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
79
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
76
80
|
]).getValue(undefined, 'F')).toBe('Hero')
|
|
77
81
|
})
|
|
78
82
|
})
|
|
@@ -86,24 +90,24 @@ describe(Alternates.name, () => {
|
|
|
86
90
|
expect(new Alternates([
|
|
87
91
|
{ value: 'Default' },
|
|
88
92
|
{ sex: 'M', value: 'Male' },
|
|
89
|
-
{ alignment: '
|
|
90
|
-
{ alignment: '
|
|
91
|
-
{ alignment: '
|
|
93
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
94
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
95
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
92
96
|
]).default?.value).toBe('Default')
|
|
93
97
|
|
|
94
98
|
expect(new Alternates([
|
|
95
|
-
{ alignment: '
|
|
96
|
-
{ alignment: '
|
|
99
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
100
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
97
101
|
{ sex: 'M', value: 'Male' },
|
|
98
102
|
{ value: 'Default' },
|
|
99
|
-
{ alignment: '
|
|
103
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
100
104
|
]).default?.value).toBe('Default')
|
|
101
105
|
|
|
102
106
|
expect(new Alternates([
|
|
103
|
-
{ alignment: '
|
|
104
|
-
{ alignment: '
|
|
107
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
108
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Praetorian Female' },
|
|
105
109
|
{ sex: 'M', value: 'Male' },
|
|
106
|
-
{ alignment: '
|
|
110
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
107
111
|
]).default?.value).toBe('Male')
|
|
108
112
|
})
|
|
109
113
|
})
|
|
@@ -115,17 +119,17 @@ describe(Alternates.name, () => {
|
|
|
115
119
|
|
|
116
120
|
test('should return values sorted in canonical order', () => {
|
|
117
121
|
const result = new Alternates([
|
|
118
|
-
{ alignment: '
|
|
119
|
-
{ alignment: '
|
|
122
|
+
{ alignment: 'hero', sex: 'F', value: 'Female Hero' },
|
|
123
|
+
{ alignment: 'praetorian', value: 'Praetorian' },
|
|
120
124
|
{ sex: 'F', value: 'Female' },
|
|
121
|
-
{ alignment: '
|
|
122
|
-
{ alignment: '
|
|
123
|
-
{ alignment: '
|
|
124
|
-
{ alignment: '
|
|
125
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
126
|
+
{ alignment: 'praetorian', sex: 'M', value: 'Male Praetorian' },
|
|
127
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
128
|
+
{ alignment: 'hero', sex: 'M', value: 'Male Hero' },
|
|
125
129
|
{ sex: 'M', value: 'Male' },
|
|
126
|
-
{ alignment: '
|
|
127
|
-
{ alignment: '
|
|
128
|
-
{ alignment: '
|
|
130
|
+
{ alignment: 'villain', value: 'Villain' },
|
|
131
|
+
{ alignment: 'villain', sex: 'F', value: 'Female Villain' },
|
|
132
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Female Praetorian' },
|
|
129
133
|
{ value: 'Default' },
|
|
130
134
|
]).canonical
|
|
131
135
|
|
|
@@ -133,15 +137,15 @@ describe(Alternates.name, () => {
|
|
|
133
137
|
{ value: 'Default' },
|
|
134
138
|
{ sex: 'M', value: 'Male' },
|
|
135
139
|
{ sex: 'F', value: 'Female' },
|
|
136
|
-
{ alignment: '
|
|
137
|
-
{ alignment: '
|
|
138
|
-
{ alignment: '
|
|
139
|
-
{ alignment: '
|
|
140
|
-
{ alignment: '
|
|
141
|
-
{ alignment: '
|
|
142
|
-
{ alignment: '
|
|
143
|
-
{ alignment: '
|
|
144
|
-
{ alignment: '
|
|
140
|
+
{ alignment: 'hero', value: 'Hero' },
|
|
141
|
+
{ alignment: 'villain', value: 'Villain' },
|
|
142
|
+
{ alignment: 'praetorian', value: 'Praetorian' },
|
|
143
|
+
{ alignment: 'hero', sex: 'M', value: 'Male Hero' },
|
|
144
|
+
{ alignment: 'hero', sex: 'F', value: 'Female Hero' },
|
|
145
|
+
{ alignment: 'villain', sex: 'M', value: 'Male Villain' },
|
|
146
|
+
{ alignment: 'villain', sex: 'F', value: 'Female Villain' },
|
|
147
|
+
{ alignment: 'praetorian', sex: 'M', value: 'Male Praetorian' },
|
|
148
|
+
{ alignment: 'praetorian', sex: 'F', value: 'Female Praetorian' },
|
|
145
149
|
])
|
|
146
150
|
})
|
|
147
151
|
|
|
@@ -159,15 +163,15 @@ describe(Alternates.name, () => {
|
|
|
159
163
|
|
|
160
164
|
test('should sort identical values by value alpha', () => {
|
|
161
165
|
expect(new Alternates([
|
|
162
|
-
{ alignment: '
|
|
166
|
+
{ alignment: 'villain', value: 'B' },
|
|
163
167
|
{ sex: 'M', value: 'D' },
|
|
164
|
-
{ alignment: '
|
|
168
|
+
{ alignment: 'villain', value: 'A' },
|
|
165
169
|
{ sex: 'M', value: 'C' },
|
|
166
170
|
]).canonical).toStrictEqual([
|
|
167
171
|
{ sex: 'M', value: 'C' },
|
|
168
172
|
{ sex: 'M', value: 'D' },
|
|
169
|
-
{ alignment: '
|
|
170
|
-
{ alignment: '
|
|
173
|
+
{ alignment: 'villain', value: 'A' },
|
|
174
|
+
{ alignment: 'villain', value: 'B' },
|
|
171
175
|
])
|
|
172
176
|
})
|
|
173
177
|
})
|
|
@@ -177,7 +181,7 @@ describe(Alternates.name, () => {
|
|
|
177
181
|
expect(new Alternates([
|
|
178
182
|
{ sex: 'M', value: 'A' },
|
|
179
183
|
{ sex: 'F', value: 'B' },
|
|
180
|
-
{ alignment: '
|
|
184
|
+
{ alignment: 'hero', value: 'C' },
|
|
181
185
|
]).toString(', ')).toBe('A, B, C')
|
|
182
186
|
})
|
|
183
187
|
})
|