@@ -73,7 +73,7 @@ describe('parser', () => {
7373
7474 it ( 'not contain root element' , ( ) => {
7575 parse ( 'hello world' , baseOptions )
76- expect ( 'Component template should contain exactly one root element' ) . toHaveBeenWarned ( )
76+ expect ( 'Component template requires a root element, rather than just text ' ) . toHaveBeenWarned ( )
7777 } )
7878
7979 it ( 'warn multiple root elements' , ( ) => {
@@ -83,10 +83,28 @@ describe('parser', () => {
8383
8484 it ( 'not warn 2 root elements with v-if and v-else' , ( ) => {
8585 parse ( '<div v-if="1"></div><div v-else></div>' , baseOptions )
86- expect ( 'Component template should contain exactly one root element:\n\n<div v-if="1"></div><div v-else></div> ' )
86+ expect ( 'Component template should contain exactly one root element' )
8787 . not . toHaveBeenWarned ( )
8888 } )
8989
90+ it ( 'not warn 2 root elements with v-if and v-else on separate lines' , ( ) => {
91+ parse ( `
92+ <div v-if="1"></div>
93+ <div v-else></div>
94+ ` , baseOptions )
95+ expect ( 'Component template should contain exactly one root element' )
96+ . not . toHaveBeenWarned ( )
97+ } )
98+
99+ it ( 'generate correct ast for 2 root elements with v-if and v-else on separate lines' , ( ) => {
100+ const ast = parse ( `
101+ <div v-if="1"></div>
102+ <p v-else></p>
103+ ` , baseOptions )
104+ expect ( ast . tag ) . toBe ( 'div' )
105+ expect ( ast . elseBlock . tag ) . toBe ( 'p' )
106+ } )
107+
90108 it ( 'warn 2 root elements with v-if' , ( ) => {
91109 parse ( '<div v-if="1"></div><div v-if="2"></div>' , baseOptions )
92110 expect ( 'Component template should contain exactly one root element:\n\n<div v-if="1"></div><div v-if="2"></div>' )
0 commit comments