Newer
Older
smart-home-server / webclient-vue / src / features / devices / components / __tests__ / DeviceStateCell.spec.js
@Eugene Sukhodolskiy Eugene Sukhodolskiy 1 day ago 1 KB Add script detail pages with scope grouping
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");
  });
});