2020-09-19 15:23:39 +08:00
|
|
|
require("@testing-library/jest-dom");
|
|
|
|
const renderWakatimeCard = require("../src/cards/wakatime-card");
|
|
|
|
|
|
|
|
const { wakaTimeData } = require("./fetchWakatime.test");
|
|
|
|
|
|
|
|
describe("Test Render Wakatime Card", () => {
|
|
|
|
it("should render correctly", () => {
|
2020-11-05 02:21:57 +08:00
|
|
|
const card = renderWakatimeCard(wakaTimeData.data);
|
2020-09-19 15:23:39 +08:00
|
|
|
|
2020-11-05 02:21:57 +08:00
|
|
|
expect(card).toMatchSnapshot();
|
|
|
|
});
|
2020-09-19 15:23:39 +08:00
|
|
|
|
2020-11-05 02:21:57 +08:00
|
|
|
it("should render correctly with compact layout", () => {
|
|
|
|
const card = renderWakatimeCard(wakaTimeData.data, { layout: "compact" });
|
2020-09-19 15:23:39 +08:00
|
|
|
|
2020-11-05 02:21:57 +08:00
|
|
|
expect(card).toMatchSnapshot();
|
2020-09-19 15:23:39 +08:00
|
|
|
});
|
2020-10-04 16:05:15 +08:00
|
|
|
|
|
|
|
it("should render translations", () => {
|
|
|
|
document.body.innerHTML = renderWakatimeCard({}, { locale: "cn" });
|
|
|
|
expect(document.getElementsByClassName("header")[0].textContent).toBe(
|
2020-10-04 22:47:13 +08:00
|
|
|
"Wakatime 周统计",
|
2020-10-04 16:05:15 +08:00
|
|
|
);
|
|
|
|
expect(
|
|
|
|
document.querySelector('g[transform="translate(0, 0)"]>text.stat.bold')
|
|
|
|
.textContent,
|
2020-10-04 22:47:13 +08:00
|
|
|
).toBe("本周没有编程活动");
|
2020-10-04 16:05:15 +08:00
|
|
|
});
|
2020-09-19 15:23:39 +08:00
|
|
|
});
|