Skip to content

Commit

Permalink
test: replace sinon with jest
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Dec 4, 2017
1 parent 1f22424 commit f97f93f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 107 deletions.
98 changes: 0 additions & 98 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"mkdirp": "^0.5.1",
"rollup": "^0.51.8",
"rollup-plugin-buble": "^0.18.0",
"sinon": "^4.1.2",
"uglify-js": "^3.1.10",
"vue": "^2.5.9"
},
Expand Down
5 changes: 2 additions & 3 deletions test/collection.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sinon from 'sinon'
import Vuefire from '../src'
import {
db,
Expand Down Expand Up @@ -57,11 +56,11 @@ test('add properties', async () => {
test('unbinds when the instance is destroyed', async () => {
expect(vm._firestoreUnbinds).toBeTruthy()
expect(vm.items).toEqual([])
const spy = sinon.spy(vm._firestoreUnbinds, 'items')
const spy = jest.spyOn(vm._firestoreUnbinds, 'items')
expect(() => {
vm.$destroy()
}).not.toThrow()
expect(spy.callCount).toBe(1)
expect(spy).toHaveBeenCalled()
expect(vm._firestoreUnbinds).toBe(null)
await expect(async () => {
await collection.add({ text: 'foo' })
Expand Down
11 changes: 6 additions & 5 deletions test/unbind.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sinon from 'sinon'
import Vuefire from '../src'
import {
db,
Expand Down Expand Up @@ -33,23 +32,25 @@ beforeEach(async () => {
})

test('manually unbinds a collection', async () => {
const spy = sinon.spy(vm._firestoreUnbinds, 'items')
const spy = jest.spyOn(vm._firestoreUnbinds, 'items')
vm.$unbind('items')
expect(spy.callCount).toBe(1)
expect(spy).toHaveBeenCalled()
expect(Object.keys(vm._firestoreUnbinds)).toEqual(['item'])
expect(Object.keys(vm.$firestoreRefs)).toEqual(['item'])
expect(vm.items).toEqual([])
await collection.add({ text: 'foo' })
expect(vm.items).toEqual([])
spy.mockRestore()
})

test('manually unbinds a document', async () => {
const spy = sinon.spy(vm._firestoreUnbinds, 'item')
const spy = jest.spyOn(vm._firestoreUnbinds, 'item')
vm.$unbind('item')
expect(spy.callCount).toBe(1)
expect(spy).toHaveBeenCalled()
expect(Object.keys(vm._firestoreUnbinds)).toEqual(['items'])
expect(Object.keys(vm.$firestoreRefs)).toEqual(['items'])
expect(vm.item).toEqual(null)
await document.update({ foo: 'foo' })
expect(vm.item).toEqual(null)
spy.mockRestore()
})

0 comments on commit f97f93f

Please sign in to comment.