Skip to content

Commit

Permalink
Improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaong committed Nov 28, 2022
1 parent 6d3f900 commit 52233a1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/MiniSearch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,10 +814,18 @@ describe('MiniSearch', () => {

it('throws an error if removing a field that did not exist', () => {
const ms = new MiniSearch({ fields: ['text', 'author'] })
ms.add({ id: 1, author: 'Al et. al.' })
ms.addAll([
{ id: 1, author: 'Al et. al.' },
{ id: 2 }
])

expect(() => {
ms.removeFields(1, { text: 'Some interesting stuff' })
}).toThrow('MiniSearch: field text does not exist on document with ID 1')

expect(() => {
ms.removeFields(2, { author: 'Someone' })
}).toThrow('MiniSearch: field author does not exist on document with ID 2')
})
})

Expand Down

0 comments on commit 52233a1

Please sign in to comment.