Skip to content

Commit 744be0d

Browse files
authored
test(result): Complete the it.todo (#1240)
* test(result): 增加对title和desc的测试
1 parent 843234d commit 744be0d

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

packages/devui-vue/devui/result/__tests__/result.spec.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { mount } from '@vue/test-utils';
22
import { Result } from '../index';
3+
import { useNamespace } from '../../shared/hooks/use-namespace';
4+
5+
const ns = useNamespace('result', true);
6+
7+
const titleClass = ns.e('title');
8+
const descClass = ns.e('desc');
39

410
describe('result test', () => {
511
it('result init render', async () => {
@@ -42,7 +48,28 @@ describe('result test', () => {
4248
expect(wrapper.element.children[3].innerHTML).toEqual('This is extra slot');
4349
});
4450

45-
it.todo('props title work well.');
51+
it('props title', async () => {
52+
const wrapper = mount(Result);
53+
expect(wrapper.find(titleClass).exists()).toBe(true);
54+
// 测试不传入值的情况
55+
expect(wrapper.find(titleClass).text()).toBe('');
56+
await wrapper.setProps({
57+
title: '标题-测试title',
58+
});
59+
expect(wrapper.find(titleClass).text()).toBe('标题-测试title');
60+
});
4661

47-
it.todo('props desc work well.');
62+
it('props desc', async () => {
63+
const wrapper = mount(Result);
64+
expect(wrapper.find(titleClass).exists()).toBe(true);
65+
// 测试不传入值的情况
66+
expect(wrapper.find(titleClass).text()).toBe('');
67+
expect(wrapper.find(descClass).text()).toBe('');
68+
await wrapper.setProps({
69+
title: '标题-测试desc',
70+
desc: '描述-测试desc',
71+
});
72+
expect(wrapper.find(titleClass).text()).toBe('标题-测试desc');
73+
expect(wrapper.find(descClass).text()).toBe('描述-测试desc');
74+
});
4875
});

0 commit comments

Comments
 (0)