Skip to content

Commit

Permalink
test(ids): make sure items in collections have an id
Browse files Browse the repository at this point in the history
Make sure they're non-enumerable, etc pretty much like documents
  • Loading branch information
posva committed Dec 24, 2017
1 parent 5b06306 commit 56bfee6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/collection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Vuefire from '../src'
import {
db,
tick,
Key,
Vue
} from './helpers'

Expand Down Expand Up @@ -67,3 +68,19 @@ test('unbinds when the instance is destroyed', async () => {
expect(vm.items).toEqual([])
}).not.toThrow()
})

test('adds non-enumerable id', async () => {
const a = await collection.doc(new Key('u0'))
const b = await collection.doc(new Key('u1'))
await a.update({})
await b.update({})
expect(vm.items.length).toBe(2)
vm.items.forEach((item, i) => {
expect(Object.getOwnPropertyDescriptor(item, 'id')).toEqual({
configurable: false,
enumerable: false,
writable: false,
value: `u${i}`
})
})
})

0 comments on commit 56bfee6

Please sign in to comment.