binding test

This commit is contained in:
Evan You 2014-08-18 15:09:09 -04:00
parent 5862da6475
commit e2d5f4514c
1 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,40 @@
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()
})
})