mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-02-23 13:31:06 +08:00
fix(date-picker): test
This commit is contained in:
parent
9312609462
commit
48acc3f1b1
@ -18,7 +18,12 @@ export type Value = number | [number, number]
|
||||
|
||||
export type Shortcuts =
|
||||
| Record<string, number | (() => number)>
|
||||
| Record<string, [number, number] | (() => [number, number])>
|
||||
| Record<
|
||||
string,
|
||||
| [number, number]
|
||||
| readonly [number, number]
|
||||
| (() => [number, number] | readonly [number, number])
|
||||
>
|
||||
|
||||
export type OnUpdateValue = (
|
||||
value: number & (number | null) & [number, number] & ([number, number] | null)
|
||||
|
@ -110,16 +110,17 @@ describe('n-date-picker', () => {
|
||||
})
|
||||
|
||||
it('range type should work with shortcuts prop with function value', async () => {
|
||||
const test = ref<Value>(0)
|
||||
const test = ref<[number, number]>([0, 0])
|
||||
const wrapper = mount(NDatePicker, {
|
||||
props: {
|
||||
value: test.value,
|
||||
type: 'daterange',
|
||||
onUpdateValue: (value: Value) => {
|
||||
onUpdateValue: (value: [number, number]) => {
|
||||
test.value = value
|
||||
},
|
||||
shortcuts: {
|
||||
'Honey birthday': () => [1629216000000, 1631203200000]
|
||||
Good: [123, 456] as const,
|
||||
'Honey birthday': () => [1629216000000, 1631203200000] as const
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -129,7 +130,7 @@ describe('n-date-picker', () => {
|
||||
?.querySelector('.n-button') as HTMLElement
|
||||
button.click()
|
||||
expect(test.value).toEqual([1629216000000, 1631203200000])
|
||||
test.value = 0
|
||||
test.value = [0, 0]
|
||||
wrapper.setProps({
|
||||
type: 'datetimerange'
|
||||
})
|
||||
|
@ -99,3 +99,23 @@ exports[`locale works 5`] = `
|
||||
</div>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`locale works 6`] = `
|
||||
"<div class=\\"n-config-provider\\">
|
||||
<div class=\\"n-input n-input--resizable n-input--stateful\\" style=\\"--bezier: cubic-bezier(.4, 0, .2, 1); --count-text-color: rgb(158, 164, 170); --color: rgba(255, 255, 255, 1); --font-size: 14px; --border-radius: 3px; --height: 34px; --padding-left: 12px; --padding-right: 12px; --text-color: rgb(51, 54, 57); --caret-color: #18a058; --text-decoration-color: rgb(51, 54, 57); --border: 1px solid rgb(224, 224, 230); --border-disabled: 1px solid rgb(224, 224, 230); --border-hover: 1px solid #36ad6a; --border-focus: 1px solid #36ad6a; --placeholder-color: rgba(194, 194, 194, 1); --placeholder-color-disabled: rgba(209, 209, 209, 1); --icon-size: 16px; --line-height-textarea: 1.6; --color-disabled: rgb(250, 250, 252); --color-focus: rgba(255, 255, 255, 1); --text-color-disabled: rgba(194, 194, 194, 1); --box-shadow-focus: 0 0 0 2px rgba(24, 160, 88, 0.2); --loading-color: #18a058; --caret-color-warning: #f0a020; --color-focus-warning: rgba(255, 255, 255, 1); --box-shadow-focus-warning: 0 0 0 2px rgba(240, 160, 32, 0.2); --border-warning: 1px solid #f0a020; --border-focus-warning: 1px solid #fcb040; --border-hover-warning: 1px solid #fcb040; --loading-color-warning: #f0a020; --caret-color-error: #d03050; --color-focus-error: rgba(255, 255, 255, 1); --box-shadow-focus-error: 0 0 0 2px rgba(208, 48, 80, 0.2); --border-error: 1px solid #d03050; --border-focus-error: 1px solid #de576d; --border-hover-error: 1px solid #de576d; --loading-color-error: #d03050; --clear-color: rgba(194, 194, 194, 1); --clear-size: 16px; --clear-color-hover: rgba(146, 146, 146, 1); --clear-color-pressed: rgba(175, 175, 175, 1); --icon-color: rgba(194, 194, 194, 1); --icon-color-hover: rgba(146, 146, 146, 1); --icon-color-pressed: rgba(175, 175, 175, 1); --icon-color-disabled: rgba(209, 209, 209, 1); --suffix-text-color: rgb(51, 54, 57);\\">
|
||||
<div class=\\"n-input-wrapper\\">
|
||||
<!---->
|
||||
<div class=\\"n-input__input\\"><input type=\\"text\\" class=\\"n-input__input-el\\" placeholder=\\"Mohon isi\\" size=\\"20\\">
|
||||
<div class=\\"n-input__placeholder\\"><span>Mohon isi</span></div>
|
||||
<!---->
|
||||
</div>
|
||||
<!---->
|
||||
</div>
|
||||
<!---->
|
||||
<!---->
|
||||
<div class=\\"n-input__border\\"></div>
|
||||
<div class=\\"n-input__state-border\\"></div>
|
||||
<!---->
|
||||
</div>
|
||||
</div>"
|
||||
`;
|
||||
|
Loading…
Reference in New Issue
Block a user