Add component tests for ModalHeader, IconChecked, and Conformance result components
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
51
tests/components/ResultDot.test.js
Normal file
51
tests/components/ResultDot.test.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import ResultDot from '@/components/Discover/Conformance/ConformanceSidebar/ResultDot.vue';
|
||||
|
||||
// Mock $emitter to prevent errors
|
||||
const mockEmitter = { on: () => {}, emit: () => {} };
|
||||
|
||||
describe('ResultDot', () => {
|
||||
const mountResultDot = (props = {}) => {
|
||||
return mount(ResultDot, {
|
||||
props: {
|
||||
timeResultData: null,
|
||||
select: null,
|
||||
...props,
|
||||
},
|
||||
global: {
|
||||
mocks: {
|
||||
$emitter: mockEmitter,
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
it('renders list from select prop on creation', () => {
|
||||
const data = [
|
||||
{ category: 'Start', task: 'Task A' },
|
||||
{ category: 'End', task: 'Task B' },
|
||||
];
|
||||
const wrapper = mountResultDot({ select: data });
|
||||
const items = wrapper.findAll('li');
|
||||
expect(items.length).toBe(2);
|
||||
expect(items[0].text()).toContain('Start');
|
||||
expect(items[0].text()).toContain('Task A');
|
||||
});
|
||||
|
||||
it('renders empty when select is null', () => {
|
||||
const wrapper = mountResultDot({ select: null });
|
||||
const items = wrapper.findAll('li');
|
||||
expect(items.length).toBe(0);
|
||||
});
|
||||
|
||||
it('updates list when timeResultData prop changes', async () => {
|
||||
const wrapper = mountResultDot({ select: null });
|
||||
expect(wrapper.findAll('li').length).toBe(0);
|
||||
|
||||
const newData = [{ category: 'Mid', task: 'Task C' }];
|
||||
await wrapper.setProps({ timeResultData: newData });
|
||||
expect(wrapper.findAll('li').length).toBe(1);
|
||||
expect(wrapper.text()).toContain('Task C');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user