Skip to content

Commit 139fd3a

Browse files
committed
test(switch): 解决switch组件单元测试问题
1 parent 1335b9d commit 139fd3a

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ describe('d-switch', () => {
5252
it('switch size work', async () => {
5353
const wrapper = mount(DSwitch, {
5454
props: {
55-
size: 'small'
55+
size: 'sm'
5656
}
5757
});
5858

5959
expect(wrapper.classes()).toContain('devui-switch-sm');
6060

6161
await wrapper.setProps({
62-
size: 'large'
62+
size: 'lg'
6363
});
6464
expect(wrapper.classes()).not.toContain('devui-switch-sm');
6565
expect(wrapper.classes()).toContain('devui-switch-lg');

packages/devui-vue/devui/switch/src/switch-types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type { ExtractPropTypes, PropType } from 'vue';
22

33
export const switchProps = {
44
size: {
5-
type: String as PropType<'small' | 'middle' | 'large'>,
6-
default: 'middle'
5+
type: String as PropType<'sm' | 'md' | 'lg'>,
6+
default: 'md'
77
},
88
color: {
99
type: String,

packages/devui-vue/devui/switch/src/switch.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
left: 19px;
7979
}
8080

81-
&.devui-switch-large {
81+
&.devui-switch-lg {
8282
width: 58px;
8383
height: 30px;
8484
border-radius: math.div(32px, 2);
@@ -106,7 +106,7 @@
106106
}
107107
}
108108

109-
&.devui-switch-small {
109+
&.devui-switch-sm {
110110
width: 30px;
111111
height: 14px;
112112
border-radius: math.div(16px, 2);

packages/devui-vue/docs/components/switch/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
### size
1010

11-
:::demo size可选:`small | middle | large`,默认为middle
11+
:::demo size可选:`sm | md | lg`,默认为`md`
1212
```vue
1313
<template>
14-
<d-switch v-model:checked="checkedSmall" size="small"></d-switch>
15-
<d-switch v-model:checked="uncheckedMiddle" ></d-switch>
16-
<d-switch v-model:checked="checkedLarge" size="large"></d-switch>
14+
<d-switch v-model:checked="checkedSmall" size="sm"></d-switch>
15+
<d-switch v-model:checked="uncheckedMiddle"></d-switch>
16+
<d-switch v-model:checked="checkedLarge" size="lg"></d-switch>
1717
</template>
1818
<script>
1919
import { defineComponent, ref } from 'vue'
@@ -101,7 +101,7 @@ export default defineComponent({
101101

102102
| 参数 | 类型 | 默认 | 说明 | 跳转 Demo |
103103
| :--------------: | :------------------------: | :------: | :--------------------------: | :------------------------ |
104-
| size | `small \| middle \| large` | `middle` | 可选,开关尺寸大小 | [size](#size) |
104+
| size | `sm \| md \| lg` | `md` | 可选,开关尺寸大小 | [size](#size) |
105105
| color | `string` | -- | 可选,开关打开时的自定义颜色 | [自定义样式](#自定义样式) |
106106
| checked | `boolean` | false | 可选,开关是否打开,默认关闭 | [基本用法](#size) |
107107
| disabled | `boolean` | false | 可选,是否禁用开关 | [基本用法](#size) |

0 commit comments

Comments
 (0)