coh-content-db 2.0.0-rc.4 → 2.0.0-rc.5

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.
Files changed (37) hide show
  1. package/README.md +28 -4
  2. package/dist/coh-content-db.d.ts +189 -68
  3. package/dist/coh-content-db.js +323 -229
  4. package/dist/coh-content-db.js.map +1 -1
  5. package/dist/coh-content-db.mjs +317 -228
  6. package/dist/coh-content-db.mjs.map +1 -1
  7. package/package.json +1 -4
  8. package/src/main/api/alternate-data.ts +2 -2
  9. package/src/main/api/badge-data.ts +5 -10
  10. package/src/main/api/badge-partial-data.ts +6 -5
  11. package/src/main/api/change.ts +5 -2
  12. package/src/main/api/content-bundle.ts +2 -3
  13. package/src/main/api/markdown-string.ts +4 -0
  14. package/src/main/api/vidiot-map-point-of-interest-data.ts +3 -3
  15. package/src/main/changelog.ts +3 -2
  16. package/src/main/db/alignments.ts +17 -0
  17. package/src/main/db/alternates.ts +8 -14
  18. package/src/main/db/badge-index.ts +87 -0
  19. package/src/main/db/badge-partial.ts +54 -6
  20. package/src/main/db/badge-search-options.ts +51 -0
  21. package/src/main/db/badge.ts +8 -13
  22. package/src/main/db/bundle-metadata.ts +2 -3
  23. package/src/main/db/coh-content-database.ts +17 -25
  24. package/src/main/db/paged.ts +7 -0
  25. package/src/main/db/vidiot-map-point-of-interest.ts +2 -3
  26. package/src/main/index.ts +7 -1
  27. package/src/main/util.ts +36 -6
  28. package/src/test/api/alignments.test.ts +40 -0
  29. package/src/test/api/badge-partial-data.fixture.ts +1 -1
  30. package/src/test/db/alternates.test.ts +16 -74
  31. package/src/test/db/badge-index.test.ts +488 -0
  32. package/src/test/db/coh-content-database.test.ts +15 -0
  33. package/src/test/index.test.ts +4 -2
  34. package/src/test/util.test.ts +49 -13
  35. package/src/main/db/badge-search-document.ts +0 -16
  36. package/src/test/db/badge-search-document.test.ts +0 -35
  37. package/src/test/db/coh-content-database-search.test.ts +0 -119
@@ -1,119 +0,0 @@
1
- import { CohContentDatabase } from '../../main'
2
- import { contentBundleFixture } from '../api/content-bundle.fixture'
3
- import { badgeDataFixture } from '../api/badge-data.fixture'
4
-
5
- describe(CohContentDatabase.name, () => {
6
- describe('searchBadges', () => {
7
- test(`should match on badge name`, () => {
8
- const data = contentBundleFixture.create({
9
- badges: [
10
- badgeDataFixture.create({ key: 'match-1', name: [{ value: 'Foo 1' }] }),
11
- badgeDataFixture.create({ key: 'match-2', name: [{ value: 'Foo 2' }, { value: 'Bar 2' }] }),
12
- badgeDataFixture.create({ key: 'match-3', name: [{ value: 'Bar 3' }, { value: 'Foo 3' }] }),
13
- badgeDataFixture.create({ key: 'miss-1', name: [{ value: 'Bar 4' }] }),
14
- ],
15
- })
16
-
17
- const result = new CohContentDatabase(data).searchBadges('Foo')
18
-
19
- expect(result).toHaveLength(3)
20
- const keys = result.map(x => x.key)
21
- expect(keys).toContain('match-1')
22
- expect(keys).toContain('match-2')
23
- expect(keys).toContain('match-3')
24
- expect(keys).not.toContainEqual(['miss-1'])
25
- })
26
-
27
- test(`should match on badge text`, () => {
28
- const data = contentBundleFixture.create({
29
- badges: [
30
- badgeDataFixture.create({ key: 'match-1', badgeText: [{ value: 'Foo 1' }] }),
31
- badgeDataFixture.create({ key: 'match-2', badgeText: [{ value: 'Foo 2' }, { value: 'Bar 2' }] }),
32
- badgeDataFixture.create({ key: 'match-3', badgeText: [{ value: 'Bar 3' }, { value: 'Foo 3' }] }),
33
- badgeDataFixture.create({ key: 'miss-1', badgeText: [{ value: 'Bar 4' }] }),
34
- ],
35
- })
36
-
37
- const result = new CohContentDatabase(data).searchBadges('Foo')
38
-
39
- expect(result).toHaveLength(3)
40
- const keys = result.map(x => x.key)
41
- expect(keys).toContain('match-1')
42
- expect(keys).toContain('match-2')
43
- expect(keys).toContain('match-3')
44
- expect(keys).not.toContainEqual(['miss-1'])
45
- })
46
- })
47
-
48
- test(`should match on acquisition`, () => {
49
- const data = contentBundleFixture.create({
50
- badges: [
51
- badgeDataFixture.create({ key: 'match-1', acquisition: 'Foo 1' }),
52
- badgeDataFixture.create({ key: 'match-2', acquisition: 'Foo 2' }),
53
- badgeDataFixture.create({ key: 'miss-1', acquisition: 'Bar 1' }),
54
- ],
55
- })
56
-
57
- const result = new CohContentDatabase(data).searchBadges('Foo')
58
-
59
- expect(result).toHaveLength(2)
60
- const keys = result.map(x => x.key)
61
- expect(keys).toContain('match-1')
62
- expect(keys).toContain('match-2')
63
- expect(keys).not.toContainEqual(['miss-1'])
64
- })
65
-
66
- test(`should match the start of a string`, () => {
67
- const data = contentBundleFixture.create({
68
- badges: [
69
- badgeDataFixture.create({ key: 'match-1', acquisition: 'Foo 1' }),
70
- badgeDataFixture.create({ key: 'match-2', acquisition: 'Foo 2' }),
71
- badgeDataFixture.create({ key: 'miss-1', acquisition: 'Bar 1' }),
72
- ],
73
- })
74
-
75
- const result = new CohContentDatabase(data).searchBadges('Fo')
76
-
77
- expect(result).toHaveLength(2)
78
- const keys = result.map(x => x.key)
79
- expect(keys).toContain('match-1')
80
- expect(keys).toContain('match-2')
81
- expect(keys).not.toContainEqual(['miss-1'])
82
- })
83
-
84
- test(`should return everything for an empty query`, () => {
85
- const data = contentBundleFixture.create({
86
- badges: [
87
- badgeDataFixture.create({ key: 'foo-1', acquisition: 'Foo 1' }),
88
- badgeDataFixture.create({ key: 'foo-2', acquisition: 'Foo 2' }),
89
- badgeDataFixture.create({ key: 'bar-1', acquisition: 'Bar 1' }),
90
- ],
91
- })
92
-
93
- const result = new CohContentDatabase(data).searchBadges()
94
-
95
- expect(result).toHaveLength(3)
96
- const keys = result.map(x => x.key)
97
- expect(keys).toContain('foo-1')
98
- expect(keys).toContain('foo-2')
99
- expect(keys).toContain('bar-1')
100
- })
101
-
102
- test(`should be case insensitive`, () => {
103
- const data = contentBundleFixture.create({
104
- badges: [
105
- badgeDataFixture.create({ key: 'match-1', acquisition: 'Foo 1' }),
106
- badgeDataFixture.create({ key: 'match-2', acquisition: 'Foo 2' }),
107
- badgeDataFixture.create({ key: 'miss-1', acquisition: 'Bar 1' }),
108
- ],
109
- })
110
-
111
- const result = new CohContentDatabase(data).searchBadges('foo')
112
-
113
- expect(result).toHaveLength(2)
114
- const keys = result.map(x => x.key)
115
- expect(keys).toContain('match-1')
116
- expect(keys).toContain('match-2')
117
- expect(keys).not.toContain('miss-1')
118
- })
119
- })