Update the binding spec so that any post-bind setting of formatters is done thro…
…ugh view.formatters explicitly. [#81]
Showing
1 changed file
with
4 additions
and
10 deletions
... | @@ -131,7 +131,7 @@ describe('Rivets.Binding', function() { | ... | @@ -131,7 +131,7 @@ describe('Rivets.Binding', function() { |
131 | }); | 131 | }); |
132 | 132 | ||
133 | it('applies any formatters to the value before performing the routine', function() { | 133 | it('applies any formatters to the value before performing the routine', function() { |
134 | rivets.formatters.awesome = function(value) { return 'awesome ' + value; }; | 134 | view.formatters.awesome = function(value) { return 'awesome ' + value; }; |
135 | binding.formatters.push('awesome'); | 135 | binding.formatters.push('awesome'); |
136 | spyOn(binding.binder, 'routine'); | 136 | spyOn(binding.binder, 'routine'); |
137 | binding.set('sweater'); | 137 | binding.set('sweater'); |
... | @@ -167,7 +167,7 @@ describe('Rivets.Binding', function() { | ... | @@ -167,7 +167,7 @@ describe('Rivets.Binding', function() { |
167 | describe('publishTwoWay()', function() { | 167 | describe('publishTwoWay()', function() { |
168 | 168 | ||
169 | it('applies a two-way read formatter to function same as a single-way', function() { | 169 | it('applies a two-way read formatter to function same as a single-way', function() { |
170 | rivets.formatters.awesome = { | 170 | view.formatters.awesome = { |
171 | read: function(value) { return 'awesome ' + value; }, | 171 | read: function(value) { return 'awesome ' + value; }, |
172 | }; | 172 | }; |
173 | binding.formatters.push('awesome'); | 173 | binding.formatters.push('awesome'); |
... | @@ -300,7 +300,7 @@ describe('Rivets.Binding', function() { | ... | @@ -300,7 +300,7 @@ describe('Rivets.Binding', function() { |
300 | 300 | ||
301 | describe('formattedValue()', function() { | 301 | describe('formattedValue()', function() { |
302 | it('applies the current formatters on the supplied value', function() { | 302 | it('applies the current formatters on the supplied value', function() { |
303 | rivets.formatters.awesome = function(value) { return 'awesome ' + value; }; | 303 | view.formatters.awesome = function(value) { return 'awesome ' + value; }; |
304 | binding.formatters.push('awesome'); | 304 | binding.formatters.push('awesome'); |
305 | expect(binding.formattedValue('hat')).toBe('awesome hat'); | 305 | expect(binding.formattedValue('hat')).toBe('awesome hat'); |
306 | }); | 306 | }); |
... | @@ -311,15 +311,9 @@ describe('Rivets.Binding', function() { | ... | @@ -311,15 +311,9 @@ describe('Rivets.Binding', function() { |
311 | expect(binding.formattedValue('hat')).toBe('model awesome hat'); | 311 | expect(binding.formattedValue('hat')).toBe('model awesome hat'); |
312 | }); | 312 | }); |
313 | 313 | ||
314 | it('uses formatters from the bind options', function() { | ||
315 | opts.formatters = { optAwesome: function(value) { return 'option awesome ' + value; } }; | ||
316 | binding.formatters.push("optAwesome"); | ||
317 | expect(binding.formattedValue('hat')).toBe('option awesome hat'); | ||
318 | }); | ||
319 | |||
320 | describe('with a multi-argument formatter string', function() { | 314 | describe('with a multi-argument formatter string', function() { |
321 | beforeEach(function() { | 315 | beforeEach(function() { |
322 | rivets.formatters.awesome = function(value, prefix) { | 316 | view.formatters.awesome = function(value, prefix) { |
323 | return prefix + ' awesome ' + value; | 317 | return prefix + ' awesome ' + value; |
324 | }; | 318 | }; |
325 | binding.formatters.push('awesome super'); | 319 | binding.formatters.push('awesome super'); | ... | ... |
-
Please register or sign in to post a comment