Skip to content

Commit

Permalink
test: add test case for id index removal
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnowack committed Mar 23, 2024
1 parent 1f75de8 commit 7aeecf9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/signaldb/__tests__/Collection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ describe('Collection', () => {
expect(eventHandler).toHaveBeenCalledTimes(1)
expect(eventHandler).toHaveBeenCalledWith({ id: '1', name: 'John' })
})

it('should remove the index if the item is removed', () => {
const id = 'test'
collection.insert({ id, name: 'John' })
expect(collection.findOne({ id })).toEqual({ id, name: 'John' })

collection.removeOne({ id })
expect(collection.findOne({ id })).toBeUndefined()

collection.insert({ id, name: 'Jane' })
expect(collection.findOne({ id })).toEqual({ id, name: 'Jane' })
})
})

describe('removeMany', () => {
Expand Down

0 comments on commit 7aeecf9

Please sign in to comment.