|
1 | 1 | import { mountPcMode } from '@opentiny-internal/vue-test-utils' |
2 | 2 | import { describe, expect, test, vi } from 'vitest' |
3 | 3 | import Numeric from '@opentiny/vue-numeric' |
4 | | -import { IconChevronUp } from '@opentiny/vue-icon' |
5 | 4 | import { nextTick, ref } from 'vue' |
6 | 5 |
|
7 | 6 | const mouseup = new Event('mouseup') |
@@ -166,11 +165,10 @@ describe('PC Mode', () => { |
166 | 165 | expect(wrapper.find('.tiny-numeric__increase').exists()).toBe(false) |
167 | 166 | }) |
168 | 167 |
|
169 | | - test('controls-position 控制按钮位置', async () => { |
| 168 | + test('controls-position = right', async () => { |
170 | 169 | const num = ref(0) |
171 | | - const wrapper = mount(() => <Numeric controls-position="rigint" v-model={num.value}></Numeric>) |
172 | | - expect(wrapper.find('.tiny-numeric__decrease').findComponent(IconChevronUp).exists()).toBe(false) |
173 | | - expect(wrapper.find('.tiny-numeric__increase').findComponent(IconChevronUp).exists()).toBe(false) |
| 170 | + const wrapper = mount(() => <Numeric controls-position="right" v-model={num.value} />) |
| 171 | + expect(wrapper.find('.is-controls-right').exists()).toBe(true) |
174 | 172 | }) |
175 | 173 |
|
176 | 174 | test('name 原生属性', async () => { |
@@ -224,10 +222,10 @@ describe('PC Mode', () => { |
224 | 222 | test('allow-empty 计数器内容的可清空', async () => { |
225 | 223 | const num = ref(0) |
226 | 224 | // allow-empty = false |
227 | | - let wrapper = mount(() => <Numeric v-model={num.value}></Numeric>) |
| 225 | + let wrapper = mount(() => <Numeric v-model={num.value} />) |
228 | 226 | wrapper.find('input').setValue('') |
229 | 227 | await nextTick() |
230 | | - expect(wrapper.find('input').element.value).toEqual('0') |
| 228 | + expect(wrapper.find('input').element.value).toEqual('') |
231 | 229 |
|
232 | 230 | // allow-empty = true |
233 | 231 | wrapper = mount(() => <Numeric allow-empty v-model={num.value}></Numeric>) |
@@ -260,7 +258,7 @@ describe('PC Mode', () => { |
260 | 258 | const change = vi.fn() |
261 | 259 | const wrapper = mount(() => <Numeric v-model={num.value} onChange={change}></Numeric>) |
262 | 260 |
|
263 | | - num.value = 2 |
| 261 | + wrapper.find('input').setValue(2) |
264 | 262 | await nextTick() |
265 | 263 | expect(change).toHaveBeenCalledTimes(1) |
266 | 264 | expect(change).toHaveBeenCalledWith(2, 1) |
|
0 commit comments