aboutsummaryrefslogtreecommitdiffstats
path: root/test/FormattersSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2011-01-13 10:35:26 -0800
committerMisko Hevery2011-01-14 10:30:00 -0800
commit347be5ae9aa6829427e1e8e1b1e58afdf2a36c0a (patch)
tree3b350a12378c1ec63f60cce0fe674186d204726e /test/FormattersSpec.js
parent934f44f69e94a77a3ea6c19dc5c6f82ade2cc669 (diff)
downloadangular.js-347be5ae9aa6829427e1e8e1b1e58afdf2a36c0a.tar.bz2
fixed select with ng:format
select (one/multiple) could not chose from a list of objects, since DOM requires string ids. Solved by adding index formatter, which exposed incorrect handling of formatters in select widgets.
Diffstat (limited to 'test/FormattersSpec.js')
-rw-r--r--test/FormattersSpec.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/FormattersSpec.js b/test/FormattersSpec.js
index af50f384..1ebd8e22 100644
--- a/test/FormattersSpec.js
+++ b/test/FormattersSpec.js
@@ -33,5 +33,20 @@ describe("formatter", function(){
assertEquals('a', angular.formatter.trim.format(" a "));
assertEquals('a', angular.formatter.trim.parse(' a '));
});
+
+ describe('json', function(){
+ it('should treat empty string as null', function(){
+ expect(angular.formatter.json.parse('')).toEqual(null);
+ });
+ });
+
+ describe('index', function(){
+ it('should parse an object from array', function(){
+ expect(angular.formatter.index.parse('1', ['A', 'B', 'C'])).toEqual('B');
+ });
+ it('should format an index from array', function(){
+ expect(angular.formatter.index.format('B', ['A', 'B', 'C'])).toEqual('1');
+ });
+ });
});