import { describe, it, expect } from "vitest";
import { mount } from "@vue/test-utils";
import DeviceStateCell from "../DeviceStateCell.vue";

describe("DeviceStateCell", () => {
  it("shows loading state", () => {
    const wrapper = mount(DeviceStateCell, {
      props: { state: { status: "loading", message: "Loading" } },
    });

    expect(wrapper.text()).toContain("Loading");
  });

  it("shows ready state with message", () => {
    const wrapper = mount(DeviceStateCell, {
      props: { state: { status: "ready", message: "ok" } },
    });

    expect(wrapper.text()).toBe("ok");
  });

  it("shows error state with message", () => {
    const wrapper = mount(DeviceStateCell, {
      props: { state: { status: "error", message: "Timeout" } },
    });

    expect(wrapper.text()).toBe("Timeout");
  });

  it("shows skipped state with message", () => {
    const wrapper = mount(DeviceStateCell, {
      props: { state: { status: "skipped", message: "Skipped" } },
    });

    expect(wrapper.text()).toBe("Skipped");
  });

  it("falls back to default message for idle state", () => {
    const wrapper = mount(DeviceStateCell, {
      props: { state: { status: "idle" } },
    });

    expect(wrapper.text()).toBe("Not loaded");
  });
});
