import { shallowMount } from '@vue/test-utils'; 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('should render', () => { const App = { render() { return
1234
; }, }; const wrapper = shallowMount(App); expect(wrapper.html()).toBe('
1234
'); }); 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('Spread (single object expression)', () => { const props = { innerHTML: 123, other: '1', }; const wrapper = shallowMount({ render() { return
; }, }); expect(wrapper.html()).toBe('
123
'); }); test('Spread (mixed)', () => { const calls = []; const data = { id: 'hehe', onClick() { calls.push(3); }, innerHTML: 2, class: ['a', 'b'], }; shallowMount({ setup() { return () => (
calls.push(4)} hook-insert={() => calls.push(2)} /> ); }, }); });