Apply repository-wide ESLint auto-fix formatting pass
Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
@@ -3,29 +3,29 @@
|
||||
// Authors:
|
||||
// imacat.yang@dsp.im (imacat), 2026/03/05
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import Badge from '@/components/Badge.vue';
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import Badge from "@/components/Badge.vue";
|
||||
|
||||
describe('Badge', () => {
|
||||
it('renders display text', () => {
|
||||
describe("Badge", () => {
|
||||
it("renders display text", () => {
|
||||
const wrapper = mount(Badge, {
|
||||
props: { isActivated: true, displayText: 'Active' },
|
||||
props: { isActivated: true, displayText: "Active" },
|
||||
});
|
||||
expect(wrapper.text()).toBe('Active');
|
||||
expect(wrapper.text()).toBe("Active");
|
||||
});
|
||||
|
||||
it('has activated class when isActivated is true', () => {
|
||||
it("has activated class when isActivated is true", () => {
|
||||
const wrapper = mount(Badge, {
|
||||
props: { isActivated: true, displayText: 'Active' },
|
||||
props: { isActivated: true, displayText: "Active" },
|
||||
});
|
||||
expect(wrapper.classes()).toContain('badge-activated');
|
||||
expect(wrapper.classes()).toContain("badge-activated");
|
||||
});
|
||||
|
||||
it('has deactivated class when isActivated is false', () => {
|
||||
it("has deactivated class when isActivated is false", () => {
|
||||
const wrapper = mount(Badge, {
|
||||
props: { isActivated: false, displayText: 'Inactive' },
|
||||
props: { isActivated: false, displayText: "Inactive" },
|
||||
});
|
||||
expect(wrapper.classes()).toContain('badge-deactivated');
|
||||
expect(wrapper.classes()).toContain("badge-deactivated");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,32 +3,32 @@
|
||||
// Authors:
|
||||
// imacat.yang@dsp.im (imacat), 2026/03/05
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import Button from '@/components/Button.vue';
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import Button from "@/components/Button.vue";
|
||||
|
||||
describe('Button', () => {
|
||||
it('renders button text', () => {
|
||||
describe("Button", () => {
|
||||
it("renders button text", () => {
|
||||
const wrapper = mount(Button, {
|
||||
props: { buttonText: 'Click Me' },
|
||||
props: { buttonText: "Click Me" },
|
||||
});
|
||||
expect(wrapper.text()).toBe('Click Me');
|
||||
expect(wrapper.text()).toBe("Click Me");
|
||||
});
|
||||
|
||||
it('adds ring classes on mousedown', async () => {
|
||||
it("adds ring classes on mousedown", async () => {
|
||||
const wrapper = mount(Button, {
|
||||
props: { buttonText: 'Test' },
|
||||
props: { buttonText: "Test" },
|
||||
});
|
||||
await wrapper.trigger('mousedown');
|
||||
expect(wrapper.classes()).toContain('ring');
|
||||
await wrapper.trigger("mousedown");
|
||||
expect(wrapper.classes()).toContain("ring");
|
||||
});
|
||||
|
||||
it('removes ring classes on mouseup', async () => {
|
||||
it("removes ring classes on mouseup", async () => {
|
||||
const wrapper = mount(Button, {
|
||||
props: { buttonText: 'Test' },
|
||||
props: { buttonText: "Test" },
|
||||
});
|
||||
await wrapper.trigger('mousedown');
|
||||
await wrapper.trigger('mouseup');
|
||||
expect(wrapper.classes()).not.toContain('ring');
|
||||
await wrapper.trigger("mousedown");
|
||||
await wrapper.trigger("mouseup");
|
||||
expect(wrapper.classes()).not.toContain("ring");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,32 +3,32 @@
|
||||
// Authors:
|
||||
// imacat.yang@dsp.im (imacat), 2026/03/05
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import ButtonFilled from '@/components/ButtonFilled.vue';
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import ButtonFilled from "@/components/ButtonFilled.vue";
|
||||
|
||||
describe('ButtonFilled', () => {
|
||||
it('renders button text', () => {
|
||||
describe("ButtonFilled", () => {
|
||||
it("renders button text", () => {
|
||||
const wrapper = mount(ButtonFilled, {
|
||||
props: { buttonText: 'Save' },
|
||||
props: { buttonText: "Save" },
|
||||
});
|
||||
expect(wrapper.text()).toBe('Save');
|
||||
expect(wrapper.text()).toBe("Save");
|
||||
});
|
||||
|
||||
it('has filled background class', () => {
|
||||
it("has filled background class", () => {
|
||||
const wrapper = mount(ButtonFilled, {
|
||||
props: { buttonText: 'Save' },
|
||||
props: { buttonText: "Save" },
|
||||
});
|
||||
expect(wrapper.find('button').exists()).toBe(true);
|
||||
expect(wrapper.find("button").exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('adds ring on mousedown and removes on mouseup', async () => {
|
||||
it("adds ring on mousedown and removes on mouseup", async () => {
|
||||
const wrapper = mount(ButtonFilled, {
|
||||
props: { buttonText: 'Test' },
|
||||
props: { buttonText: "Test" },
|
||||
});
|
||||
await wrapper.trigger('mousedown');
|
||||
expect(wrapper.classes()).toContain('ring');
|
||||
await wrapper.trigger('mouseup');
|
||||
expect(wrapper.classes()).not.toContain('ring');
|
||||
await wrapper.trigger("mousedown");
|
||||
expect(wrapper.classes()).toContain("ring");
|
||||
await wrapper.trigger("mouseup");
|
||||
expect(wrapper.classes()).not.toContain("ring");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
// Authors:
|
||||
// imacat.yang@dsp.im (imacat), 2026/03/05
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import IconChecked from '@/components/icons/IconChecked.vue';
|
||||
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', () => {
|
||||
describe("IconChecked", () => {
|
||||
it("shows gray frame when not checked", () => {
|
||||
const wrapper = mount(IconChecked, {
|
||||
props: { isChecked: false },
|
||||
});
|
||||
@@ -17,7 +17,7 @@ describe('IconChecked', () => {
|
||||
expect(imgs.length).toBe(1);
|
||||
});
|
||||
|
||||
it('shows blue frame and check mark when checked', () => {
|
||||
it("shows blue frame and check mark when checked", () => {
|
||||
const wrapper = mount(IconChecked, {
|
||||
props: { isChecked: true },
|
||||
});
|
||||
@@ -26,7 +26,7 @@ describe('IconChecked', () => {
|
||||
expect(imgs.length).toBe(2);
|
||||
});
|
||||
|
||||
it('updates rendering when isChecked prop changes', async () => {
|
||||
it("updates rendering when isChecked prop changes", async () => {
|
||||
const wrapper = mount(IconChecked, {
|
||||
props: { isChecked: false },
|
||||
});
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
// Authors:
|
||||
// imacat.yang@dsp.im (imacat), 2026/03/05
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import Loading from '@/components/Loading.vue';
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import Loading from "@/components/Loading.vue";
|
||||
|
||||
describe('Loading', () => {
|
||||
it('renders a loader element', () => {
|
||||
describe("Loading", () => {
|
||||
it("renders a loader element", () => {
|
||||
const wrapper = mount(Loading);
|
||||
expect(wrapper.find('.loader').exists()).toBe(true);
|
||||
expect(wrapper.find(".loader").exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('has full-screen overlay classes', () => {
|
||||
it("has full-screen overlay classes", () => {
|
||||
const wrapper = mount(Loading);
|
||||
expect(wrapper.classes()).toContain('fixed');
|
||||
expect(wrapper.classes()).toContain('inset-0');
|
||||
expect(wrapper.classes()).toContain("fixed");
|
||||
expect(wrapper.classes()).toContain("inset-0");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// Authors:
|
||||
// imacat.yang@dsp.im (imacat), 2026/03/05
|
||||
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import { describe, it, expect, beforeEach, vi } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { setActivePinia, createPinia } from "pinia";
|
||||
|
||||
vi.mock('@/module/apiError.js', () => ({
|
||||
vi.mock("@/module/apiError.js", () => ({
|
||||
default: vi.fn(),
|
||||
}));
|
||||
|
||||
@@ -15,14 +15,14 @@ const mockRoute = vi.hoisted(() => ({
|
||||
query: {},
|
||||
}));
|
||||
|
||||
vi.mock('vue-router', () => ({
|
||||
vi.mock("vue-router", () => ({
|
||||
useRoute: () => mockRoute,
|
||||
}));
|
||||
|
||||
import Login from '@/views/Login/Login.vue';
|
||||
import { useLoginStore } from '@/stores/login';
|
||||
import Login from "@/views/Login/Login.vue";
|
||||
import { useLoginStore } from "@/stores/login";
|
||||
|
||||
describe('Login', () => {
|
||||
describe("Login", () => {
|
||||
let pinia;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -42,62 +42,62 @@ describe('Login', () => {
|
||||
});
|
||||
};
|
||||
|
||||
it('renders login form', () => {
|
||||
it("renders login form", () => {
|
||||
const wrapper = mountLogin();
|
||||
expect(wrapper.find('h2').text()).toBe('LOGIN');
|
||||
expect(wrapper.find('#account').exists()).toBe(true);
|
||||
expect(wrapper.find('#password').exists()).toBe(true);
|
||||
expect(wrapper.find("h2").text()).toBe("LOGIN");
|
||||
expect(wrapper.find("#account").exists()).toBe(true);
|
||||
expect(wrapper.find("#password").exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('has disabled login button when fields are empty', () => {
|
||||
it("has disabled login button when fields are empty", () => {
|
||||
const wrapper = mountLogin();
|
||||
const btn = wrapper.find('#login_btn_main_btn');
|
||||
expect(btn.attributes('disabled')).toBeDefined();
|
||||
const btn = wrapper.find("#login_btn_main_btn");
|
||||
expect(btn.attributes("disabled")).toBeDefined();
|
||||
});
|
||||
|
||||
it('enables login button when both fields have values', async () => {
|
||||
it("enables login button when both fields have values", async () => {
|
||||
const wrapper = mountLogin();
|
||||
const store = useLoginStore();
|
||||
store.auth.username = 'user';
|
||||
store.auth.password = 'pass';
|
||||
store.auth.username = "user";
|
||||
store.auth.password = "pass";
|
||||
await wrapper.vm.$nextTick();
|
||||
const btn = wrapper.find('#login_btn_main_btn');
|
||||
expect(btn.attributes('disabled')).toBeUndefined();
|
||||
const btn = wrapper.find("#login_btn_main_btn");
|
||||
expect(btn.attributes("disabled")).toBeUndefined();
|
||||
});
|
||||
|
||||
it('shows error message when isInvalid', async () => {
|
||||
it("shows error message when isInvalid", async () => {
|
||||
const wrapper = mountLogin();
|
||||
const store = useLoginStore();
|
||||
store.isInvalid = true;
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.text()).toContain('Incorrect account or password');
|
||||
expect(wrapper.text()).toContain("Incorrect account or password");
|
||||
});
|
||||
|
||||
it('toggles password visibility', async () => {
|
||||
it("toggles password visibility", async () => {
|
||||
const wrapper = mountLogin();
|
||||
const store = useLoginStore();
|
||||
store.auth.password = 'secret';
|
||||
store.auth.password = "secret";
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
const pwdInput = wrapper.find('#password');
|
||||
expect(pwdInput.attributes('type')).toBe('password');
|
||||
const pwdInput = wrapper.find("#password");
|
||||
expect(pwdInput.attributes("type")).toBe("password");
|
||||
|
||||
// Click the eye icon to toggle
|
||||
const eyeToggle = wrapper.find(
|
||||
'label[for="passwordt"] span.cursor-pointer',
|
||||
);
|
||||
if (eyeToggle.exists()) {
|
||||
await eyeToggle.trigger('click');
|
||||
await eyeToggle.trigger("click");
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(pwdInput.attributes('type')).toBe('text');
|
||||
expect(pwdInput.attributes("type")).toBe("text");
|
||||
}
|
||||
});
|
||||
|
||||
it('stores return-to URL from route query', () => {
|
||||
it("stores return-to URL from route query", () => {
|
||||
const wrapper = mountLogin({
|
||||
route: { query: { 'return-to': 'encodedUrl' } },
|
||||
route: { query: { "return-to": "encodedUrl" } },
|
||||
});
|
||||
const store = useLoginStore();
|
||||
expect(store.rememberedReturnToUrl).toBe('encodedUrl');
|
||||
expect(store.rememberedReturnToUrl).toBe("encodedUrl");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
// Authors:
|
||||
// imacat.yang@dsp.im (imacat), 2026/03/05
|
||||
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { setActivePinia, createPinia } from 'pinia';
|
||||
import ModalHeader from '@/views/AccountManagement/ModalHeader.vue';
|
||||
import { useModalStore } from '@/stores/modal';
|
||||
import { describe, it, expect, beforeEach, vi } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { setActivePinia, createPinia } from "pinia";
|
||||
import ModalHeader from "@/views/AccountManagement/ModalHeader.vue";
|
||||
import { useModalStore } from "@/stores/modal";
|
||||
|
||||
describe('ModalHeader', () => {
|
||||
describe("ModalHeader", () => {
|
||||
let pinia;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -17,35 +17,35 @@ describe('ModalHeader', () => {
|
||||
setActivePinia(pinia);
|
||||
});
|
||||
|
||||
const mountModalHeader = (headerText = 'Test Header') => {
|
||||
const mountModalHeader = (headerText = "Test Header") => {
|
||||
return mount(ModalHeader, {
|
||||
props: { headerText },
|
||||
global: { plugins: [pinia] },
|
||||
});
|
||||
};
|
||||
|
||||
it('renders header text from prop', () => {
|
||||
const wrapper = mountModalHeader('Account Info');
|
||||
expect(wrapper.find('h1').text()).toBe('Account Info');
|
||||
it("renders header text from prop", () => {
|
||||
const wrapper = mountModalHeader("Account Info");
|
||||
expect(wrapper.find("h1").text()).toBe("Account Info");
|
||||
});
|
||||
|
||||
it('renders close button (X icon)', () => {
|
||||
it("renders close button (X icon)", () => {
|
||||
const wrapper = mountModalHeader();
|
||||
const img = wrapper.find('img[alt="X"]');
|
||||
expect(img.exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('calls closeModal when X is clicked', async () => {
|
||||
it("calls closeModal when X is clicked", async () => {
|
||||
const wrapper = mountModalHeader();
|
||||
const store = useModalStore();
|
||||
store.isModalOpen = true;
|
||||
store.whichModal = 'SOME_MODAL';
|
||||
store.whichModal = "SOME_MODAL";
|
||||
|
||||
const img = wrapper.find('img[alt="X"]');
|
||||
await img.trigger('click');
|
||||
await img.trigger("click");
|
||||
|
||||
// closeModal only sets isModalOpen to false; whichModal is not reset
|
||||
expect(store.isModalOpen).toBe(false);
|
||||
expect(store.whichModal).toBe('SOME_MODAL');
|
||||
expect(store.whichModal).toBe("SOME_MODAL");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,42 +3,42 @@
|
||||
// Authors:
|
||||
// imacat.yang@dsp.im (imacat), 2026/03/05
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import ResultArrow from '@/components/Discover/Conformance/ConformanceSidebar/ResultArrow.vue';
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import ResultArrow from "@/components/Discover/Conformance/ConformanceSidebar/ResultArrow.vue";
|
||||
|
||||
describe('ResultArrow', () => {
|
||||
it('renders list items from data prop', () => {
|
||||
describe("ResultArrow", () => {
|
||||
it("renders list items from data prop", () => {
|
||||
const wrapper = mount(ResultArrow, {
|
||||
props: {
|
||||
data: ['Activity A', 'Activity B', 'Activity C'],
|
||||
data: ["Activity A", "Activity B", "Activity C"],
|
||||
select: null,
|
||||
},
|
||||
});
|
||||
const items = wrapper.findAll('li');
|
||||
const items = wrapper.findAll("li");
|
||||
expect(items.length).toBe(3);
|
||||
expect(items[0].text()).toContain('Activity A');
|
||||
expect(items[1].text()).toContain('Activity B');
|
||||
expect(items[2].text()).toContain('Activity C');
|
||||
expect(items[0].text()).toContain("Activity A");
|
||||
expect(items[1].text()).toContain("Activity B");
|
||||
expect(items[2].text()).toContain("Activity C");
|
||||
});
|
||||
|
||||
it('renders empty list when data is null', () => {
|
||||
it("renders empty list when data is null", () => {
|
||||
const wrapper = mount(ResultArrow, {
|
||||
props: { data: null, select: null },
|
||||
});
|
||||
const items = wrapper.findAll('li');
|
||||
const items = wrapper.findAll("li");
|
||||
expect(items.length).toBe(0);
|
||||
});
|
||||
|
||||
it('renders arrow_circle_down icon for each item', () => {
|
||||
it("renders arrow_circle_down icon for each item", () => {
|
||||
const wrapper = mount(ResultArrow, {
|
||||
props: {
|
||||
data: ['Task 1'],
|
||||
data: ["Task 1"],
|
||||
select: null,
|
||||
},
|
||||
});
|
||||
expect(wrapper.find('span.material-symbols-outlined').text()).toContain(
|
||||
'arrow_circle_down',
|
||||
expect(wrapper.find("span.material-symbols-outlined").text()).toContain(
|
||||
"arrow_circle_down",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
// 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';
|
||||
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', () => {
|
||||
describe("ResultCheck", () => {
|
||||
const mountResultCheck = (props = {}) => {
|
||||
return mount(ResultCheck, {
|
||||
props: {
|
||||
@@ -26,41 +26,41 @@ describe('ResultCheck', () => {
|
||||
});
|
||||
};
|
||||
|
||||
it('renders list from select prop on creation', () => {
|
||||
it("renders list from select prop on creation", () => {
|
||||
const wrapper = mountResultCheck({
|
||||
select: ['Activity X', 'Activity Y'],
|
||||
select: ["Activity X", "Activity Y"],
|
||||
});
|
||||
const items = wrapper.findAll('li');
|
||||
const items = wrapper.findAll("li");
|
||||
expect(items.length).toBe(2);
|
||||
expect(items[0].text()).toContain('Activity X');
|
||||
expect(items[1].text()).toContain('Activity Y');
|
||||
expect(items[0].text()).toContain("Activity X");
|
||||
expect(items[1].text()).toContain("Activity Y");
|
||||
});
|
||||
|
||||
it('renders empty when select is null', () => {
|
||||
it("renders empty when select is null", () => {
|
||||
const wrapper = mountResultCheck({ select: null });
|
||||
const items = wrapper.findAll('li');
|
||||
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("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);
|
||||
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');
|
||||
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');
|
||||
it("updates list when select prop changes", async () => {
|
||||
const wrapper = mountResultCheck({ select: ["Old"] });
|
||||
await wrapper.setProps({ select: ["Changed"] });
|
||||
expect(wrapper.text()).toContain("Changed");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
// 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';
|
||||
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', () => {
|
||||
describe("ResultDot", () => {
|
||||
const mountResultDot = (props = {}) => {
|
||||
return mount(ResultDot, {
|
||||
props: {
|
||||
@@ -26,31 +26,31 @@ describe('ResultDot', () => {
|
||||
});
|
||||
};
|
||||
|
||||
it('renders list from select prop on creation', () => {
|
||||
it("renders list from select prop on creation", () => {
|
||||
const data = [
|
||||
{ category: 'Start', task: 'Task A' },
|
||||
{ category: 'End', task: 'Task B' },
|
||||
{ category: "Start", task: "Task A" },
|
||||
{ category: "End", task: "Task B" },
|
||||
];
|
||||
const wrapper = mountResultDot({ select: data });
|
||||
const items = wrapper.findAll('li');
|
||||
const items = wrapper.findAll("li");
|
||||
expect(items.length).toBe(2);
|
||||
expect(items[0].text()).toContain('Start');
|
||||
expect(items[0].text()).toContain('Task A');
|
||||
expect(items[0].text()).toContain("Start");
|
||||
expect(items[0].text()).toContain("Task A");
|
||||
});
|
||||
|
||||
it('renders empty when select is null', () => {
|
||||
it("renders empty when select is null", () => {
|
||||
const wrapper = mountResultDot({ select: null });
|
||||
const items = wrapper.findAll('li');
|
||||
const items = wrapper.findAll("li");
|
||||
expect(items.length).toBe(0);
|
||||
});
|
||||
|
||||
it('updates list when timeResultData prop changes', async () => {
|
||||
it("updates list when timeResultData prop changes", async () => {
|
||||
const wrapper = mountResultDot({ select: null });
|
||||
expect(wrapper.findAll('li').length).toBe(0);
|
||||
expect(wrapper.findAll("li").length).toBe(0);
|
||||
|
||||
const newData = [{ category: 'Mid', task: 'Task C' }];
|
||||
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');
|
||||
expect(wrapper.findAll("li").length).toBe(1);
|
||||
expect(wrapper.text()).toContain("Task C");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
// Authors:
|
||||
// imacat.yang@dsp.im (imacat), 2026/03/05
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import Search from '@/components/Search.vue';
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import Search from "@/components/Search.vue";
|
||||
|
||||
describe('Search', () => {
|
||||
it('renders search form', () => {
|
||||
describe("Search", () => {
|
||||
it("renders search form", () => {
|
||||
const wrapper = mount(Search);
|
||||
expect(wrapper.find('form[role="search"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('contains search input', () => {
|
||||
it("contains search input", () => {
|
||||
const wrapper = mount(Search);
|
||||
const input = wrapper.find('input[type="search"]');
|
||||
expect(input.exists()).toBe(true);
|
||||
expect(input.attributes('placeholder')).toBe('Search Activity');
|
||||
expect(input.attributes("placeholder")).toBe("Search Activity");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user