67 lines
2.0 KiB
JavaScript
67 lines
2.0 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 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");
|
|
});
|
|
});
|