File tree Expand file tree Collapse file tree 3 files changed +74
-5
lines changed Expand file tree Collapse file tree 3 files changed +74
-5
lines changed Original file line number Diff line number Diff line change 23
23
=========="
24
24
`;
25
25
26
+ exports[`classic components empty lines are not intended 1`] = `
27
+ " ==========
28
+ export default Component.extend({});
29
+ ~~~~~~~~~~
30
+ foo
31
+
32
+ bar
33
+ ~~~~~~~~~~
34
+ => tagName: div
35
+ ~~~~~~~~~~
36
+ export default Component.extend({
37
+ tagName: \\" \\"
38
+ });
39
+ ~~~~~~~~~~
40
+ <div ...attributes>
41
+ foo
42
+
43
+ bar
44
+ </div>
45
+ =========="
46
+ `;
47
+
26
48
exports[`classic components handles \`ariaRole\` correctly 1`] = `
27
49
" ==========
28
50
191
213
=========="
192
214
`;
193
215
216
+ exports[`classic components leading and trailing empty lines are stripped 1`] = `
217
+ " ==========
218
+ export default Component.extend({});
219
+ ~~~~~~~~~~
220
+
221
+ foo
222
+
223
+ ~~~~~~~~~~
224
+ => tagName: div
225
+ ~~~~~~~~~~
226
+ export default Component.extend({
227
+ tagName: \\" \\"
228
+ });
229
+ ~~~~~~~~~~
230
+ <div ...attributes>
231
+ foo
232
+ </div>
233
+ =========="
234
+ `;
235
+
194
236
exports[`classic components multi-line template 1`] = `
195
237
" ==========
196
238
export default Component.extend({});
511
553
}
512
554
513
555
~~~~~~~~~~
514
- <div class =\\"{{styleNamespace}} foo bar:baz\\" ...attributes>
556
+ <div class =\\"{{this. styleNamespace}} foo bar:baz\\" ...attributes>
515
557
foo
516
558
</div>
517
559
=========="
Original file line number Diff line number Diff line change @@ -231,6 +231,26 @@ describe('classic components', function() {
231
231
expect ( generateSnapshot ( source , template ) ) . toMatchSnapshot ( ) ;
232
232
} ) ;
233
233
234
+ test ( 'empty lines are not intended' , ( ) => {
235
+ let source = `export default Component.extend({});` ;
236
+
237
+ let template = `foo
238
+
239
+ bar` ;
240
+
241
+ expect ( generateSnapshot ( source , template ) ) . toMatchSnapshot ( ) ;
242
+ } ) ;
243
+
244
+ test ( 'leading and trailing empty lines are stripped' , ( ) => {
245
+ let source = `export default Component.extend({});` ;
246
+
247
+ let template = `
248
+ foo
249
+ ` ;
250
+
251
+ expect ( generateSnapshot ( source , template ) ) . toMatchSnapshot ( ) ;
252
+ } ) ;
253
+
234
254
test ( 'handles `hasComponentCSS` option correctly' , ( ) => {
235
255
let source = `
236
256
export default Component.extend({
Original file line number Diff line number Diff line change 1
1
function indentLines ( content ) {
2
- return content
3
- . split ( '\n' )
4
- . map ( it => ` ${ it } ` )
5
- . join ( '\n' ) ;
2
+ return (
3
+ content
4
+ // strip leading and trailing new lines
5
+ . trim ( )
6
+ . split ( '\n' )
7
+ . map ( it => {
8
+ // intend non-empty lines with two spaces
9
+ return it . trim ( ) . length > 0 ? ` ${ it } ` : '' ;
10
+ } )
11
+ . join ( '\n' )
12
+ ) ;
6
13
}
7
14
8
15
module . exports = {
You can’t perform that action at this time.
0 commit comments