Skip to content

Commit

Permalink
Improve some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaong committed Nov 23, 2022
1 parent f640836 commit 16298be
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/MiniSearch.test.js
Expand Up @@ -443,10 +443,12 @@ describe('MiniSearch', () => {
ms.addAll(documents)

expect(ms.search('stuff').map((doc) => doc.id)).toEqual([1, 2])
expect([1, 2].map((id) => ms.has(id))).toEqual([true, true])

ms.discard(1)

expect(ms.search('stuff').map((doc) => doc.id)).toEqual([2])
expect([1, 2].map((id) => ms.has(id))).toEqual([false, true])
})

it('raises error if a document with the given ID does not exist', () => {
Expand Down Expand Up @@ -693,10 +695,12 @@ describe('MiniSearch', () => {
ms.addAll(documents)

expect(ms.search('stuff').map((doc) => doc.id)).toEqual([1, 2, 3])
expect([1, 2, 3].map((id) => ms.has(id))).toEqual([true, true, true])

ms.discardAll([1, 3])

expect(ms.search('stuff').map((doc) => doc.id)).toEqual([2])
expect([1, 2, 3].map((id) => ms.has(id))).toEqual([false, true, false])
})

it('only triggers at most a single auto vacuum at the end', () => {
Expand Down

0 comments on commit 16298be

Please sign in to comment.