Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: third_party/pkg/angular/test/core/interpolate_spec.dart

Issue 256553002: Revert "Update all Angular libs (run update_all.sh)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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', () {
11 11
12 it('should return undefined when there are no bindings and textOnly is set t o true', 12 it('should return undefined when there are no bindings and textOnly is set t o true',
13 (Interpolate interpolate) { 13 inject((Interpolate $interpolate) {
14 expect(interpolate('some text', true)).toBe(null); 14 expect($interpolate('some text', true)).toBe(null);
15 }); 15 }));
16 16
17 it('should return an expression', (Interpolate interpolate) { 17 it('should suppress falsy objects', inject((Interpolate $interpolate) {
18 expect(interpolate('Hello {{name}}!')) 18 expect($interpolate('{{undefined}}')([null])).toEqual('');
19 .toEqual('"Hello "+(name|stringify)+"!"'); 19 expect($interpolate('{{undefined+undefined}}')([null])).toEqual('');
20 expect(interpolate('a{{b}}C')) 20 expect($interpolate('{{null}}')([null])).toEqual('');
21 .toEqual('"a"+(b|stringify)+"C"'); 21 expect($interpolate('{{a.b}}')([null])).toEqual('');
22 expect(interpolate('a{{b}}')).toEqual('"a"+(b|stringify)'); 22 }));
23 expect(interpolate('{{a}}b')).toEqual('(a|stringify)+"b"');
24 expect(interpolate('{{b}}')).toEqual('(b|stringify)');
25 expect(interpolate('{{b}}+{{c}}'))
26 .toEqual('(b|stringify)+"+"+(c|stringify)');
27 expect(interpolate('{{b}}x{{c}}'))
28 .toEqual('(b|stringify)+"x"+(c|stringify)');
29 });
30 23
31 it('should Parse Multiline', (Interpolate interpolate) { 24 it('should jsonify objects', inject((Interpolate $interpolate) {
32 expect(interpolate("X\nY{{A\n+B}}C\nD")) 25 expect($interpolate('{{ {} }}')([{}])).toEqual('{}');
33 .toEqual('"X\nY"+(A\n+B|stringify)+"C\nD"'); 26 expect($interpolate('{{ true }}')([true])).toEqual('true');
34 }); 27 expect($interpolate('{{ false }}')([false])).toEqual('false');
28 }));
35 29
36 it('should escape double quotes', (Interpolate interpolate) { 30
37 expect(interpolate(r'"{{a}}')).toEqual(r'"\""+(a|stringify)'); 31 it('should return interpolation function', inject((Interpolate $interpolate, Scope rootScope) {
38 expect(interpolate(r'\"{{a}}')).toEqual(r'"\\\""+(a|stringify)'); 32 rootScope.context['name'] = 'Misko';
33 var fn = $interpolate('Hello {{name}}!');
34 expect(fn(['Misko'])).toEqual('Hello Misko!');
35 }));
36
37
38 it('should ignore undefined model', inject((Interpolate $interpolate) {
39 expect($interpolate("Hello {{'World' + foo}}")(['World'])).toEqual('Hello World');
40 }));
41
42
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!');
45 }));
46
47
48 describe('parseBindings', () {
49 it('should Parse Text With No Bindings', inject((Interpolate $interpolate) {
50 var parts = $interpolate("a").seperators;
51 expect(parts.length).toEqual(1);
52 expect(parts[0]).toEqual("a");
53 }));
54
55 it('should Parse Empty Text', inject((Interpolate $interpolate) {
56 var parts = $interpolate("").seperators;
57 expect(parts.length).toEqual(1);
58 expect(parts[0]).toEqual("");
59 }));
60
61 it('should Parse Inner Binding', inject((Interpolate $interpolate) {
62 var parts = $interpolate("a{{b}}C").seperators;
63 expect(parts.length).toEqual(2);
64 expect(parts[0]).toEqual("a");
65 expect(parts[1]).toEqual("C");
66 }));
67
68 it('should Parse Ending Binding', inject((Interpolate $interpolate) {
69 var parts = $interpolate("a{{b}}").seperators;
70 expect(parts.length).toEqual(2);
71 expect(parts[0]).toEqual("a");
72 expect(parts[1]).toEqual("");
73 }));
74
75 it('should Parse Begging Binding', inject((Interpolate $interpolate) {
76 var parts = $interpolate("{{b}}c").seperators;
77 expect(parts.length).toEqual(2);
78 expect(parts[0]).toEqual("");
79 expect(parts[1]).toEqual("c");
80 }));
81
82 it('should Parse Loan Binding', inject((Interpolate $interpolate) {
83 var parts = $interpolate("{{b}}").seperators;
84 expect(parts.length).toEqual(2);
85 expect(parts[0]).toEqual("");
86 expect(parts[1]).toEqual("");
87 }));
88
89 it('should Parse Two Bindings', inject((Interpolate $interpolate) {
90 var parts = $interpolate("{{b}}{{c}}").seperators;
91 expect(parts.length).toEqual(3);
92 expect(parts[0]).toEqual("");
93 expect(parts[1]).toEqual("");
94 expect(parts[2]).toEqual("");
95 }));
96
97 it('should Parse Two Bindings With Text In Middle', inject((Interpolate $i nterpolate) {
98 var parts = $interpolate("{{b}}x{{c}}").seperators;
99 expect(parts.length).toEqual(3);
100 expect(parts[0]).toEqual("");
101 expect(parts[1]).toEqual("x");
102 expect(parts[2]).toEqual("");
103 }));
104
105 it('should Parse Multiline', inject((Interpolate $interpolate) {
106 var parts = $interpolate('"X\nY{{A\n+B}}C\nD"').seperators;
107 expect(parts.length).toEqual(2);
108 expect(parts[0]).toEqual('"X\nY');
109 expect(parts[1]).toEqual('C\nD"');
110 }));
39 }); 111 });
40 }); 112 });
41 } 113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698