28705c8285
Release / release (push) Successful in 1m18s
| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [ ] Pas de régression - [ ] TU/TI/TF rédigée - [ ] TU/TI/TF OK - [ ] CHANGELOG modifié --------- Co-authored-by: admin malio <malio@yuno.malio.fr> Co-authored-by: THOLOT DECHENE Matthieu <matthieu@yuno.malio.fr> Co-authored-by: matthieu <matthieu@yuno.malio.fr> Reviewed-on: #84 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { mount } from '@vue/test-utils'
|
|
import MonthPicker from './MonthPicker.vue'
|
|
|
|
const mountPicker = (props: { currentYear: number, selectedMonth?: number, min?: string, max?: string }) =>
|
|
mount(MonthPicker, { props })
|
|
|
|
describe('MalioDateMonthPicker', () => {
|
|
it('renders 12 months', () => {
|
|
const wrapper = mountPicker({ currentYear: 2026 })
|
|
expect(wrapper.findAll('[data-test="month"]')).toHaveLength(12)
|
|
})
|
|
|
|
it('emits select with the clicked month index', async () => {
|
|
const wrapper = mountPicker({ currentYear: 2026 })
|
|
await wrapper.get('[data-test="month"][data-month="0"]').trigger('click')
|
|
expect(wrapper.emitted('select')?.[0]).toEqual([0])
|
|
})
|
|
|
|
it('disables months before min in the current year and does not emit', async () => {
|
|
const wrapper = mountPicker({ currentYear: 2026, min: '2026-05-01' })
|
|
const april = wrapper.get('[data-test="month"][data-month="3"]')
|
|
expect(april.attributes('disabled')).toBeDefined()
|
|
await april.trigger('click')
|
|
expect(wrapper.emitted('select')).toBeUndefined()
|
|
})
|
|
|
|
it('disables months after max in the current year', () => {
|
|
const wrapper = mountPicker({ currentYear: 2026, max: '2026-05-31' })
|
|
expect(wrapper.get('[data-test="month"][data-month="5"]').attributes('disabled')).toBeDefined()
|
|
expect(wrapper.get('[data-test="month"][data-month="4"]').attributes('disabled')).toBeUndefined()
|
|
})
|
|
})
|