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:
2026-03-05 19:45:30 +08:00
parent fa58e665d5
commit 676b70caa0
5 changed files with 230 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import ResultCheck from '@/components/Discover/Conformance/ConformanceSidebar/ResultCheck.vue';
// Mock $emitter to prevent errors
const mockEmitter = { on: () => {}, emit: () => {} };
describe('ResultCheck', () => {
const mountResultCheck = (props = {}) => {
return mount(ResultCheck, {
props: {
data: null,
select: null,
...props,
},
global: {
mocks: {
$emitter: mockEmitter,
},
},
});
};
it('renders list from select prop on creation', () => {
const wrapper = mountResultCheck({
select: ['Activity X', 'Activity Y'],
});
const items = wrapper.findAll('li');
expect(items.length).toBe(2);
expect(items[0].text()).toContain('Activity X');
expect(items[1].text()).toContain('Activity Y');
});
it('renders empty when select is null', () => {
const wrapper = mountResultCheck({ select: null });
const items = wrapper.findAll('li');
expect(items.length).toBe(0);
});
it('renders check_circle icon for each item', () => {
const wrapper = mountResultCheck({ select: ['Task 1'] });
expect(wrapper.find('span.material-symbols-outlined').text()).toContain(
'check_circle',
);
});
it('updates list when data prop changes', async () => {
const wrapper = mountResultCheck({ select: ['Initial'] });
expect(wrapper.findAll('li').length).toBe(1);
await wrapper.setProps({ data: ['New A', 'New B'] });
expect(wrapper.findAll('li').length).toBe(2);
expect(wrapper.text()).toContain('New A');
});
it('updates list when select prop changes', async () => {
const wrapper = mountResultCheck({ select: ['Old'] });
await wrapper.setProps({ select: ['Changed'] });
expect(wrapper.text()).toContain('Changed');
});
});