30 lines
1 KiB
TypeScript
30 lines
1 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { mount } from '@vue/test-utils'
|
|
import { Button } from '../src/lib'
|
|
|
|
describe('Button', () => {
|
|
it('defaults to the primary variant', () => {
|
|
const wrapper = mount(Button, { slots: { default: 'Click' } })
|
|
expect(wrapper.classes().join(' ')).toContain('bg-primary')
|
|
})
|
|
|
|
it('applies the danger variant class', () => {
|
|
const wrapper = mount(Button, { props: { variant: 'danger' } })
|
|
expect(wrapper.classes().join(' ')).toContain('bg-destructive')
|
|
})
|
|
|
|
it('auto-disables when loading is true', () => {
|
|
const wrapper = mount(Button, { props: { loading: true } })
|
|
expect(wrapper.attributes('disabled')).toBeDefined()
|
|
})
|
|
|
|
it('renders the loading icon when loading is true', () => {
|
|
const wrapper = mount(Button, { props: { loading: true } })
|
|
expect(wrapper.find('svg.nych-loading-icon').exists()).toBe(true)
|
|
})
|
|
|
|
it('stays enabled when loading is false', () => {
|
|
const wrapper = mount(Button)
|
|
expect(wrapper.attributes('disabled')).toBeUndefined()
|
|
})
|
|
})
|