Skip to content

Commit a47cb8d

Browse files
committed
refactor(mock): collection.doc(id) instead of collection.doc(new Key(id))
1 parent 5bf1ffe commit a47cb8d

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

test/collection.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test('add elements', async () => {
3333

3434
test('delets items', async () => {
3535
await collection.add({ text: 'foo' })
36-
await collection.doc(new Key(vm.items[0].id)).delete()
36+
await collection.doc(vm.items[0].id).delete()
3737
expect(vm.items).toEqual([])
3838
})
3939

@@ -65,8 +65,8 @@ test('unbinds when the instance is destroyed', async () => {
6565
})
6666

6767
test('adds non-enumerable id', async () => {
68-
const a = await collection.doc(new Key('u0'))
69-
const b = await collection.doc(new Key('u1'))
68+
const a = await collection.doc('u0')
69+
const b = await collection.doc('u1')
7070
await a.update({})
7171
await b.update({})
7272
expect(vm.items.length).toBe(2)

test/document.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ test('updates a document', async () => {
3535
})
3636

3737
test('adds non-enumerable id', async () => {
38-
document = collection.doc(new Key('some-id'))
38+
document = collection.doc('some-id')
3939
await document.update({ foo: 'foo' })
4040
await vm.$bind('item', document)
4141
expect(Object.getOwnPropertyDescriptor(vm.item, 'id')).toEqual({

test/helpers/mock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class CollectionReference {
129129
where () {}
130130

131131
doc (id) {
132-
id = id || new Key()
132+
id = new Key(id)
133133
return this.data[id.v] || new DocumentReference({
134134
collection: this,
135135
id,

test/refs-collections.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ test('unbinds refs when items are removed', async () => {
109109
await vm.$bind('items', collection)
110110
expect(spyA).toHaveBeenCalledTimes(0)
111111

112-
await collection.doc(new Key(vm.items[0].id)).delete()
112+
await collection.doc(vm.items[0].id).delete()
113113
expect(spyA).toHaveBeenCalledTimes(1)
114114

115115
spyA.mockRestore()

0 commit comments

Comments
 (0)