Skip to content

Commit d8dca2c

Browse files
committed
feat: 修改单测
1 parent ac68691 commit d8dca2c

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

devui/skeleton/__tests__/skeleton.spec.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,59 @@ import { ref } from 'vue';
33
import DSkeleton from '../src/skeleton';
44

55
describe('skeleton 组件', () => {
6-
it('render basic skeleton successfully', () => {
7-
const row = ref(4);
6+
it('render basic skeleton', () => {
7+
const row = ref(4)
88
const wrapper = mount({
99
components: { DSkeleton },
1010
template: `<d-skeleton :row="row" />`,
1111
setup() {
1212
return {
1313
row
14-
};
14+
}
1515
},
16-
});
16+
})
1717

1818
expect(wrapper.classes()).toContain('devui-skeleton')
1919
expect(wrapper.classes()).toContain('devui-skeleton-animated')
20-
expect(wrapper.element.childElementCount).toBe(1)
21-
// 渲染个数应当与传入的 row 的数量相同
22-
expect(wrapper.element.children[0].childElementCount).toBe(4)
20+
expect(wrapper.element.childElementCount).toBe(2)
21+
expect(wrapper.element.children[1].children[1].childElementCount).toBe(4)
2322
})
2423

2524
it('render skeleton without animate', () => {
26-
const animate = ref(false);
25+
const animate = ref(false)
2726
const wrapper = mount({
2827
components: { DSkeleton },
2928
template: `<d-skeleton :animate="animate" />`,
3029
setup() {
3130
return {
3231
animate
33-
};
32+
}
3433
},
35-
});
34+
})
3635

37-
expect(wrapper.classes()).toContain('devui-skeleton-no-animated')
36+
expect(wrapper.classes()).toEqual(['devui-skeleton'])
3837
})
3938

40-
it('render skeleton with avatar', () => {
41-
const avatar = ref(true);
39+
it('render skeleton without title and paragraph', () => {
40+
const title = ref(false)
41+
const paragraph = ref(false)
4242
const wrapper = mount({
4343
components: { DSkeleton },
44-
template: `<d-skeleton :avatar="avatar" />`,
44+
template: `<d-skeleton :title="title" :paragraph="paragraph" />`,
4545
setup() {
4646
return {
47-
avatar
48-
};
47+
title,
48+
paragraph
49+
}
4950
},
50-
});
51-
52-
expect(wrapper.element.childElementCount).toBe(2)
53-
expect(wrapper.element.children[0].innerHTML).toBe('<div class="avatar"></div>')
51+
})
52+
53+
expect(wrapper.element.children[1].childElementCount).toBe(2)
5454
})
5555

5656
it('hide skeleton and show real content', () => {
57-
const row = ref(4);
58-
const loading = ref(false);
57+
const row = ref(4)
58+
const loading = ref(false)
5959
const wrapper = mount({
6060
components: { DSkeleton },
6161
template: `
@@ -71,9 +71,9 @@ describe('skeleton 组件', () => {
7171
return {
7272
row,
7373
loading
74-
};
74+
}
7575
},
76-
});
76+
})
7777

7878
expect(wrapper.classes()).toContain('devui-skeleton')
7979
expect(wrapper.element.children[0].innerHTML).toBe('<div>content1</div><div>content2</div><div>content3</div><div>content4</div>')

0 commit comments

Comments
 (0)