vue2/test/unit/specs/binding_spec.js

40 lines
771 B
JavaScript
Raw Normal View History

2014-08-19 03:09:09 +08:00
var Binding = require('../../../src/binding')
describe('Binding', function () {
var b
beforeEach(function () {
b = new Binding()
})
it('addChild', function () {
var child = new Binding()
b._addChild('test', child)
expect(b.test).toBe(child)
})
it('addSub', function () {
var sub = {}
b._addSub(sub)
expect(b._subs.length).toBe(1)
expect(b._subs.indexOf(sub)).toBe(0)
})
it('removeSub', function () {
var sub = {}
b._addSub(sub)
b._removeSub(sub)
expect(b._subs.length).toBe(0)
expect(b._subs.indexOf(sub)).toBe(-1)
})
it('notify', function () {
var sub = {
update: jasmine.createSpy('sub')
}
b._addSub(sub)
b._notify()
expect(sub.update).toHaveBeenCalled()
})
})