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:
33
tests/components/IconChecked.test.js
Normal file
33
tests/components/IconChecked.test.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import IconChecked from '@/components/icons/IconChecked.vue';
|
||||
|
||||
describe('IconChecked', () => {
|
||||
it('shows gray frame when not checked', () => {
|
||||
const wrapper = mount(IconChecked, {
|
||||
props: { isChecked: false },
|
||||
});
|
||||
const imgs = wrapper.findAll('img[alt="checkbox"]');
|
||||
// When not checked: gray frame visible, blue frame hidden, check mark hidden
|
||||
expect(imgs.length).toBe(1);
|
||||
});
|
||||
|
||||
it('shows blue frame and check mark when checked', () => {
|
||||
const wrapper = mount(IconChecked, {
|
||||
props: { isChecked: true },
|
||||
});
|
||||
const imgs = wrapper.findAll('img[alt="checkbox"]');
|
||||
// When checked: blue frame + check mark visible (2 imgs), gray frame hidden
|
||||
expect(imgs.length).toBe(2);
|
||||
});
|
||||
|
||||
it('updates rendering when isChecked prop changes', async () => {
|
||||
const wrapper = mount(IconChecked, {
|
||||
props: { isChecked: false },
|
||||
});
|
||||
expect(wrapper.findAll('img[alt="checkbox"]').length).toBe(1);
|
||||
|
||||
await wrapper.setProps({ isChecked: true });
|
||||
expect(wrapper.findAll('img[alt="checkbox"]').length).toBe(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user