// 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 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);
  });
});
