4b6ab8f113
Delta mode combines Add/Remove numeric inputs into a single signed delta; Replace mode switches to an absolute value input via v-checkbox toggle. 5/5 Vitest pass; full suite 611 passed + 3 skipped. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
48 lines
2.2 KiB
TypeScript
48 lines
2.2 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { mount } from '@vue/test-utils';
|
|
import { createVuetify } from 'vuetify';
|
|
import LimitBulkDialog from '../../resources/js/components/projects/LimitBulkDialog.vue';
|
|
|
|
const mountDialog = (count = 5) =>
|
|
mount(LimitBulkDialog, {
|
|
props: { modelValue: true, count },
|
|
global: { plugins: [createVuetify()], stubs: { VDialog: { template: '<div><slot /></div>' } } },
|
|
});
|
|
|
|
describe('LimitBulkDialog', () => {
|
|
it('emits apply with positive delta when only add filled', async () => {
|
|
const wrapper = mountDialog();
|
|
await wrapper.find('[data-testid="add-input"] input').setValue('100');
|
|
await wrapper.find('[data-testid="apply"]').trigger('click');
|
|
expect(wrapper.emitted('apply')?.[0]).toEqual([{ delta: 100 }]);
|
|
});
|
|
|
|
it('emits apply with negative delta when only remove filled', async () => {
|
|
const wrapper = mountDialog();
|
|
await wrapper.find('[data-testid="remove-input"] input').setValue('50');
|
|
await wrapper.find('[data-testid="apply"]').trigger('click');
|
|
expect(wrapper.emitted('apply')?.[0]).toEqual([{ delta: -50 }]);
|
|
});
|
|
|
|
it('emits apply with combined delta when both filled', async () => {
|
|
const wrapper = mountDialog();
|
|
await wrapper.find('[data-testid="add-input"] input').setValue('100');
|
|
await wrapper.find('[data-testid="remove-input"] input').setValue('30');
|
|
await wrapper.find('[data-testid="apply"]').trigger('click');
|
|
expect(wrapper.emitted('apply')?.[0]).toEqual([{ delta: 70 }]);
|
|
});
|
|
|
|
it('emits apply with replace when replace mode toggled', async () => {
|
|
const wrapper = mountDialog();
|
|
await wrapper.find('[data-testid="replace-toggle"] input').setValue(true);
|
|
await wrapper.find('[data-testid="replace-input"] input').setValue('500');
|
|
await wrapper.find('[data-testid="apply"]').trigger('click');
|
|
expect(wrapper.emitted('apply')?.[0]).toEqual([{ replace: 500 }]);
|
|
});
|
|
|
|
it('apply disabled when neither input is filled', () => {
|
|
const wrapper = mountDialog();
|
|
expect(wrapper.find('[data-testid="apply"]').attributes('disabled')).toBeDefined();
|
|
});
|
|
});
|