Add component tests for presentational components and Login

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 19:32:57 +08:00
parent 529e9a4aa1
commit fa58e665d5
6 changed files with 209 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import ButtonFilled from '@/components/ButtonFilled.vue';
describe('ButtonFilled', () => {
it('renders button text', () => {
const wrapper = mount(ButtonFilled, {
props: { buttonText: 'Save' },
});
expect(wrapper.text()).toBe('Save');
});
it('has filled background class', () => {
const wrapper = mount(ButtonFilled, {
props: { buttonText: 'Save' },
});
expect(wrapper.find('button').exists()).toBe(true);
});
it('adds ring on mousedown and removes on mouseup', async () => {
const wrapper = mount(ButtonFilled, {
props: { buttonText: 'Test' },
});
await wrapper.trigger('mousedown');
expect(wrapper.classes()).toContain('ring');
await wrapper.trigger('mouseup');
expect(wrapper.classes()).not.toContain('ring');
});
});