Skip to content

Commit c2b8991

Browse files
committed
chore(test): move tests from bind to refs
1 parent bb4ca0f commit c2b8991

File tree

2 files changed

+33
-37
lines changed

2 files changed

+33
-37
lines changed

test/bind.spec.js

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -89,39 +89,3 @@ test('unbinds previously bound refs', async () => {
8989
expect(vm.$firestoreRefs.item).toBe(doc2)
9090
expect(vm.item).toEqual({ bar: 'bar' })
9191
})
92-
93-
test('resolves the promise when refs are resolved in a document', async () => {
94-
const a = db.collection().doc()
95-
await a.update({ a: true })
96-
await document.update({ ref: a })
97-
98-
await vm.$bind('item', document)
99-
expect(vm.item).toEqual({ ref: { a: true }})
100-
})
101-
102-
test('resolves the promise when nested refs are resolved in a document', async () => {
103-
const a = db.collection().doc()
104-
const b = db.collection().doc()
105-
await a.update({ a: b })
106-
await b.update({ b: true })
107-
await document.update({ ref: a })
108-
109-
await vm.$bind('item', document)
110-
expect(vm.item).toEqual({ ref: { a: { b: true }}})
111-
})
112-
113-
test('resolves the promise when nested non-existant refs are resolved in a document', async () => {
114-
const a = db.collection().doc()
115-
const b = db.collection().doc()
116-
await a.update({ a: b })
117-
await document.update({ ref: a })
118-
119-
await vm.$bind('item', document)
120-
expect(vm.item).toEqual({ ref: { a: null }})
121-
})
122-
123-
test('resolves the promise when the document does not exist', async () => {
124-
expect(vm.item).toEqual(null)
125-
await vm.$bind('item', document)
126-
expect(vm.item).toBe(null)
127-
})

test/refs.spec.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ beforeEach(async () => {
2828
a: null,
2929
b: null,
3030
c: null,
31-
d: null
31+
d: null,
32+
item: null
3233
}),
3334

3435
firestore: {
@@ -123,3 +124,34 @@ test('unbinds previously bound document when overwriting a bound', async () => {
123124
})
124125
spy.mockRestore()
125126
})
127+
128+
test('resolves the promise when refs are resolved in a document', async () => {
129+
await a.update({ a: true })
130+
await b.update({ ref: a })
131+
132+
await vm.$bind('item', b)
133+
expect(vm.item).toEqual({ ref: { a: true }})
134+
})
135+
136+
test('resolves the promise when nested refs are resolved in a document', async () => {
137+
await a.update({ a: b })
138+
await b.update({ b: true })
139+
await d.update({ ref: a })
140+
141+
await vm.$bind('item', d)
142+
expect(vm.item).toEqual({ ref: { a: { b: true }}})
143+
})
144+
145+
test('resolves the promise when nested non-existant refs are resolved in a document', async () => {
146+
await a.update({ a: b })
147+
await d.update({ ref: a })
148+
149+
await vm.$bind('item', d)
150+
expect(vm.item).toEqual({ ref: { a: null }})
151+
})
152+
153+
test('resolves the promise when the document does not exist', async () => {
154+
expect(vm.item).toEqual(null)
155+
await vm.$bind('item', a)
156+
expect(vm.item).toBe(null)
157+
})

0 commit comments

Comments
 (0)