7d8f7d5c by Michael Richards

Add specs for Rivets.Binding::formattedValue().

1 parent 19a39894
...@@ -63,4 +63,29 @@ describe('Rivets.Binding', function() { ...@@ -63,4 +63,29 @@ describe('Rivets.Binding', function() {
63 }); 63 });
64 }); 64 });
65 }); 65 });
66
67 describe('formattedValue()', function() {
68 it('applies the current formatters on the supplied value', function() {
69 rivets.config.formatters = {
70 awesome: function(value) { return 'awesome ' + value }
71 };
72 binding.formatters.push('awesome');
73 expect(binding.formattedValue('hat')).toBe('awesome hat');
74 });
75
76 describe('with a multi-argument formatter string', function() {
77 beforeEach(function() {
78 rivets.config.formatters = {
79 awesome: function(value, prefix) {
80 return prefix + ' awesome ' + value;
81 }
82 };
83 binding.formatters.push('awesome super');
84 });
85
86 it('applies the formatter with arguments', function() {
87 expect(binding.formattedValue('jacket')).toBe('super awesome jacket');
88 });
89 });
90 });
66 }); 91 });
......