Skip to content

Commit

Permalink
refactor(mock): collection.doc(id) instead of collection.doc(new Key(…
Browse files Browse the repository at this point in the history
…id))
  • Loading branch information
posva committed Dec 26, 2017
1 parent 5bf1ffe commit a47cb8d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions test/collection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test('add elements', async () => {

test('delets items', async () => {
await collection.add({ text: 'foo' })
await collection.doc(new Key(vm.items[0].id)).delete()
await collection.doc(vm.items[0].id).delete()
expect(vm.items).toEqual([])
})

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

test('adds non-enumerable id', async () => {
const a = await collection.doc(new Key('u0'))
const b = await collection.doc(new Key('u1'))
const a = await collection.doc('u0')
const b = await collection.doc('u1')
await a.update({})
await b.update({})
expect(vm.items.length).toBe(2)
Expand Down
2 changes: 1 addition & 1 deletion test/document.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test('updates a document', async () => {
})

test('adds non-enumerable id', async () => {
document = collection.doc(new Key('some-id'))
document = collection.doc('some-id')
await document.update({ foo: 'foo' })
await vm.$bind('item', document)
expect(Object.getOwnPropertyDescriptor(vm.item, 'id')).toEqual({
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class CollectionReference {
where () {}

doc (id) {
id = id || new Key()
id = new Key(id)
return this.data[id.v] || new DocumentReference({
collection: this,
id,
Expand Down
2 changes: 1 addition & 1 deletion test/refs-collections.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ test('unbinds refs when items are removed', async () => {
await vm.$bind('items', collection)
expect(spyA).toHaveBeenCalledTimes(0)

await collection.doc(new Key(vm.items[0].id)).delete()
await collection.doc(vm.items[0].id).delete()
expect(spyA).toHaveBeenCalledTimes(1)

spyA.mockRestore()
Expand Down

0 comments on commit a47cb8d

Please sign in to comment.