import { compile } from '../../src' describe('Transition multi children warnings', () => { function checkWarning( template: string, shouldWarn: boolean, message = ` expects exactly one child element or component.` ) { const spy = jest.fn() compile(template.trim(), { hoistStatic: true, transformHoist: null, onError: err => { spy(err.message) } }) if (shouldWarn) expect(spy).toHaveBeenCalledWith(message) else expect(spy).not.toHaveBeenCalled() } test('warns if multiple children', () => { checkWarning( `
hey
hey
`, true ) }) test('warns with v-for', () => { checkWarning( `
hey
`, true ) }) test('warns with multiple v-if + v-for', () => { checkWarning( `
hey
hey
`, true ) }) test('warns with template v-if', () => { checkWarning( ` `, true ) }) test('warns with multiple templates', () => { checkWarning( ` `, true ) }) test('warns if multiple children with v-if', () => { checkWarning( `
hey
hey
`, true ) }) test('does not warn with regular element', () => { checkWarning( `
hey
`, false ) }) test('does not warn with one single v-if', () => { checkWarning( `
hey
`, false ) }) test('does not warn with v-if v-else-if v-else', () => { checkWarning( `
hey
hey
hey
`, false ) }) test('does not warn with v-if v-else', () => { checkWarning( `
hey
hey
`, false ) }) }) test('inject persisted when child has v-show', () => { expect( compile(`
`).code ).toMatchSnapshot() }) test('the v-if/else-if/else branches in Transition should ignore comments', () => { expect( compile(`
hey
hey

`).code ).toMatchSnapshot() })