diff --git a/tests/card.test.js b/tests/card.test.js index 15d1d7b..4e8b2df 100644 --- a/tests/card.test.js +++ b/tests/card.test.js @@ -133,4 +133,39 @@ describe("Card", () => { "#fff" ); }); + it("should render gradient backgrounds", () => { + const { titleColor, textColor, iconColor, bgColor } = getCardColors({ + title_color: "f00", + icon_color: "0f0", + text_color: "00f", + bg_color: "90,fff,000", + theme: "default", + }); + const card = new Card({ + height: 200, + colors: { + titleColor, + textColor, + iconColor, + bgColor, + }, + }); + document.body.innerHTML = card.render(``); + expect(queryByTestId(document.body, "card-bg")).toHaveAttribute( + "fill", + "url(#gradient)" + ); + expect(document.querySelector('defs linearGradient')).toHaveAttribute( + "gradientTransform", + "rotate(90)" + ); + expect(document.querySelector('defs linearGradient stop:nth-child(1)')).toHaveAttribute( + "stop-color", + "#fff" + ); + expect(document.querySelector('defs linearGradient stop:nth-child(2)')).toHaveAttribute( + "stop-color", + "#000" + ); + }); });