Add gradient background tests

This commit is contained in:
Nathan Chu 2020-08-02 14:50:30 -04:00
parent 66836db71b
commit 3a3d8d2c5e

View File

@ -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"
);
});
});