|
| 1 | +import { describe, expect, it } from 'vitest' |
| 2 | +import { mountSuspended } from '@nuxt/test-utils/runtime' |
| 3 | +import ButtonBase from '~/components/Button/Base.vue' |
| 4 | + |
| 5 | +describe('ButtonBase', () => { |
| 6 | + it('has cursor-pointer class on enabled button', async () => { |
| 7 | + const wrapper = await mountSuspended(ButtonBase) |
| 8 | + const button = wrapper.find('button') |
| 9 | + expect(button.classes()).toContain('cursor-pointer') |
| 10 | + }) |
| 11 | + |
| 12 | + it('has cursor-not-allowed on disabled state via class', async () => { |
| 13 | + const wrapper = await mountSuspended(ButtonBase, { |
| 14 | + props: { disabled: true }, |
| 15 | + }) |
| 16 | + const button = wrapper.find('button') |
| 17 | + // The class string includes the disabled modifier with cursor-not-allowed |
| 18 | + expect(button.attributes('class')).toContain('cursor-not-allowed') |
| 19 | + }) |
| 20 | + |
| 21 | + it('does not have disabled attribute when not disabled', async () => { |
| 22 | + const wrapper = await mountSuspended(ButtonBase) |
| 23 | + const button = wrapper.find('button') |
| 24 | + expect(button.attributes('disabled')).toBeUndefined() |
| 25 | + }) |
| 26 | + |
| 27 | + it('has disabled attribute when disabled prop is true', async () => { |
| 28 | + const wrapper = await mountSuspended(ButtonBase, { |
| 29 | + props: { disabled: true }, |
| 30 | + }) |
| 31 | + const button = wrapper.find('button') |
| 32 | + expect(button.attributes('disabled')).toBeDefined() |
| 33 | + }) |
| 34 | +}) |
0 commit comments