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 2323=========="
2424`;
2525
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+
2648exports[`classic components handles \`ariaRole\` correctly 1`] = `
2749" ==========
2850
191213=========="
192214`;
193215
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+
194236exports[`classic components multi-line template 1`] = `
195237" ==========
196238export default Component.extend({});
511553 }
512554
513555~~~~~~~~~~
514- <div class =\\"{{styleNamespace}} foo bar:baz\\" ...attributes>
556+ <div class =\\"{{this. styleNamespace}} foo bar:baz\\" ...attributes>
515557 foo
516558</div>
517559=========="
Original file line number Diff line number Diff line change @@ -231,6 +231,26 @@ describe('classic components', function() {
231231 expect ( generateSnapshot ( source , template ) ) . toMatchSnapshot ( ) ;
232232 } ) ;
233233
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+
234254 test ( 'handles `hasComponentCSS` option correctly' , ( ) => {
235255 let source = `
236256 export default Component.extend({
Original file line number Diff line number Diff line change 11function 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+ ) ;
613}
714
815module . exports = {
You can’t perform that action at this time.
0 commit comments