|
|
@@ -315,39 +315,6 @@ describe('Watcher', function () {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- it('add callback', function (done) {
|
|
|
- var watcher = new Watcher(vm, 'a', spy)
|
|
|
- var spy2 = jasmine.createSpy()
|
|
|
- watcher.addCb(spy2)
|
|
|
- vm.a = 99
|
|
|
- nextTick(function () {
|
|
|
- expect(spy).toHaveBeenCalledWith(99, 1)
|
|
|
- expect(spy2).toHaveBeenCalledWith(99, 1)
|
|
|
- done()
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- it('remove callback', function (done) {
|
|
|
- // single, should equal teardown
|
|
|
- var fn = function () {}
|
|
|
- var watcher = new Watcher(vm, 'a', fn)
|
|
|
- watcher.removeCb(fn)
|
|
|
- expect(watcher.active).toBe(false)
|
|
|
- expect(watcher.vm).toBe(null)
|
|
|
- expect(watcher.cbs).toBe(null)
|
|
|
- // multiple
|
|
|
- watcher = new Watcher(vm, 'a', spy)
|
|
|
- var spy2 = jasmine.createSpy()
|
|
|
- watcher.addCb(spy2)
|
|
|
- watcher.removeCb(spy)
|
|
|
- vm.a = 234
|
|
|
- nextTick(function () {
|
|
|
- expect(spy).not.toHaveBeenCalled()
|
|
|
- expect(spy2).toHaveBeenCalledWith(234, 1)
|
|
|
- done()
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
it('teardown', function (done) {
|
|
|
var watcher = new Watcher(vm, 'b.c', spy)
|
|
|
watcher.teardown()
|
|
|
@@ -355,7 +322,7 @@ describe('Watcher', function () {
|
|
|
nextTick(function () {
|
|
|
expect(watcher.active).toBe(false)
|
|
|
expect(watcher.vm).toBe(null)
|
|
|
- expect(watcher.cbs).toBe(null)
|
|
|
+ expect(watcher.cb).toBe(null)
|
|
|
expect(spy).not.toHaveBeenCalled()
|
|
|
done()
|
|
|
})
|
|
|
@@ -372,21 +339,6 @@ describe('Watcher', function () {
|
|
|
config.async = true
|
|
|
})
|
|
|
|
|
|
- it('handle a cb that triggers removeCb', function () {
|
|
|
- var watcher = new Watcher(vm, 'a', spy)
|
|
|
- watcher.addCb(function () {
|
|
|
- watcher.removeCb(spy)
|
|
|
- })
|
|
|
- watcher.addCb(function () {})
|
|
|
- config.async = false
|
|
|
- expect(function () {
|
|
|
- vm.a = 2
|
|
|
- }).not.toThrow()
|
|
|
- config.async = true
|
|
|
- expect(spy).toHaveBeenCalled()
|
|
|
- expect(watcher.cbs.length).toBe(2)
|
|
|
- })
|
|
|
-
|
|
|
it('warn getter errors', function () {
|
|
|
var watcher = new Watcher(vm, 'd.e + c', spy)
|
|
|
expect(hasWarned(_, 'Error when evaluating expression')).toBe(true)
|