aee54fd4 by Michael Richards

Update and remove old specs from Rivets.Binding specs. This component has become…

… much simpler now that all binding logic is self-contained in the binder/routine.
1 parent 391add17
...@@ -18,8 +18,8 @@ describe('Rivets.Binding', function() { ...@@ -18,8 +18,8 @@ describe('Rivets.Binding', function() {
18 model = binding.model; 18 model = binding.model;
19 }); 19 });
20 20
21 it('gets assigned the routine function matching the identifier', function() { 21 it('gets assigned the proper binder routine matching the identifier', function() {
22 expect(binding.routine).toBe(rivets.routines.text); 22 expect(binding.binder.routine).toBe(rivets.routines.text);
23 }); 23 });
24 24
25 describe('bind()', function() { 25 describe('bind()', function() {
...@@ -72,50 +72,24 @@ describe('Rivets.Binding', function() { ...@@ -72,50 +72,24 @@ describe('Rivets.Binding', function() {
72 72
73 describe('set()', function() { 73 describe('set()', function() {
74 it('performs the binding routine with the supplied value', function() { 74 it('performs the binding routine with the supplied value', function() {
75 spyOn(binding, 'routine'); 75 spyOn(binding.binder, 'routine');
76 binding.set('sweater'); 76 binding.set('sweater');
77 expect(binding.routine).toHaveBeenCalledWith(el, 'sweater'); 77 expect(binding.binder.routine).toHaveBeenCalledWith(el, 'sweater');
78 }); 78 });
79 79
80 it('applies any formatters to the value before performing the routine', function() { 80 it('applies any formatters to the value before performing the routine', function() {
81 rivets.formatters.awesome = function(value) { return 'awesome ' + value }; 81 rivets.formatters.awesome = function(value) { return 'awesome ' + value };
82 binding.formatters.push('awesome'); 82 binding.formatters.push('awesome');
83 spyOn(binding, 'routine'); 83 spyOn(binding.binder, 'routine');
84 binding.set('sweater'); 84 binding.set('sweater');
85 expect(binding.routine).toHaveBeenCalledWith(el, 'awesome sweater'); 85 expect(binding.binder.routine).toHaveBeenCalledWith(el, 'awesome sweater');
86 }); 86 });
87 87
88 it('calls methods with the object as context', function() { 88 it('calls methods with the object as context', function() {
89 binding.model = {foo: 'bar'}; 89 binding.model = {foo: 'bar'};
90 spyOn(binding, 'routine'); 90 spyOn(binding.binder, 'routine');
91 binding.set(function() { return this.foo; }); 91 binding.set(function() { return this.foo; });
92 expect(binding.routine).toHaveBeenCalledWith(el, binding.model.foo); 92 expect(binding.binder.routine).toHaveBeenCalledWith(el, binding.model.foo);
93 });
94
95 describe('on an event binding', function() {
96 beforeEach(function() {
97 binding.options.special = 'event';
98 });
99
100 it('performs the binding routine with the supplied function and current listener', function() {
101 spyOn(binding, 'routine');
102 func = function() { return 1 + 2; }
103 binding.set(func);
104 expect(binding.routine).toHaveBeenCalledWith(el, binding.model, func, undefined);
105 });
106 });
107
108 describe('on an iteration binding', function(){
109 beforeEach(function(){
110 binding.options.special = 'iteration';
111 });
112
113 it('performs the binding routine with the supplied collection and binding', function() {
114 spyOn(binding, 'routine');
115 array = [{name: 'a'}, {name: 'b'}];
116 binding.set(array);
117 expect(binding.routine).toHaveBeenCalledWith(el, array, binding);
118 });
119 }); 93 });
120 }); 94 });
121 95
......