Newer
Older
smart-home-server / webclient-vue / src / components / feedback / __tests__ / AppEmptyState.spec.js
@Eugene Sukhodolskiy Eugene Sukhodolskiy 1 day ago 1011 bytes Add script detail pages with scope grouping
import { describe, it, expect } from "vitest";
import { mount } from "@vue/test-utils";
import AppEmptyState from "../AppEmptyState.vue";

describe("AppEmptyState", () => {
  it("renders title and message", () => {
    const wrapper = mount(AppEmptyState, {
      props: {
        title: "No items",
        message: "There is nothing here yet.",
      },
    });

    expect(wrapper.text()).toContain("No items");
    expect(wrapper.text()).toContain("There is nothing here yet.");
  });

  it("uses default title when not provided", () => {
    const wrapper = mount(AppEmptyState, {
      props: {
        message: "Something",
      },
    });

    expect(wrapper.text()).toContain("Nothing here");
  });

  it("does not render message paragraph when empty", () => {
    const wrapper = mount(AppEmptyState, {
      props: {
        title: "Only title",
        message: "",
      },
    });

    expect(wrapper.text()).toContain("Only title");
    expect(wrapper.find("p").exists()).toBe(false);
  });
});