Skip to content

Commit

Permalink
- updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Severin Beauvais committed Sep 13, 2024
1 parent 7f76f54 commit 1bb16aa
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions tests/unit/LimitedRestorationPanel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,23 @@ function createDefaultComponent (

describe('Initialize RelationshipsPanel component', () => {
it('loads the component', () => {
const wrapper: Wrapper<LimitedRestorationPanel> = createDefaultComponent()
const wrapper = createDefaultComponent()

expect(wrapper.findComponent(LimitedRestorationPanel).exists()).toBe(true)

wrapper.destroy()
})

it('loads with a preset expiry (24 months)', async () => {
const wrapper: Wrapper<LimitedRestorationPanel> = createDefaultComponent(24)
await Vue.nextTick()
it('loads with a preset expiry (24 months)', () => {
const wrapper = createDefaultComponent(24)

expect(wrapper.vm.$data.radioValue).toEqual('24')

wrapper.destroy()
})

it('loads with a custom expiry (1 month)', async () => {
const wrapper: Wrapper<LimitedRestorationPanel> = createDefaultComponent(1)
await Vue.nextTick()
it('loads with a custom expiry (1 month)', () => {
const wrapper = createDefaultComponent(1)

expect(wrapper.vm.$data.radioValue).toEqual('customMonths')
expect(wrapper.vm.$data.inputValue).toEqual('1')
Expand All @@ -54,48 +52,49 @@ describe('Initialize RelationshipsPanel component', () => {
})

it('emits events when we select a preset expiry (24 months)', async () => {
const wrapper: Wrapper<LimitedRestorationPanel> = createDefaultComponent()
await Vue.nextTick()
const wrapper = createDefaultComponent()

await wrapper.find('#radio-24').setChecked()

expect(wrapper.emitted('valid').pop()[0]).toBe(true)
expect(wrapper.emitted('months').pop()[0]).toEqual(24)

wrapper.destroy()
})

it('emits events when we select a custom expiry (1 month)', async () => {
const wrapper: Wrapper<LimitedRestorationPanel> = createDefaultComponent()
await Vue.nextTick()
const vm = wrapper.vm as any
const wrapper = createDefaultComponent()

await wrapper.find('#radio-custom').setChecked()
await wrapper.find('#text-field-months').setValue('1')
await Vue.nextTick()

expect(wrapper.emitted('valid').pop()[0]).toBe(true)
expect(wrapper.emitted('months').pop()[0]).toEqual(1)

wrapper.destroy()
})

it('emits valid=false when we select 25 months with a max of 24', async () => {
const wrapper: Wrapper<LimitedRestorationPanel> = createDefaultComponent()
await Vue.nextTick()
const vm = wrapper.vm as any
const wrapper = createDefaultComponent()

await wrapper.find('#radio-custom').setChecked()
await wrapper.find('#text-field-months').setValue('25')

expect(wrapper.emitted('valid').pop()[0]).toEqual(false)
expect(wrapper.emitted('months').pop()[0]).toEqual(null)

wrapper.destroy()
})

it('emits valid=true when we select 25 months with a max of 36', async () => {
const wrapper: Wrapper<LimitedRestorationPanel> = createDefaultComponent(undefined, 36)
await Vue.nextTick()
const vm = wrapper.vm as any
const wrapper = createDefaultComponent(undefined, 36)

await wrapper.find('#radio-custom').setChecked()
await wrapper.find('#text-field-months').setValue('25')

expect(wrapper.emitted('valid').pop()[0]).toEqual(true)
expect(wrapper.emitted('months').pop()[0]).toEqual(25)

wrapper.destroy()
})
Expand Down

0 comments on commit 1bb16aa

Please sign in to comment.