import test from 'ava' import { transform } from 'babel-core' const transpile = src => { return transform(src, { plugins: './index' }).code.trim() } const testTranspile = (title, code) => { test(title, t => { const compiled = transpile(code) t.snapshot(code, 'Initial code') t.snapshot(compiled, 'Compiled code') }) } const testError = (title, code) => { test(title, t => { const error = t.throws(() => transpile(code), SyntaxError) t.snapshot(code, 'Initial code') t.snapshot(error.message, 'Error mesage') }) } testError( 'Error: input[type={dynamic}, v-model]', ` ` ) testError( 'Error: input[v-model:invalidModifier]', ` ` ) testError( 'Error: input[v-model, v-model]', ` ` ) testError( 'Error: input[v-model="string literal"]', ` ` ) testError( 'Error: input[v-model={identifier}]', ` ` ) testError( 'Error: h3', `

` ) testError( 'Error: select[v-model:trim]', ` ` ) testError( 'Error: input[type="radio",v-model:trim]', ` ` ) testError( 'Error: input[type="file",v-model]', ` ` ) testTranspile( 'Ignores namespaced attributes', ` ` ) testTranspile( 'textarea[v-model]', `