54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { mount } from '@vue/test-utils';
|
|
import { createVuetify } from 'vuetify';
|
|
import ProjectCard from '../../resources/js/components/projects/ProjectCard.vue';
|
|
|
|
const vuetify = createVuetify();
|
|
const baseProject = {
|
|
id: 1,
|
|
name: 'Окна СПб',
|
|
signal_type: 'site' as const,
|
|
signal_identifier: 'okna.ru',
|
|
daily_limit_target: 50,
|
|
delivered_today: 32,
|
|
is_active: true,
|
|
archived_at: null,
|
|
sync_status: 'ok' as const,
|
|
};
|
|
|
|
describe('ProjectCard', () => {
|
|
it('renders project name + signal_identifier', () => {
|
|
const wrapper = mount(ProjectCard, {
|
|
global: { plugins: [vuetify] },
|
|
props: { project: baseProject, selected: false },
|
|
});
|
|
expect(wrapper.text()).toContain('Окна СПб');
|
|
expect(wrapper.text()).toContain('okna.ru');
|
|
});
|
|
|
|
it('shows progress percentage 32/50', () => {
|
|
const wrapper = mount(ProjectCard, {
|
|
global: { plugins: [vuetify] },
|
|
props: { project: baseProject, selected: false },
|
|
});
|
|
expect(wrapper.text()).toMatch(/32.*50/);
|
|
});
|
|
|
|
it('emits select event on checkbox change', async () => {
|
|
const wrapper = mount(ProjectCard, {
|
|
global: { plugins: [vuetify] },
|
|
props: { project: baseProject, selected: false },
|
|
});
|
|
await wrapper.find('[data-testid="card-select"]').trigger('change');
|
|
expect(wrapper.emitted('toggle-select')).toBeTruthy();
|
|
});
|
|
|
|
it('shows "На паузе" when is_active=false', () => {
|
|
const wrapper = mount(ProjectCard, {
|
|
global: { plugins: [vuetify] },
|
|
props: { project: { ...baseProject, is_active: false }, selected: false },
|
|
});
|
|
expect(wrapper.text()).toContain('На паузе');
|
|
});
|
|
});
|