에디터 정리 및 버그 수정
This commit is contained in:
@@ -102,4 +102,63 @@ describe("PublicPageRenderer - 버튼 블록 스타일", () => {
|
||||
// lg → 12px → 12 / 16 = 0.75em
|
||||
expect(link!.style.borderRadius).toBe("0.75em");
|
||||
});
|
||||
|
||||
it("버튼에 imageSrc 가 있으면 이미지와 텍스트를 함께 렌더링해야 한다 (좌측 배치)", () => {
|
||||
const blocks: Block[] = [
|
||||
{
|
||||
id: "btn_img_left",
|
||||
type: "button",
|
||||
props: {
|
||||
label: "이미지 버튼",
|
||||
href: "#",
|
||||
imageSrc: "https://example.com/icon.png",
|
||||
imageAlt: "아이콘",
|
||||
imagePlacement: "left",
|
||||
} as any,
|
||||
},
|
||||
];
|
||||
|
||||
const { container } = render(<PublicPageRenderer blocks={blocks} />);
|
||||
|
||||
const link = container.querySelector("a") as HTMLAnchorElement | null;
|
||||
expect(link).not.toBeNull();
|
||||
|
||||
const img = link!.querySelector("img") as HTMLImageElement | null;
|
||||
expect(img).not.toBeNull();
|
||||
expect(img!.src).toContain("https://example.com/icon.png");
|
||||
expect(img!.alt).toBe("아이콘");
|
||||
|
||||
const labelNode = Array.from(link!.querySelectorAll("span")).find((el) =>
|
||||
el.textContent?.includes("이미지 버튼"),
|
||||
);
|
||||
expect(labelNode).toBeTruthy();
|
||||
});
|
||||
|
||||
it("imagePlacement 가 top 인 경우 이미지가 텍스트 위쪽에 렌더링되어야 한다", () => {
|
||||
const blocks: Block[] = [
|
||||
{
|
||||
id: "btn_img_top",
|
||||
type: "button",
|
||||
props: {
|
||||
label: "위쪽 이미지 버튼",
|
||||
href: "#",
|
||||
imageSrc: "https://example.com/icon-top.png",
|
||||
imageAlt: "위쪽 아이콘",
|
||||
imagePlacement: "top",
|
||||
} as any,
|
||||
},
|
||||
];
|
||||
|
||||
const { container } = render(<PublicPageRenderer blocks={blocks} />);
|
||||
|
||||
const link = container.querySelector("a") as HTMLAnchorElement | null;
|
||||
expect(link).not.toBeNull();
|
||||
|
||||
const wrapper = link!.querySelector("span") as HTMLSpanElement | null;
|
||||
expect(wrapper).not.toBeNull();
|
||||
expect(wrapper!.className).toContain("flex-col");
|
||||
|
||||
const firstChild = wrapper!.firstElementChild as HTMLElement | null;
|
||||
expect(firstChild?.tagName.toLowerCase()).toBe("img");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user