test: Added variant button test

This commit is contained in:
Paul Valerie GOMA 2025-07-19 16:53:31 +02:00
parent f3b93bb2b0
commit 714d79781f

View File

@ -133,4 +133,80 @@ describe('VButton', () => {
expect(button.classes()).not.toContain('p-button-sm')
expect(button.classes().some(c => c.includes('text-body-MD'))).toBe(true)
})
test('primary button', () => {
const wrapper = mount(VButton, {
props: {
title: 'button',
label: 'label',
}
})
const button = wrapper.find('button')
expect(button.classes()).not.toContain('p-button-secondary')
expect(button.classes()).not.toContain('p-button-outlined')
expect(button.classes()).not.toContain('p-button-text')
expect(button.classes()).not.toContain('p-button-danger')
})
test('secondary button', () => {
const wrapper = mount(VButton, {
props: {
title: 'button',
label: 'label',
secondary: true,
}
})
const button = wrapper.find('button')
expect(button.classes()).toContain('p-button-secondary')
expect(button.classes()).toContain('p-button-outlined')
expect(button.classes()).not.toContain('p-button-text')
expect(button.classes()).not.toContain('p-button-danger')
expect(button.attributes('data-p-severity')).toBe('secondary')
})
test('tertiary button', () => {
const wrapper = mount(VButton, {
props: {
title: 'button',
label: 'label',
tertiary: true
}
})
const button = wrapper.find('button')
expect(button.classes()).not.toContain('p-button-secondary')
expect(button.classes()).toContain('p-button-outlined')
expect(button.classes()).not.toContain('p-button-text')
expect(button.classes()).not.toContain('p-button-danger')
})
test('no outlined button', () => {
const wrapper = mount(VButton, {
props: {
title: 'button',
label: 'label',
noOutline: true,
}
})
const button = wrapper.find('button')
expect(button.classes()).not.toContain('p-button-secondary')
expect(button.classes()).not.toContain('p-button-outlined')
expect(button.classes()).toContain('p-button-text')
expect(button.classes()).not.toContain('p-button-danger')
})
test('danger variant button', () => {
const wrapper = mount(VButton, {
props: {
title: 'button',
label: 'label',
danger: true,
}
})
const button = wrapper.find('button')
expect(button.classes()).not.toContain('p-button-secondary')
expect(button.classes()).not.toContain('p-button-outlined')
expect(button.classes()).not.toContain('p-button-text')
expect(button.classes()).toContain('p-button-danger')
expect(button.attributes('data-p-severity')).toBe('danger')
})
})