Files
lucia-frontend/tests/components/Button.test.js
2026-03-06 18:57:58 +08:00

35 lines
976 B
JavaScript

// The Lucia project.
// Copyright 2026-2026 DSP, inc. All rights reserved.
// Authors:
// imacat.yang@dsp.im (imacat), 2026/03/05
import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import Button from '@/components/Button.vue';
describe('Button', () => {
it('renders button text', () => {
const wrapper = mount(Button, {
props: { buttonText: 'Click Me' },
});
expect(wrapper.text()).toBe('Click Me');
});
it('adds ring classes on mousedown', async () => {
const wrapper = mount(Button, {
props: { buttonText: 'Test' },
});
await wrapper.trigger('mousedown');
expect(wrapper.classes()).toContain('ring');
});
it('removes ring classes on mouseup', async () => {
const wrapper = mount(Button, {
props: { buttonText: 'Test' },
});
await wrapper.trigger('mousedown');
await wrapper.trigger('mouseup');
expect(wrapper.classes()).not.toContain('ring');
});
});