aboutsummaryrefslogtreecommitdiffstats
path: root/test/ParserSpec.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/ParserSpec.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/ParserSpec.js')
-rw-r--r--test/ParserSpec.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ParserSpec.js b/test/ParserSpec.js
index c237aa40..4d0e14dc 100644
--- a/test/ParserSpec.js
+++ b/test/ParserSpec.js
@@ -396,4 +396,29 @@ describe('parser', function() {
expect(scope.obj.name).toBeUndefined();
expect(scope.obj[0].name).toEqual(1);
});
+
+ describe('formatter', function(){
+ it('should return no argument function', function() {
+ var noop = parser('noop').formatter()();
+ expect(noop.format(null, 'abc')).toEqual('abc');
+ expect(noop.parse(null, '123')).toEqual('123');
+ });
+
+ it('should delegate arguments', function(){
+ var index = parser('index:objs').formatter()();
+ expect(index.format({objs:['A','B']}, 'B')).toEqual('1');
+ expect(index.parse({objs:['A','B']}, '1')).toEqual('B');
+ });
+ });
+
+ describe('assignable', function(){
+ it('should expose assignment function', function(){
+ var fn = parser('a').assignable();
+ expect(fn.assign).toBeTruthy();
+ var scope = {};
+ fn.assign(scope, 123);
+ expect(scope).toEqual({a:123});
+ });
+ });
+
});