57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
// The Lucia project.
|
|
// Copyright 2026-2026 DSP, inc. All rights reserved.
|
|
// Authors:
|
|
// imacat.yang@dsp.im (imacat), 2026/03/05
|
|
|
|
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');
|
|
});
|
|
});
|