|
1 |
| -import {describe, beforeEach, it, expect, iit, ddescribe} from 'test_lib/test_lib'; |
| 1 | +import {describe, beforeEach, it, expect, iit, ddescribe, el} from 'test_lib/test_lib'; |
2 | 2 | import {isPresent} from 'facade/lang';
|
3 | 3 | import {ListWrapper, MapWrapper, StringMapWrapper} from 'facade/collection';
|
4 | 4 | import {DirectiveParser} from 'core/compiler/pipeline/directive_parser';
|
@@ -50,126 +50,126 @@ export function main() {
|
50 | 50 | }
|
51 | 51 |
|
52 | 52 | it('should not add directives if they are not used', () => {
|
53 |
| - var results = createPipeline().process(createElement('<div></div>')); |
| 53 | + var results = createPipeline().process(el('<div></div>')); |
54 | 54 | expect(results[0].decoratorDirectives).toBe(null);
|
55 | 55 | expect(results[0].componentDirective).toBe(null);
|
56 | 56 | expect(results[0].templateDirective).toBe(null);
|
57 | 57 | });
|
58 | 58 |
|
59 | 59 | describe('component directives', () => {
|
60 | 60 | it('should detect them in attributes', () => {
|
61 |
| - var results = createPipeline().process(createElement('<div some-comp></div>')); |
| 61 | + var results = createPipeline().process(el('<div some-comp></div>')); |
62 | 62 | expect(results[0].componentDirective).toEqual(reader.read(SomeComponent));
|
63 | 63 | });
|
64 | 64 |
|
65 | 65 | it('should detect them in property bindings', () => {
|
66 | 66 | var pipeline = createPipeline({propertyBindings: {
|
67 | 67 | 'some-comp': 'someExpr'
|
68 | 68 | }});
|
69 |
| - var results = pipeline.process(createElement('<div></div>')); |
| 69 | + var results = pipeline.process(el('<div></div>')); |
70 | 70 | expect(results[0].componentDirective).toEqual(reader.read(SomeComponent));
|
71 | 71 | });
|
72 | 72 |
|
73 | 73 | it('should detect them in variable bindings', () => {
|
74 | 74 | var pipeline = createPipeline({variableBindings: {
|
75 | 75 | 'some-comp': 'someExpr'
|
76 | 76 | }});
|
77 |
| - var results = pipeline.process(createElement('<div></div>')); |
| 77 | + var results = pipeline.process(el('<div></div>')); |
78 | 78 | expect(results[0].componentDirective).toEqual(reader.read(SomeComponent));
|
79 | 79 | });
|
80 | 80 |
|
81 | 81 | it('should not allow multiple component directives on the same element', () => {
|
82 | 82 | expect( () => {
|
83 | 83 | createPipeline().process(
|
84 |
| - createElement('<div some-comp some-comp2></div>') |
| 84 | + el('<div some-comp some-comp2></div>') |
85 | 85 | );
|
86 | 86 | }).toThrowError('Only one component directive per element is allowed!');
|
87 | 87 | });
|
88 | 88 |
|
89 | 89 | it('should not allow component directives on <template> elements', () => {
|
90 | 90 | expect( () => {
|
91 | 91 | createPipeline().process(
|
92 |
| - createElement('<template some-comp></template>') |
| 92 | + el('<template some-comp></template>') |
93 | 93 | );
|
94 | 94 | }).toThrowError('Only template directives are allowed on <template> elements!');
|
95 | 95 | });
|
96 | 96 | });
|
97 | 97 |
|
98 | 98 | describe('template directives', () => {
|
99 | 99 | it('should detect them in attributes', () => {
|
100 |
| - var results = createPipeline().process(createElement('<template some-templ></template>')); |
| 100 | + var results = createPipeline().process(el('<template some-templ></template>')); |
101 | 101 | expect(results[0].templateDirective).toEqual(reader.read(SomeTemplate));
|
102 | 102 | });
|
103 | 103 |
|
104 | 104 | it('should detect them in property bindings', () => {
|
105 | 105 | var pipeline = createPipeline({propertyBindings: {
|
106 | 106 | 'some-templ': 'someExpr'
|
107 | 107 | }});
|
108 |
| - var results = pipeline.process(createElement('<template></template>')); |
| 108 | + var results = pipeline.process(el('<template></template>')); |
109 | 109 | expect(results[0].templateDirective).toEqual(reader.read(SomeTemplate));
|
110 | 110 | });
|
111 | 111 |
|
112 | 112 | it('should detect them in variable bindings', () => {
|
113 | 113 | var pipeline = createPipeline({variableBindings: {
|
114 | 114 | 'some-templ': 'someExpr'
|
115 | 115 | }});
|
116 |
| - var results = pipeline.process(createElement('<template></template>')); |
| 116 | + var results = pipeline.process(el('<template></template>')); |
117 | 117 | expect(results[0].templateDirective).toEqual(reader.read(SomeTemplate));
|
118 | 118 | });
|
119 | 119 |
|
120 | 120 | it('should not allow multiple template directives on the same element', () => {
|
121 | 121 | expect( () => {
|
122 | 122 | createPipeline().process(
|
123 |
| - createElement('<template some-templ some-templ2></template>') |
| 123 | + el('<template some-templ some-templ2></template>') |
124 | 124 | );
|
125 | 125 | }).toThrowError('Only one template directive per element is allowed!');
|
126 | 126 | });
|
127 | 127 |
|
128 | 128 | it('should not allow template directives on non <template> elements', () => {
|
129 | 129 | expect( () => {
|
130 | 130 | createPipeline().process(
|
131 |
| - createElement('<div some-templ></div>') |
| 131 | + el('<div some-templ></div>') |
132 | 132 | );
|
133 | 133 | }).toThrowError('Template directives need to be placed on <template> elements or elements with template attribute!');
|
134 | 134 | });
|
135 | 135 | });
|
136 | 136 |
|
137 | 137 | describe('decorator directives', () => {
|
138 | 138 | it('should detect them in attributes', () => {
|
139 |
| - var results = createPipeline().process(createElement('<div some-decor></div>')); |
| 139 | + var results = createPipeline().process(el('<div some-decor></div>')); |
140 | 140 | expect(results[0].decoratorDirectives).toEqual([reader.read(SomeDecorator)]);
|
141 | 141 | });
|
142 | 142 |
|
143 | 143 | it('should detect them in property bindings', () => {
|
144 | 144 | var pipeline = createPipeline({propertyBindings: {
|
145 | 145 | 'some-decor': 'someExpr'
|
146 | 146 | }});
|
147 |
| - var results = pipeline.process(createElement('<div></div>')); |
| 147 | + var results = pipeline.process(el('<div></div>')); |
148 | 148 | expect(results[0].decoratorDirectives).toEqual([reader.read(SomeDecorator)]);
|
149 | 149 | });
|
150 | 150 |
|
151 | 151 | it('should compile children by default', () => {
|
152 |
| - var results = createPipeline().process(createElement('<div some-decor></div>')); |
| 152 | + var results = createPipeline().process(el('<div some-decor></div>')); |
153 | 153 | expect(results[0].compileChildren).toEqual(true);
|
154 | 154 | });
|
155 | 155 |
|
156 | 156 | it('should stop compiling children when specified in the decorator config', () => {
|
157 |
| - var results = createPipeline().process(createElement('<div some-decor-ignoring-children></div>')); |
| 157 | + var results = createPipeline().process(el('<div some-decor-ignoring-children></div>')); |
158 | 158 | expect(results[0].compileChildren).toEqual(false);
|
159 | 159 | });
|
160 | 160 |
|
161 | 161 | it('should detect them in variable bindings', () => {
|
162 | 162 | var pipeline = createPipeline({variableBindings: {
|
163 | 163 | 'some-decor': 'someExpr'
|
164 | 164 | }});
|
165 |
| - var results = pipeline.process(createElement('<div></div>')); |
| 165 | + var results = pipeline.process(el('<div></div>')); |
166 | 166 | expect(results[0].decoratorDirectives).toEqual([reader.read(SomeDecorator)]);
|
167 | 167 | });
|
168 | 168 |
|
169 | 169 | it('should not allow decorator directives on <template> elements', () => {
|
170 | 170 | expect( () => {
|
171 | 171 | createPipeline().process(
|
172 |
| - createElement('<template some-decor></template>') |
| 172 | + el('<template some-decor></template>') |
173 | 173 | );
|
174 | 174 | }).toThrowError('Only template directives are allowed on <template> elements!');
|
175 | 175 | });
|
@@ -226,7 +226,3 @@ class SomeComponent2 {}
|
226 | 226 | })
|
227 | 227 | })
|
228 | 228 | class MyComp {}
|
229 |
| - |
230 |
| -function createElement(html) { |
231 |
| - return DOM.createTemplate(html).content.firstChild; |
232 |
| -} |
0 commit comments