Skip to content

Commit 2b3faad

Browse files
committed
test(firestore): doc updates
1 parent 2f53ec6 commit 2b3faad

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/firestore/collection.spec.ts

+19
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
DocumentData,
1111
Query,
1212
setDoc,
13+
updateDoc,
1314
} from 'firebase/firestore'
1415
import { expectType, setupFirestoreRefs, tds, firestore } from '../utils'
1516
import { type Ref } from 'vue'
@@ -92,6 +93,24 @@ describe('Firestore collections', () => {
9293
expect(wrapper.vm.list).toContainEqual({ name: 'b' })
9394
})
9495

96+
it('updates items of the collection', async () => {
97+
const { wrapper, listRef } = factory<{ name: string }>()
98+
99+
const aRef = doc(listRef)
100+
const a = await setDoc(aRef, { name: 'a' })
101+
const bRef = doc(listRef)
102+
const b = await setDoc(bRef, { name: 'b' })
103+
const cRef = doc(listRef)
104+
const c = await setDoc(cRef, { name: 'c' })
105+
106+
await setDoc(aRef, { name: 'aa' })
107+
await updateDoc(cRef, { name: 'cc' })
108+
expect(wrapper.vm.list).toHaveLength(3)
109+
expect(wrapper.vm.list).toContainEqual({ name: 'aa' })
110+
expect(wrapper.vm.list).toContainEqual({ name: 'b' })
111+
expect(wrapper.vm.list).toContainEqual({ name: 'cc' })
112+
})
113+
95114
tds(() => {
96115
interface TodoI {
97116
text: string

0 commit comments

Comments
 (0)