Skip to content

Commit b8f3b66

Browse files
committed
chore: improve test coverage to 97.2%
Add 425+ tests across 24 files covering previously untested components (Rating, Collapsible, Progress, NumberField, Locale) and closing coverage gaps in composables and existing components.
1 parent ddc86a7 commit b8f3b66

File tree

24 files changed

+6337
-136
lines changed

24 files changed

+6337
-136
lines changed

apps/docs/src/data/metrics.json

Lines changed: 142 additions & 86 deletions
Large diffs are not rendered by default.

packages/0/src/components/Collapsible/index.test.ts

Lines changed: 767 additions & 0 deletions
Large diffs are not rendered by default.

packages/0/src/components/Form/index.test.ts

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,5 +373,153 @@ describe('form', () => {
373373

374374
expect(slot.isReadonly).toBe(true)
375375
})
376+
377+
it('should expose isDisabled as false by default', () => {
378+
let slot: any
379+
380+
mount(Form, {
381+
slots: {
382+
default: (props: any) => {
383+
slot = props
384+
return h('div')
385+
},
386+
},
387+
})
388+
389+
expect(slot.isDisabled).toBe(false)
390+
})
391+
392+
it('should expose isReadonly as false by default', () => {
393+
let slot: any
394+
395+
mount(Form, {
396+
slots: {
397+
default: (props: any) => {
398+
slot = props
399+
return h('div')
400+
},
401+
},
402+
})
403+
404+
expect(slot.isReadonly).toBe(false)
405+
})
406+
407+
it('should expose isValidating as false when idle', () => {
408+
let slot: any
409+
410+
mount(Form, {
411+
slots: {
412+
default: (props: any) => {
413+
slot = props
414+
return h('div')
415+
},
416+
},
417+
})
418+
419+
expect(slot.isValidating).toBe(false)
420+
})
421+
422+
it('should expose isValid as false after failed submission', async () => {
423+
let slot: any
424+
425+
const wrapper = mount(Form, {
426+
slots: {
427+
default: (props: any) => {
428+
slot = props
429+
return h(FailingField)
430+
},
431+
},
432+
})
433+
434+
await wrapper.trigger('submit')
435+
await flushPromises()
436+
await nextTick()
437+
438+
expect(slot.isValid).toBe(false)
439+
})
440+
441+
it('should expose isValid as true after successful submission', async () => {
442+
const PassingField = defineComponent({
443+
setup () {
444+
const value = shallowRef('valid')
445+
createValidation({
446+
value,
447+
rules: [(v: unknown) => v === 'valid' ? true : 'Error'],
448+
})
449+
return () => h('input')
450+
},
451+
})
452+
453+
let slot: any
454+
455+
const wrapper = mount(Form, {
456+
slots: {
457+
default: (props: any) => {
458+
slot = props
459+
return h(PassingField)
460+
},
461+
},
462+
})
463+
464+
await wrapper.trigger('submit')
465+
await flushPromises()
466+
await nextTick()
467+
468+
expect(slot.isValid).toBe(true)
469+
})
470+
471+
it('should allow submit via slot prop function', async () => {
472+
let slot: any
473+
474+
mount(Form, {
475+
slots: {
476+
default: (props: any) => {
477+
slot = props
478+
return h('div')
479+
},
480+
},
481+
})
482+
483+
const result = await slot.submit()
484+
await flushPromises()
485+
486+
expect(result).toBe(true)
487+
})
488+
489+
it('should allow reset via slot prop function', async () => {
490+
let injected: ReturnType<typeof useForm>
491+
492+
const Field = defineComponent({
493+
setup () {
494+
injected = useForm()
495+
const value = shallowRef('')
496+
createValidation({
497+
value,
498+
rules: [(v: unknown) => v === 'valid' ? true : 'Error'],
499+
})
500+
return () => h('input')
501+
},
502+
})
503+
504+
let slot: any
505+
506+
const wrapper = mount(Form, {
507+
slots: {
508+
default: (props: any) => {
509+
slot = props
510+
return h(Field)
511+
},
512+
},
513+
})
514+
515+
await wrapper.trigger('submit')
516+
await flushPromises()
517+
expect(injected!.isValid.value).toBe(false)
518+
519+
slot.reset()
520+
await nextTick()
521+
522+
expect(injected!.isValid.value).toBeNull()
523+
})
376524
})
377525
})

0 commit comments

Comments
 (0)