Skip to content

Commit 56bfee6

Browse files
committed
test(ids): make sure items in collections have an id
Make sure they're non-enumerable, etc pretty much like documents
1 parent 5b06306 commit 56bfee6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/collection.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Vuefire from '../src'
22
import {
33
db,
44
tick,
5+
Key,
56
Vue
67
} from './helpers'
78

@@ -67,3 +68,19 @@ test('unbinds when the instance is destroyed', async () => {
6768
expect(vm.items).toEqual([])
6869
}).not.toThrow()
6970
})
71+
72+
test('adds non-enumerable id', async () => {
73+
const a = await collection.doc(new Key('u0'))
74+
const b = await collection.doc(new Key('u1'))
75+
await a.update({})
76+
await b.update({})
77+
expect(vm.items.length).toBe(2)
78+
vm.items.forEach((item, i) => {
79+
expect(Object.getOwnPropertyDescriptor(item, 'id')).toEqual({
80+
configurable: false,
81+
enumerable: false,
82+
writable: false,
83+
value: `u${i}`
84+
})
85+
})
86+
})

0 commit comments

Comments
 (0)