Files
portal/app/tests/Frontend/DaysBulkDialog.spec.ts
T
2026-05-12 15:17:16 +03:00

35 lines
1.5 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import { createVuetify } from 'vuetify';
import DaysBulkDialog from '../../resources/js/components/projects/DaysBulkDialog.vue';
const mountDialog = (count = 5) =>
mount(DaysBulkDialog, {
props: { modelValue: true, count },
global: { plugins: [createVuetify()], stubs: { VDialog: { template: '<div><slot /></div>' } } },
});
describe('DaysBulkDialog', () => {
it('renders 7 weekday buttons for Add and Remove', () => {
const wrapper = mountDialog();
expect(wrapper.findAll('[data-testid^="day-add-"]').length).toBe(7);
expect(wrapper.findAll('[data-testid^="day-remove-"]').length).toBe(7);
});
it('emits apply with bitmasks (add Tue+Thu, remove Sat+Sun)', async () => {
const wrapper = mountDialog();
await wrapper.find('[data-testid="day-add-2"]').trigger('click'); // Вт
await wrapper.find('[data-testid="day-add-8"]').trigger('click'); // Чт
await wrapper.find('[data-testid="day-remove-32"]').trigger('click'); // Сб
await wrapper.find('[data-testid="day-remove-64"]').trigger('click'); // Вс
await wrapper.find('[data-testid="apply"]').trigger('click');
expect(wrapper.emitted('apply')?.[0]).toEqual([{ add: 10, remove: 96 }]);
});
it('apply disabled when both masks are 0', () => {
const wrapper = mountDialog();
expect(wrapper.find('[data-testid="apply"]').attributes('disabled')).toBeDefined();
});
});