import { BindingTypes } from '@vue/compiler-dom' import { compileSFCScript as compile, assertCode } from './utils' describe('SFC compile `) assertCode(content) expect(content).toMatch('return { a, b, c, d, x }') }) test('defineProps()', () => { const { content, bindings } = compile(` `) // should generate working code assertCode(content) // should anayze bindings expect(bindings).toStrictEqual({ foo: BindingTypes.PROPS, bar: BindingTypes.SETUP_CONST, props: BindingTypes.SETUP_CONST }) // should remove defineOptions import and call expect(content).not.toMatch('defineProps') // should generate correct setup signature expect(content).toMatch(`setup(__props) {`) // should assign user identifier to it expect(content).toMatch(`const props = __props`) // should include context options in default export expect(content).toMatch(`export default { expose: [], props: { foo: String },`) }) test('defineEmit()', () => { const { content, bindings } = compile(` `) assertCode(content) expect(bindings).toStrictEqual({ myEmit: BindingTypes.SETUP_CONST }) // should remove defineOptions import and call expect(content).not.toMatch('defineEmit') // should generate correct setup signature expect(content).toMatch(`setup(__props, { emit: myEmit }) {`) // should include context options in default export expect(content).toMatch(`export default { expose: [], emits: ['foo', 'bar'],`) }) test('