| OLD | NEW |
| 1 library interpolate_spec; | 1 library interpolate_spec; |
| 2 | 2 |
| 3 import '../_specs.dart'; | 3 import '../_specs.dart'; |
| 4 | 4 |
| 5 class ToStringableObject { | 5 class ToStringableObject { |
| 6 toString() => 'World'; | 6 toString() => 'World'; |
| 7 } | 7 } |
| 8 | 8 |
| 9 main() { | 9 main() { |
| 10 describe('\$interpolate', () { | 10 describe('\$interpolate', () { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 expect($interpolate('{{a.b}}')([null])).toEqual(''); | 21 expect($interpolate('{{a.b}}')([null])).toEqual(''); |
| 22 })); | 22 })); |
| 23 | 23 |
| 24 it('should jsonify objects', inject((Interpolate $interpolate) { | 24 it('should jsonify objects', inject((Interpolate $interpolate) { |
| 25 expect($interpolate('{{ {} }}')([{}])).toEqual('{}'); | 25 expect($interpolate('{{ {} }}')([{}])).toEqual('{}'); |
| 26 expect($interpolate('{{ true }}')([true])).toEqual('true'); | 26 expect($interpolate('{{ true }}')([true])).toEqual('true'); |
| 27 expect($interpolate('{{ false }}')([false])).toEqual('false'); | 27 expect($interpolate('{{ false }}')([false])).toEqual('false'); |
| 28 })); | 28 })); |
| 29 | 29 |
| 30 | 30 |
| 31 it('should return interpolation function', inject((Interpolate $interpolate,
Scope rootScope) { | 31 it('should return interpolation function', inject((Interpolate $interpolate,
Scope $rootScope) { |
| 32 rootScope.context['name'] = 'Misko'; | 32 $rootScope.name = 'Misko'; |
| 33 var fn = $interpolate('Hello {{name}}!'); | 33 var fn = $interpolate('Hello {{name}}!'); |
| 34 expect(fn(['Misko'])).toEqual('Hello Misko!'); | 34 expect(fn(['Misko'])).toEqual('Hello Misko!'); |
| 35 })); | 35 })); |
| 36 | 36 |
| 37 | 37 |
| 38 it('should ignore undefined model', inject((Interpolate $interpolate) { | 38 it('should ignore undefined model', inject((Interpolate $interpolate) { |
| 39 expect($interpolate("Hello {{'World' + foo}}")(['World'])).toEqual('Hello
World'); | 39 expect($interpolate("Hello {{'World' + foo}}")(['World'])).toEqual('Hello
World'); |
| 40 })); | 40 })); |
| 41 | 41 |
| 42 | 42 |
| 43 it('should use toString to conver objects to string', inject((Interpolate $i
nterpolate, Scope rootScope) { | 43 it('should use toString to conver objects to string', inject((Interpolate $i
nterpolate, Scope $rootScope) { |
| 44 expect($interpolate("Hello, {{obj}}!")([new ToStringableObject()])).toEqua
l('Hello, World!'); | 44 expect($interpolate("Hello, {{obj}}!")([new ToStringableObject()])).toEqua
l('Hello, World!'); |
| 45 })); | 45 })); |
| 46 | 46 |
| 47 | 47 |
| 48 describe('parseBindings', () { | 48 describe('parseBindings', () { |
| 49 it('should Parse Text With No Bindings', inject((Interpolate $interpolate)
{ | 49 it('should Parse Text With No Bindings', inject((Interpolate $interpolate)
{ |
| 50 var parts = $interpolate("a").seperators; | 50 var parts = $interpolate("a").seperators; |
| 51 expect(parts.length).toEqual(1); | 51 expect(parts.length).toEqual(1); |
| 52 expect(parts[0]).toEqual("a"); | 52 expect(parts[0]).toEqual("a"); |
| 53 })); | 53 })); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 it('should Parse Multiline', inject((Interpolate $interpolate) { | 105 it('should Parse Multiline', inject((Interpolate $interpolate) { |
| 106 var parts = $interpolate('"X\nY{{A\n+B}}C\nD"').seperators; | 106 var parts = $interpolate('"X\nY{{A\n+B}}C\nD"').seperators; |
| 107 expect(parts.length).toEqual(2); | 107 expect(parts.length).toEqual(2); |
| 108 expect(parts[0]).toEqual('"X\nY'); | 108 expect(parts[0]).toEqual('"X\nY'); |
| 109 expect(parts[1]).toEqual('C\nD"'); | 109 expect(parts[1]).toEqual('C\nD"'); |
| 110 })); | 110 })); |
| 111 }); | 111 }); |
| 112 }); | 112 }); |
| 113 } | 113 } |
| OLD | NEW |