import { shallowMount } from '@vue/test-utils'; test('should render with render function', () => { const wrapper = shallowMount({ render() { return
123
; }, }); expect(wrapper.text()).toBe('123'); }); test('should render with setup', () => { const wrapper = shallowMount({ setup() { return () =>
123
; }, }); expect(wrapper.text()).toBe('123'); }); test('Extracts attrs', () => { const wrapper = shallowMount({ setup() { return () =>
; }, }); expect(wrapper.element.id).toBe('hi'); expect(wrapper.element.dir).toBe('ltr'); }); test('Binds attrs', () => { const id = 'foo'; const wrapper = shallowMount({ setup() { return () =>
{id}
; }, }); expect(wrapper.text()).toBe('foo'); }); test('should not fallthrough with inheritAttrs: false', () => { const Child = (props) =>
{props.foo}
; Child.inheritAttrs = false; const wrapper = shallowMount({ setup() { return () => ( ); }, }); expect(wrapper.text()).toBe('1'); }); test('Fragment', () => { const Child = () =>
123
; Child.inheritAttrs = false; const wrapper = shallowMount({ setup() { return () => ( <>
456
); }, }); expect(wrapper.html()).toBe('
123
456
'); }); test('xlink:href', () => { const wrapper = shallowMount({ setup() { return () => ; }, }); expect(wrapper.attributes()['xlink:href']).toBe('#name'); }); test('Merge class', () => { const wrapper = shallowMount({ setup() { return () =>
; }, }); expect(wrapper.html()).toBe('
'); }); test('Merge style', () => { const propsA = { style: { color: 'red', }, }; const propsB = { style: [ { color: 'blue', width: '200px', }, { width: '300px', height: '300px', }, ], }; const wrapper = shallowMount({ setup() { return () =>
; }, }); expect(wrapper.html()).toBe('
'); }); test('JSXSpreadChild', () => { const a = ['1', '2']; const wrapper = shallowMount({ setup() { return () =>
{[...a]}
; }, }); expect(wrapper.text()).toBe('12'); }); test('domProps input[value]', () => { const val = 'foo'; const wrapper = shallowMount({ setup() { return () => ; }, }); expect(wrapper.html()).toBe(''); }); test('domProps input[checked]', () => { const val = 'foo'; const wrapper = shallowMount({ setup() { return () => ; }, }); expect(wrapper.vm.$.subTree.props.checked).toBe(val); }); test('domProps option[selected]', () => { const val = 'foo'; const wrapper = shallowMount({ render() { return