import { describe, it, expect } from "vitest"; import { mount } from "@vue/test-utils"; import JsonView from "../JsonView.vue"; describe("JsonView", () => { it("pretty-prints the value with 2-space indent", () => { const wrapper = mount(JsonView, { props: { value: { a: 1, b: "two" } }, }); const text = wrapper.get("[data-testid=json-view]").text(); expect(text).toContain('"a": 1'); expect(text).toContain('"b": "two"'); }); it("renders an empty pre when value is undefined", () => { const wrapper = mount(JsonView, { props: { value: undefined } }); expect(wrapper.get("[data-testid=json-view]").text()).toBe(""); }); it("shows the label header when provided", () => { const wrapper = mount(JsonView, { props: { value: {}, label: "Body schema" }, }); expect(wrapper.text()).toContain("Body schema"); }); it("applies max-height style when maxLines is set", () => { const wrapper = mount(JsonView, { props: { value: {}, maxLines: 5 }, }); expect(wrapper.get("[data-testid=json-view]").attributes("style")).toContain("max-height"); }); });