Skip to content

Commit

Permalink
Merge pull request #7 from peterhil/test-index-from-map
Browse files Browse the repository at this point in the history
Test index from map
  • Loading branch information
peterhil authored Sep 3, 2024
2 parents 066f4af + aebdc35 commit 348cc04
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 17 deletions.
27 changes: 10 additions & 17 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,26 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: main

- name: Setup Pnpm
uses: pnpm/action-setup@v4
with:
version: 9.4.x

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
# cache: pnpm

- name: Cache pnpm modules
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
cache: pnpm

- name: Pnpm install
uses: pnpm/action-setup@v4
with:
version: 9.4.x
run_install: |
- recursive: true
args: [--frozen-lockfile, --strict-peer-dependencies]
- args: [--global, typedoc, typescript]
run: pnpm install --strict-peer-dependencies

- name: Generate documentation
run: pnpm run doc
run: pnpm doc

- name: Publish Docs
run: |
Expand Down
41 changes: 41 additions & 0 deletions src/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,47 @@ tap.test('Index.from', assert => {
assert.end()
})

tap.test('Index.from an object', assert => {
const obj = {
a: 'Alpha',
b: 'Beta',
g: 'Gamma',
d: 'Delta',
}
const index = Index.from(obj, 2, '•')

assert.same(
index.all(),
{
'al': {'a': [0]},
'lp': {'a': [1]},
'ph': {'a': [2]},
'ha': {'a': [3]},
'a•': {
'a': [4],
'b': [3],
'g': [4],
'd': [4],
},
'be': {'b': [0]},
'et': {'b': [1]},
'ta': {
'b': [2],
'd': [3],
},
'ga': {'g': [0]},
'am': {'g': [1]},
'mm': {'g': [2]},
'ma': {'g': [3]},
'de': {'d': [0]},
'el': {'d': [1]},
'lt': {'d': [2]},
},
)
assert.same(index.search('ta'), ['b', 'd'])
assert.end()
})

tap.test('index', assert => {
const index = new Index(3, '•')
index.add('Alpha', 'a')
Expand Down

0 comments on commit 348cc04

Please sign in to comment.