| 
									
										
										
										
											2014-08-19 03:09:09 +08:00
										 |  |  | var Binding = require('../../../src/binding') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe('Binding', function () { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   var b | 
					
						
							|  |  |  |   beforeEach(function () { | 
					
						
							|  |  |  |     b = new Binding() | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('addSub', function () { | 
					
						
							|  |  |  |     var sub = {} | 
					
						
							| 
									
										
										
										
											2014-09-02 20:37:34 +08:00
										 |  |  |     b.addSub(sub) | 
					
						
							|  |  |  |     expect(b.subs.length).toBe(1) | 
					
						
							|  |  |  |     expect(b.subs.indexOf(sub)).toBe(0) | 
					
						
							| 
									
										
										
										
											2014-08-19 03:09:09 +08:00
										 |  |  |   }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('removeSub', function () { | 
					
						
							|  |  |  |     var sub = {} | 
					
						
							| 
									
										
										
										
											2014-09-02 20:37:34 +08:00
										 |  |  |     b.addSub(sub) | 
					
						
							|  |  |  |     b.removeSub(sub) | 
					
						
							|  |  |  |     expect(b.subs.length).toBe(0) | 
					
						
							|  |  |  |     expect(b.subs.indexOf(sub)).toBe(-1) | 
					
						
							| 
									
										
										
										
											2014-08-19 03:09:09 +08:00
										 |  |  |   }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('notify', function () { | 
					
						
							|  |  |  |     var sub = { | 
					
						
							|  |  |  |       update: jasmine.createSpy('sub') | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-09-02 20:37:34 +08:00
										 |  |  |     b.addSub(sub) | 
					
						
							|  |  |  |     b.notify() | 
					
						
							| 
									
										
										
										
											2014-08-19 03:09:09 +08:00
										 |  |  |     expect(sub.update).toHaveBeenCalled() | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }) |