coh-content-db 2.0.0-rc.4 → 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 +31 -7
- package/dist/coh-content-db.d.ts +353 -185
- package/dist/coh-content-db.js +460 -300
- package/dist/coh-content-db.js.map +1 -1
- package/dist/coh-content-db.mjs +448 -294
- package/dist/coh-content-db.mjs.map +1 -1
- package/package.json +1 -4
- package/src/main/api/alternate-data.ts +2 -2
- package/src/main/api/badge-data.ts +21 -19
- package/src/main/api/badge-requirement-data.ts +82 -0
- package/src/main/api/badge-requirement-type.ts +11 -0
- package/src/main/api/change.ts +5 -2
- package/src/main/api/contact-data.ts +46 -0
- package/src/main/api/content-bundle.ts +12 -7
- package/src/main/api/markdown-string.ts +4 -0
- package/src/main/api/zone-data.ts +20 -0
- package/src/main/changelog.ts +7 -2
- package/src/main/db/alignments.ts +17 -0
- package/src/main/db/alternates.ts +8 -14
- package/src/main/db/badge-index.ts +93 -0
- package/src/main/db/badge-requirement.ts +102 -0
- package/src/main/db/badge-search-options.ts +51 -0
- package/src/main/db/badge.ts +55 -48
- package/src/main/db/bundle-metadata.ts +5 -6
- package/src/main/db/coh-content-database.ts +65 -40
- package/src/main/db/contact.ts +59 -0
- package/src/main/db/paged.ts +7 -0
- package/src/main/db/zone.ts +28 -0
- package/src/main/index.ts +15 -11
- package/src/main/util.ts +68 -7
- package/src/test/api/alignments.test.ts +40 -0
- 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/alternates.test.ts +16 -74
- package/src/test/db/badge-index.test.ts +520 -0
- 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 +125 -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 +6 -2
- package/src/test/util.test.ts +91 -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/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/badge-partial.ts +0 -35
- package/src/main/db/badge-search-document.ts +0 -16
- package/src/main/db/game-map.ts +0 -33
- 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/vidiot-map-point-of-interest.fixture.ts +0 -10
- package/src/test/api/vidiot-map.fixture.ts +0 -9
- package/src/test/db/badge-search-document.test.ts +0 -35
- package/src/test/db/coh-content-database-search.test.ts +0 -119
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Link } from '../api/link'
|
|
2
|
+
import { Key } from './key'
|
|
3
|
+
import { MarkdownString } from '../api/markdown-string'
|
|
4
|
+
import { ContactData } from '../api/contact-data'
|
|
5
|
+
|
|
6
|
+
export class Contact {
|
|
7
|
+
/**
|
|
8
|
+
* Unique key used to reference this contact.
|
|
9
|
+
*
|
|
10
|
+
* Keys can only contain lowercase letters, numbers and hyphens (`-`).
|
|
11
|
+
*/
|
|
12
|
+
readonly key: string
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The name of this contact.
|
|
16
|
+
*/
|
|
17
|
+
readonly name: string
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The contact's title.
|
|
21
|
+
*/
|
|
22
|
+
readonly title?: string
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The zone this character is located in.
|
|
26
|
+
*/
|
|
27
|
+
readonly zoneKey?: string
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The `/loc` coordinates of the contact.
|
|
31
|
+
*/
|
|
32
|
+
readonly loc?: [number, number, number]
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The level range this contact will offer missions for.
|
|
36
|
+
*/
|
|
37
|
+
readonly levelRange?: [number, number?]
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Freeform notes or tips about the contact.
|
|
41
|
+
*/
|
|
42
|
+
readonly notes?: MarkdownString
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* List of external links. Wiki, forums, etc.
|
|
46
|
+
*/
|
|
47
|
+
readonly links: Link[]
|
|
48
|
+
|
|
49
|
+
constructor(contactData: ContactData) {
|
|
50
|
+
this.key = new Key(contactData.key).value
|
|
51
|
+
this.name = contactData.name
|
|
52
|
+
this.title = contactData.title
|
|
53
|
+
this.zoneKey = contactData.zoneKey
|
|
54
|
+
this.loc = contactData.loc
|
|
55
|
+
this.levelRange = contactData.levelRange
|
|
56
|
+
this.notes = contactData.notes
|
|
57
|
+
this.links = contactData.links ?? []
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Link } from '../api/link'
|
|
2
|
+
import { ZoneData } from '../api/zone-data'
|
|
3
|
+
import { Key } from './key'
|
|
4
|
+
|
|
5
|
+
export class Zone {
|
|
6
|
+
/**
|
|
7
|
+
* Unique key used to reference this zone.
|
|
8
|
+
*
|
|
9
|
+
* Keys can only contain lowercase letters, numbers and hyphens (`-`).
|
|
10
|
+
*/
|
|
11
|
+
readonly key: string
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The name of the zone as it appears in-game.
|
|
15
|
+
*/
|
|
16
|
+
readonly name: string
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* List of external links. Wiki, forums, etc.
|
|
20
|
+
*/
|
|
21
|
+
readonly links: Link[]
|
|
22
|
+
|
|
23
|
+
constructor(data: ZoneData) {
|
|
24
|
+
this.key = new Key(data.key).value
|
|
25
|
+
this.name = data.name
|
|
26
|
+
this.links = data.links ?? []
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/main/index.ts
CHANGED
|
@@ -3,29 +3,33 @@ export * from './api/alignment'
|
|
|
3
3
|
export * from './api/alternate-data'
|
|
4
4
|
export * from './api/archetype-data'
|
|
5
5
|
export * from './api/badge-data'
|
|
6
|
-
export * from './api/badge-
|
|
7
|
-
export * from './api/badge-
|
|
6
|
+
export * from './api/badge-requirement-data'
|
|
7
|
+
export * from './api/badge-requirement-type'
|
|
8
8
|
export * from './api/badge-type'
|
|
9
9
|
export * from './api/change'
|
|
10
|
+
export * from './api/contact-data'
|
|
11
|
+
export * from './api/content-bundle'
|
|
10
12
|
export * from './api/enhancement-category'
|
|
11
|
-
export * from './api/game-map-data'
|
|
12
13
|
export * from './api/link'
|
|
14
|
+
export * from './api/markdown-string'
|
|
13
15
|
export * from './api/plaque-type'
|
|
14
|
-
export * from './api/content-bundle'
|
|
15
16
|
export * from './api/sex'
|
|
16
|
-
export * from './api/
|
|
17
|
-
export * from './api/vidiot-map-point-of-interest-data'
|
|
17
|
+
export * from './api/zone-data'
|
|
18
18
|
|
|
19
19
|
// DB
|
|
20
|
+
export * from './db/alignments'
|
|
21
|
+
export * from './db/alternates'
|
|
20
22
|
export * from './db/archetype'
|
|
21
23
|
export * from './db/badge'
|
|
22
|
-
export * from './db/badge-
|
|
24
|
+
export * from './db/badge-index'
|
|
25
|
+
export * from './db/badge-requirement'
|
|
26
|
+
export * from './db/badge-search-options'
|
|
27
|
+
export * from './db/bundle-metadata'
|
|
23
28
|
export * from './db/coh-content-database'
|
|
24
|
-
export * from './db/
|
|
29
|
+
export * from './db/contact'
|
|
25
30
|
export * from './db/key'
|
|
26
|
-
export * from './db/
|
|
27
|
-
export * from './db/
|
|
28
|
-
export * from './db/vidiot-map-point-of-interest'
|
|
31
|
+
export * from './db/paged'
|
|
32
|
+
export * from './db/zone'
|
|
29
33
|
|
|
30
34
|
// ROOT
|
|
31
35
|
export { CHANGELOG } from './changelog'
|
package/src/main/util.ts
CHANGED
|
@@ -1,17 +1,78 @@
|
|
|
1
|
+
import { BadgeData } from './api/badge-data'
|
|
2
|
+
import { Badge } from './db/badge'
|
|
3
|
+
import { ZoneData } from './api/zone-data'
|
|
4
|
+
import { Zone } from './db/zone'
|
|
5
|
+
import { Contact } from './db/contact'
|
|
6
|
+
import { ContactData } from './api/contact-data'
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
|
-
*
|
|
9
|
+
* Returns the URI of the given badge that can be used in {@link MarkdownString} links.
|
|
10
|
+
*
|
|
11
|
+
* URI format: `badge://<key>`
|
|
12
|
+
*
|
|
3
13
|
* @param target The badge or badge key to target.
|
|
4
14
|
*/
|
|
5
|
-
export function
|
|
15
|
+
export function badgeUri(target: string | Badge | BadgeData): string {
|
|
16
|
+
const key = typeof target === 'string' ? target : target.key
|
|
17
|
+
return `badge://${key}`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns a {@link MarkdownString} link to the given badge.
|
|
22
|
+
*
|
|
23
|
+
* Link format: `[<key>](badge://<key>)`
|
|
24
|
+
*
|
|
25
|
+
* @param target The {@link Badge} or badge key to target.
|
|
26
|
+
*/
|
|
27
|
+
export function badgeLink(target: string | Badge | BadgeData): string {
|
|
28
|
+
const key = typeof target === 'string' ? target : target.key
|
|
29
|
+
return `[${key}](${badgeUri(target)})`
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns the URI of the given contact that can be used in {@link MarkdownString} links.
|
|
34
|
+
*
|
|
35
|
+
* URI format: `contact://<key>`
|
|
36
|
+
*
|
|
37
|
+
* @param target The {@link Contact} or contact key to target.
|
|
38
|
+
*/
|
|
39
|
+
export function contactUri(target: string | Contact | ContactData): string {
|
|
40
|
+
const key = typeof target === 'string' ? target : target.key
|
|
41
|
+
return `contact://${key}`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Returns a {@link MarkdownString} link to the given contact.
|
|
46
|
+
*
|
|
47
|
+
* Link format: `[<key>](contact://<key>)`
|
|
48
|
+
*
|
|
49
|
+
* @param target The {@link Contact} or contact key to target.
|
|
50
|
+
*/
|
|
51
|
+
export function contactLink(target: string | Contact | ContactData): string {
|
|
52
|
+
const key = typeof target === 'string' ? target : target.key
|
|
53
|
+
return `[${key}](${contactUri(target)})`
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Returns the URI of the given zone that can be used in {@link MarkdownString} links.
|
|
58
|
+
*
|
|
59
|
+
* URI format: `zone://<key>`
|
|
60
|
+
*
|
|
61
|
+
* @param target The {@link Zone} or zone key to target.
|
|
62
|
+
*/
|
|
63
|
+
export function zoneUri(target: string | Zone | ZoneData): string {
|
|
6
64
|
const key = typeof target === 'string' ? target : target.key
|
|
7
|
-
return `
|
|
65
|
+
return `zone://${key}`
|
|
8
66
|
}
|
|
9
67
|
|
|
10
68
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
69
|
+
* Returns a {@link MarkdownString} link to the given zone.
|
|
70
|
+
*
|
|
71
|
+
* Link format: `[<key>](zone://<key>)`
|
|
72
|
+
*
|
|
73
|
+
* @param target The {@link Zone} or zone key to target.
|
|
13
74
|
*/
|
|
14
|
-
export function
|
|
75
|
+
export function zoneLink(target: string | Zone | ZoneData): string {
|
|
15
76
|
const key = typeof target === 'string' ? target : target.key
|
|
16
|
-
return `[
|
|
77
|
+
return `[${key}](${zoneUri(target)})`
|
|
17
78
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Alignments } from '../../main'
|
|
2
|
+
|
|
3
|
+
describe(Alignments.name, () => {
|
|
4
|
+
test('should return the raw array', () => {
|
|
5
|
+
expect(new Alignments(['H', 'V']).items).toStrictEqual(['H', 'V'])
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
test('should detect a hero', () => {
|
|
9
|
+
expect(new Alignments(['H', 'V']).hero).toBeTruthy()
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('should detect a villain', () => {
|
|
13
|
+
expect(new Alignments(['H', 'V']).villain).toBeTruthy()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
test('should detect a praetorian', () => {
|
|
17
|
+
expect(new Alignments(['H', 'V', 'P']).praetorian).toBeTruthy()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
test('should detect a primal', () => {
|
|
21
|
+
expect(new Alignments(['H', 'V']).primal).toBeTruthy()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
test('should not falsely detect a hero', () => {
|
|
25
|
+
expect(new Alignments(['V']).hero).toBeFalsy()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('should not falsely detect a villain', () => {
|
|
29
|
+
expect(new Alignments(['H']).villain).toBeFalsy()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test('should not falsely detect a praetorian', () => {
|
|
33
|
+
expect(new Alignments(['V']).praetorian).toBeFalsy()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
test('should falsely detect a primal', () => {
|
|
37
|
+
expect(new Alignments(['H', 'V', 'P']).primal).toBeFalsy()
|
|
38
|
+
expect(new Alignments(['P']).primal).toBeFalsy()
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineFixture } from 'efate'
|
|
2
2
|
import { ALIGNMENT, BADGE_TYPE, BadgeData } from '../../main'
|
|
3
|
-
import {
|
|
3
|
+
import { badgeRequirementDataFixture } from './badge-requirement-data.fixture'
|
|
4
4
|
|
|
5
5
|
export const badgeDataFixture = defineFixture<BadgeData>((t) => {
|
|
6
6
|
t.key.as(index => `badge-${index}`)
|
|
@@ -9,14 +9,16 @@ export const badgeDataFixture = defineFixture<BadgeData>((t) => {
|
|
|
9
9
|
t.alignment.pickFrom([...ALIGNMENT])
|
|
10
10
|
t.badgeText?.as(index => [{ value: `This is badge ${index}` }])
|
|
11
11
|
t.acquisition?.asLoremIpsum()
|
|
12
|
-
t.icon?.
|
|
12
|
+
t.icon?.as(() => [{ value: 'https://nouri.org' }])
|
|
13
13
|
t.notes?.asLoremIpsum()
|
|
14
|
-
t.links?.
|
|
15
|
-
t.
|
|
16
|
-
t.loc?.
|
|
14
|
+
t.links?.as(() => [{ href: 'https://nouri.org' }])
|
|
15
|
+
t.zoneKey?.asString()
|
|
16
|
+
t.loc?.as(index => [index, index, index])
|
|
17
17
|
t.vidiotMapKey?.asString()
|
|
18
|
-
t.setTitle?.
|
|
18
|
+
t.setTitle?.as((index) => {
|
|
19
|
+
return { id: index }
|
|
20
|
+
})
|
|
19
21
|
t.effect?.asString()
|
|
20
|
-
t.
|
|
22
|
+
t.requirements?.as(() => [[badgeRequirementDataFixture]])
|
|
21
23
|
t.ignoreInTotals?.asBoolean()
|
|
22
24
|
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineFixture } from 'efate'
|
|
2
|
+
import { BADGE_REQUIREMENT_TYPE, BadgeRequirementData, ENHANCEMENT_CATEGORY, PLAQUE_TYPE } from '../../main'
|
|
3
|
+
|
|
4
|
+
export const badgeRequirementDataFixture = defineFixture<BadgeRequirementData>((t) => {
|
|
5
|
+
t.key.as(index => `badge-requirement-${index}`)
|
|
6
|
+
t.type.pickFrom([...BADGE_REQUIREMENT_TYPE])
|
|
7
|
+
t.zoneKey?.asString()
|
|
8
|
+
t.loc?.as(index => [index, index, index])
|
|
9
|
+
t.plaqueType?.pickFrom([...PLAQUE_TYPE])
|
|
10
|
+
t.plaqueInscription?.asLoremIpsum()
|
|
11
|
+
t.vidiotMapKey?.asString()
|
|
12
|
+
t.badgeKey?.as(index => `badge-${index}`)
|
|
13
|
+
t.inventionLevel?.asNumber()
|
|
14
|
+
t.inventionTypes?.pickFrom([...ENHANCEMENT_CATEGORY])
|
|
15
|
+
t.inventionCount?.asNumber()
|
|
16
|
+
t.notes?.asLoremIpsum()
|
|
17
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BADGE_REQUIREMENT_TYPE, BadgeRequirementType } from '../../main'
|
|
2
|
+
|
|
3
|
+
describe('BADGE_REQUIREMENT_TYPE', () => {
|
|
4
|
+
test('should be an array', () => {
|
|
5
|
+
expect(Array.isArray(BADGE_REQUIREMENT_TYPE)).toBeTruthy()
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
test('should not be empty', () => {
|
|
9
|
+
expect(BADGE_REQUIREMENT_TYPE).not.toHaveLength(0)
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('should contain only strings', () => {
|
|
13
|
+
for (const entry of BADGE_REQUIREMENT_TYPE) {
|
|
14
|
+
expect(typeof entry).toBe('string')
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test('should contain all known badge requirement types', () => {
|
|
19
|
+
const expected = ['PLAQUE', 'BADGE', 'INVENTION', 'INVENTION_PLUS_ONE']
|
|
20
|
+
for (const category of expected) {
|
|
21
|
+
expect(BADGE_REQUIREMENT_TYPE).toContain(category)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
describe('BadgeRequirementType', () => {
|
|
27
|
+
test('should be a usable type', () => {
|
|
28
|
+
const field: BadgeRequirementType = 'PLAQUE'
|
|
29
|
+
expect(field).toBe('PLAQUE')
|
|
30
|
+
})
|
|
31
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineFixture } from 'efate'
|
|
2
|
+
import { ContactData } from '../../main'
|
|
3
|
+
|
|
4
|
+
export const contactDataFixture = defineFixture<ContactData>((t) => {
|
|
5
|
+
t.key.as(index => `contact-${index}`)
|
|
6
|
+
t.name.as(index => [{ value: `Contact ${index}` }])
|
|
7
|
+
t.title?.as(index => [{ value: `Contact title ${index}` }])
|
|
8
|
+
t.zoneKey?.asString()
|
|
9
|
+
t.loc?.as(index => [index, index, index])
|
|
10
|
+
t.levelRange?.as(index => [index, index])
|
|
11
|
+
t.notes?.asLoremIpsum()
|
|
12
|
+
t.links?.as(() => [{ href: 'https://nouri.org' }])
|
|
13
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineFixture } from 'efate'
|
|
2
2
|
import { Change, ContentBundle } from '../../main'
|
|
3
3
|
import { archetypeDataFixture } from './archetype-data.fixture'
|
|
4
|
-
import {
|
|
4
|
+
import { zoneDataFixture } from './zone-data.fixture'
|
|
5
5
|
import { badgeDataFixture } from './badge-data.fixture'
|
|
6
6
|
|
|
7
7
|
export const contentBundleFixture = defineFixture<ContentBundle>((t) => {
|
|
@@ -10,7 +10,7 @@ export const contentBundleFixture = defineFixture<ContentBundle>((t) => {
|
|
|
10
10
|
t.repository?.as(index => `https://nouri.org?id=${index}`)
|
|
11
11
|
t.servers?.asArray()
|
|
12
12
|
t.archetypes?.arrayOfFixture({ fixture: archetypeDataFixture })
|
|
13
|
-
t.
|
|
13
|
+
t.zones?.arrayOfFixture({ fixture: zoneDataFixture })
|
|
14
14
|
t.badges?.arrayOfFixture({ fixture: badgeDataFixture })
|
|
15
15
|
t.changelog?.arrayOfFixture({
|
|
16
16
|
fixture: defineFixture<Change>((t) => {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ZoneData } from '../../main'
|
|
2
|
+
import { defineFixture } from 'efate'
|
|
3
|
+
|
|
4
|
+
export const zoneDataFixture = defineFixture<ZoneData>((t) => {
|
|
5
|
+
t.key.as(index => `zone-${index}`)
|
|
6
|
+
t.name.as(index => `Zone ${index}`)
|
|
7
|
+
t.links?.as(() => [{ href: 'https://nouri.org' }])
|
|
8
|
+
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Alternates } from '../../main
|
|
1
|
+
import { Alternates } from '../../main'
|
|
2
2
|
|
|
3
3
|
describe(Alternates.name, () => {
|
|
4
4
|
describe('Constructor', () => {
|
|
@@ -89,7 +89,7 @@ describe(Alternates.name, () => {
|
|
|
89
89
|
{ alignment: 'H', value: 'Hero' },
|
|
90
90
|
{ alignment: 'V', sex: 'M', value: 'Male Villain' },
|
|
91
91
|
{ alignment: 'P', sex: 'F', value: 'Praetorian Female' },
|
|
92
|
-
]).default).toBe('Default')
|
|
92
|
+
]).default?.value).toBe('Default')
|
|
93
93
|
|
|
94
94
|
expect(new Alternates([
|
|
95
95
|
{ alignment: 'V', sex: 'M', value: 'Male Villain' },
|
|
@@ -97,14 +97,14 @@ describe(Alternates.name, () => {
|
|
|
97
97
|
{ sex: 'M', value: 'Male' },
|
|
98
98
|
{ value: 'Default' },
|
|
99
99
|
{ alignment: 'H', value: 'Hero' },
|
|
100
|
-
]).default).toBe('Default')
|
|
100
|
+
]).default?.value).toBe('Default')
|
|
101
101
|
|
|
102
102
|
expect(new Alternates([
|
|
103
103
|
{ alignment: 'V', sex: 'M', value: 'Male Villain' },
|
|
104
104
|
{ alignment: 'P', sex: 'F', value: 'Praetorian Female' },
|
|
105
105
|
{ sex: 'M', value: 'Male' },
|
|
106
106
|
{ alignment: 'H', value: 'Hero' },
|
|
107
|
-
]).default).toBe('Male')
|
|
107
|
+
]).default?.value).toBe('Male')
|
|
108
108
|
})
|
|
109
109
|
})
|
|
110
110
|
|
|
@@ -118,64 +118,30 @@ describe(Alternates.name, () => {
|
|
|
118
118
|
{ alignment: 'H', sex: 'F', value: 'Female Hero' },
|
|
119
119
|
{ alignment: 'P', value: 'Praetorian' },
|
|
120
120
|
{ sex: 'F', value: 'Female' },
|
|
121
|
-
{ alignment: 'H', sex: 'A', value: 'A Hero' },
|
|
122
|
-
{ alignment: 'Y', sex: 'A', value: 'A Y' },
|
|
123
121
|
{ alignment: 'V', sex: 'M', value: 'Male Villain' },
|
|
124
|
-
{ alignment: 'V', sex: 'B', value: 'B Villain' },
|
|
125
122
|
{ alignment: 'P', sex: 'M', value: 'Male Praetorian' },
|
|
126
123
|
{ alignment: 'H', value: 'Hero' },
|
|
127
|
-
{ alignment: 'V', sex: 'A', value: 'A Villain' },
|
|
128
|
-
{ sex: 'A', value: 'A Sex' },
|
|
129
|
-
{ alignment: 'X', sex: 'F', value: 'Female X' },
|
|
130
124
|
{ alignment: 'H', sex: 'M', value: 'Male Hero' },
|
|
131
|
-
{ alignment: 'X', value: 'X' },
|
|
132
|
-
{ alignment: 'P', sex: 'B', value: 'B Praetorian' },
|
|
133
|
-
{ alignment: 'P', sex: 'A', value: 'A Praetorian' },
|
|
134
|
-
{ alignment: 'X', sex: 'M', value: 'Male X' },
|
|
135
125
|
{ sex: 'M', value: 'Male' },
|
|
136
|
-
{ alignment: 'X', sex: 'B', value: 'B X' },
|
|
137
|
-
{ alignment: 'H', sex: 'B', value: 'B Hero' },
|
|
138
126
|
{ alignment: 'V', value: 'Villain' },
|
|
139
|
-
{ alignment: 'Y', sex: 'M', value: 'Male Y' },
|
|
140
127
|
{ alignment: 'V', sex: 'F', value: 'Female Villain' },
|
|
141
|
-
{ sex: 'B', value: 'B Sex' },
|
|
142
|
-
{ alignment: 'Y', sex: 'B', value: 'B Y' },
|
|
143
128
|
{ alignment: 'P', sex: 'F', value: 'Female Praetorian' },
|
|
144
|
-
{ alignment: 'X', sex: 'A', value: 'A X' },
|
|
145
129
|
{ value: 'Default' },
|
|
146
|
-
{ alignment: 'Y', sex: 'F', value: 'Female Y' },
|
|
147
130
|
]).canonical
|
|
148
131
|
|
|
149
132
|
expect(result).toStrictEqual([
|
|
150
133
|
{ value: 'Default' },
|
|
151
134
|
{ sex: 'M', value: 'Male' },
|
|
152
135
|
{ sex: 'F', value: 'Female' },
|
|
153
|
-
{ sex: 'A', value: 'A Sex' },
|
|
154
|
-
{ sex: 'B', value: 'B Sex' },
|
|
155
136
|
{ alignment: 'H', value: 'Hero' },
|
|
156
137
|
{ alignment: 'V', value: 'Villain' },
|
|
157
138
|
{ alignment: 'P', value: 'Praetorian' },
|
|
158
|
-
{ alignment: 'X', value: 'X' },
|
|
159
139
|
{ alignment: 'H', sex: 'M', value: 'Male Hero' },
|
|
160
140
|
{ alignment: 'H', sex: 'F', value: 'Female Hero' },
|
|
161
|
-
{ alignment: 'H', sex: 'A', value: 'A Hero' },
|
|
162
|
-
{ alignment: 'H', sex: 'B', value: 'B Hero' },
|
|
163
141
|
{ alignment: 'V', sex: 'M', value: 'Male Villain' },
|
|
164
142
|
{ alignment: 'V', sex: 'F', value: 'Female Villain' },
|
|
165
|
-
{ alignment: 'V', sex: 'A', value: 'A Villain' },
|
|
166
|
-
{ alignment: 'V', sex: 'B', value: 'B Villain' },
|
|
167
143
|
{ alignment: 'P', sex: 'M', value: 'Male Praetorian' },
|
|
168
144
|
{ alignment: 'P', sex: 'F', value: 'Female Praetorian' },
|
|
169
|
-
{ alignment: 'P', sex: 'A', value: 'A Praetorian' },
|
|
170
|
-
{ alignment: 'P', sex: 'B', value: 'B Praetorian' },
|
|
171
|
-
{ alignment: 'X', sex: 'M', value: 'Male X' },
|
|
172
|
-
{ alignment: 'X', sex: 'F', value: 'Female X' },
|
|
173
|
-
{ alignment: 'X', sex: 'A', value: 'A X' },
|
|
174
|
-
{ alignment: 'X', sex: 'B', value: 'B X' },
|
|
175
|
-
{ alignment: 'Y', sex: 'M', value: 'Male Y' },
|
|
176
|
-
{ alignment: 'Y', sex: 'F', value: 'Female Y' },
|
|
177
|
-
{ alignment: 'Y', sex: 'A', value: 'A Y' },
|
|
178
|
-
{ alignment: 'Y', sex: 'B', value: 'B Y' },
|
|
179
145
|
])
|
|
180
146
|
})
|
|
181
147
|
|
|
@@ -191,41 +157,17 @@ describe(Alternates.name, () => {
|
|
|
191
157
|
])
|
|
192
158
|
})
|
|
193
159
|
|
|
194
|
-
test('should sort identical values
|
|
160
|
+
test('should sort identical values by value alpha', () => {
|
|
195
161
|
expect(new Alternates([
|
|
196
|
-
{ value: '
|
|
197
|
-
{ value: '
|
|
198
|
-
{ value: '
|
|
199
|
-
{ value: '
|
|
200
|
-
]).canonical).toStrictEqual([
|
|
201
|
-
{ value: 'A' },
|
|
202
|
-
{ value: 'B' },
|
|
203
|
-
{ value: 'B' },
|
|
204
|
-
{ value: 'C' },
|
|
205
|
-
])
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
test('should sort unknown alignments by alpha', () => {
|
|
209
|
-
expect(new Alternates([
|
|
210
|
-
{ alignment: 'A', value: 'A' },
|
|
211
|
-
{ alignment: 'C', value: 'C' },
|
|
212
|
-
{ alignment: 'B', value: 'B' },
|
|
213
|
-
]).canonical).toStrictEqual([
|
|
214
|
-
{ alignment: 'A', value: 'A' },
|
|
215
|
-
{ alignment: 'B', value: 'B' },
|
|
216
|
-
{ alignment: 'C', value: 'C' },
|
|
217
|
-
])
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
test('should sort unknown sex by alpha', () => {
|
|
221
|
-
expect(new Alternates([
|
|
222
|
-
{ sex: 'A', value: 'A' },
|
|
223
|
-
{ sex: 'C', value: 'C' },
|
|
224
|
-
{ sex: 'B', value: 'B' },
|
|
162
|
+
{ alignment: 'V', value: 'B' },
|
|
163
|
+
{ sex: 'M', value: 'D' },
|
|
164
|
+
{ alignment: 'V', value: 'A' },
|
|
165
|
+
{ sex: 'M', value: 'C' },
|
|
225
166
|
]).canonical).toStrictEqual([
|
|
226
|
-
{ sex: '
|
|
227
|
-
{ sex: '
|
|
228
|
-
{
|
|
167
|
+
{ sex: 'M', value: 'C' },
|
|
168
|
+
{ sex: 'M', value: 'D' },
|
|
169
|
+
{ alignment: 'V', value: 'A' },
|
|
170
|
+
{ alignment: 'V', value: 'B' },
|
|
229
171
|
])
|
|
230
172
|
})
|
|
231
173
|
})
|
|
@@ -233,9 +175,9 @@ describe(Alternates.name, () => {
|
|
|
233
175
|
describe('toString', () => {
|
|
234
176
|
test('should create a string separated by the separator', () => {
|
|
235
177
|
expect(new Alternates([
|
|
236
|
-
{ sex: '
|
|
237
|
-
{ sex: '
|
|
238
|
-
{
|
|
178
|
+
{ sex: 'M', value: 'A' },
|
|
179
|
+
{ sex: 'F', value: 'B' },
|
|
180
|
+
{ alignment: 'H', value: 'C' },
|
|
239
181
|
]).toString(', ')).toBe('A, B, C')
|
|
240
182
|
})
|
|
241
183
|
})
|