mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-15 04:42:23 +08:00
fix(input-number): value can't be null type
This commit is contained in:
parent
4c872205ae
commit
b3e59bd418
@ -21,7 +21,7 @@ const inputNumberProps = {
|
||||
type: Number as PropType<number | null>,
|
||||
default: null
|
||||
},
|
||||
value: Number,
|
||||
value: Number as PropType<number | null>,
|
||||
step: {
|
||||
type: [Number, String],
|
||||
default: 1
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { h } from 'vue'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { NInputNumber } from '../index'
|
||||
import { NButton } from '../../button'
|
||||
@ -7,6 +8,10 @@ describe('n-input-number', () => {
|
||||
mount(NInputNumber)
|
||||
})
|
||||
|
||||
it('props.value can be null', () => {
|
||||
;<NInputNumber value={null} />
|
||||
})
|
||||
|
||||
it('should work with `show-button` prop', async () => {
|
||||
// Here is a strange case, we must make input number's slots flag to 2
|
||||
// (dynamic) to make it work.
|
||||
@ -83,7 +88,9 @@ describe('n-input-number', () => {
|
||||
let arr = [0.1, 0]
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
await minusBtn.trigger('click')
|
||||
expect((input.element as HTMLInputElement).value).toEqual(arr[i].toString())
|
||||
expect((input.element as HTMLInputElement).value).toEqual(
|
||||
arr[i].toString()
|
||||
)
|
||||
}
|
||||
expect(minusBtn.classes()).toContain('n-button--disabled')
|
||||
await wrapper.setProps({ step: 0.2 })
|
||||
@ -91,7 +98,9 @@ describe('n-input-number', () => {
|
||||
arr = [0.2, 0.4, 0.6]
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
await addBtn.trigger('click')
|
||||
expect((input.element as HTMLInputElement).value).toEqual(arr[i].toString())
|
||||
expect((input.element as HTMLInputElement).value).toEqual(
|
||||
arr[i].toString()
|
||||
)
|
||||
}
|
||||
expect(addBtn.classes()).toContain('n-button--disabled')
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user