style: format code

This commit is contained in:
Amour1688 2021-03-22 10:26:54 +08:00
parent 3a83e668f4
commit 1972dbad32

View File

@ -4,6 +4,7 @@ import {
defineComponent, defineComponent,
CSSProperties, CSSProperties,
ComponentPublicInstance, ComponentPublicInstance,
Transition,
} from 'vue'; } from 'vue';
import { shallowMount, mount, VueWrapper } from '@vue/test-utils'; import { shallowMount, mount, VueWrapper } from '@vue/test-utils';
@ -415,31 +416,37 @@ describe('variables outside slots', () => {
A.inheritAttrs = false; A.inheritAttrs = false;
test('internal', async () => { test('internal', async () => {
const wrapper = mount(defineComponent({ const wrapper = mount(
data() { defineComponent({
return { data() {
val: 0, return {
}; val: 0,
}, };
methods: {
inc() {
this.val += 1;
}, },
}, methods: {
render() { inc() {
const attrs = { this.val += 1;
innerHTML: `${this.val}`, },
}; },
return ( render() {
<A inc={this.inc}> const attrs = {
<div> innerHTML: `${this.val}`,
<textarea id="textarea" {...attrs} /> };
</div> return (
<button id="button" onClick={this.inc}>+1</button> <A inc={this.inc}>
</A> <div>
); <Transition name="foo">
}, <textarea id="textarea" {...attrs} />
})); </Transition>
</div>
<button id="button" onClick={this.inc}>
+1
</button>
</A>
);
},
}),
);
expect(wrapper.get('#textarea').element.innerHTML).toBe('0'); expect(wrapper.get('#textarea').element.innerHTML).toBe('0');
await wrapper.get('#button').trigger('click'); await wrapper.get('#button').trigger('click');
@ -466,7 +473,9 @@ describe('variables outside slots', () => {
return ( return (
<A inc={this.inc}> <A inc={this.inc}>
<div>{textarea}</div> <div>{textarea}</div>
<button id="button" onClick={this.inc}>+1</button> <button id="button" onClick={this.inc}>
+1
</button>
</A> </A>
); );
}, },
@ -562,9 +571,7 @@ describe('should support passing object slots via JSX children', () => {
test('single expression, function expression', () => { test('single expression, function expression', () => {
const wrapper = mount({ const wrapper = mount({
render() { render() {
return ( return <A>{() => 'foo'}</A>;
<A>{() => 'foo'}</A>
);
}, },
}); });
@ -576,9 +583,7 @@ describe('should support passing object slots via JSX children', () => {
const wrapper = mount({ const wrapper = mount({
render() { render() {
return ( return <A>{foo}</A>;
<A>{foo}</A>
);
}, },
}); });
@ -592,13 +597,19 @@ describe('should support passing object slots via JSX children', () => {
render() { render() {
return ( return (
<> <>
{data.map((item) => <A><span>{item}</span></A>)} {data.map((item) => (
<A>
<span>{item}</span>
</A>
))}
</> </>
); );
}, },
}); });
expect(wrapper.html()).toBe('<span><span>A</span><!----></span><span><span>B</span><!----></span><span><span>C</span><!----></span>'); expect(wrapper.html()).toBe(
'<span><span>A</span><!----></span><span><span>B</span><!----></span><span><span>C</span><!----></span>',
);
}); });
test('xx', () => { test('xx', () => {
@ -608,12 +619,16 @@ describe('should support passing object slots via JSX children', () => {
render() { render() {
return ( return (
<> <>
{data.map((item) => <A>{() => <span>{item}</span>}</A>)} {data.map((item) => (
<A>{() => <span>{item}</span>}</A>
))}
</> </>
); );
}, },
}); });
expect(wrapper.html()).toBe('<span><span>A</span><!----></span><span><span>B</span><!----></span><span><span>C</span><!----></span>'); expect(wrapper.html()).toBe(
'<span><span>A</span><!----></span><span><span>B</span><!----></span><span><span>C</span><!----></span>',
);
}); });
}); });