Skip to content

Commit 411e799

Browse files
authored
tests(wakatime card): fix correct render test (#3506)
1 parent 070dbd3 commit 411e799

File tree

2 files changed

+159
-4
lines changed

2 files changed

+159
-4
lines changed

tests/__snapshots__/renderWakatimeCard.test.js.snap

Lines changed: 157 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,162 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Test Render WakaTime Card should render correctly 1`] = `[Function]`;
3+
exports[`Test Render WakaTime Card should render correctly 1`] = `
4+
"
5+
<svg
6+
width="495"
7+
height="150"
8+
viewBox="0 0 495 150"
9+
fill="none"
10+
xmlns="http://www.w3.org/2000/svg"
11+
role="img"
12+
aria-labelledby="descId"
13+
>
14+
<title id="titleId"></title>
15+
<desc id="descId"></desc>
16+
<style>
17+
.header {
18+
font: 600 18px 'Segoe UI', Ubuntu, Sans-Serif;
19+
fill: #2f80ed;
20+
animation: fadeInAnimation 0.8s ease-in-out forwards;
21+
}
22+
@supports(-moz-appearance: auto) {
23+
/* Selector detects Firefox */
24+
.header { font-size: 15.5px; }
25+
}
26+
27+
28+
.stat {
29+
font: 600 14px 'Segoe UI', Ubuntu, "Helvetica Neue", Sans-Serif; fill: #434d58;
30+
}
31+
@supports(-moz-appearance: auto) {
32+
/* Selector detects Firefox */
33+
.stat { font-size:12px; }
34+
}
35+
.stagger {
36+
opacity: 0;
37+
animation: fadeInAnimation 0.3s ease-in-out forwards;
38+
}
39+
.not_bold { font-weight: 400 }
40+
.bold { font-weight: 700 }
41+
42+
@keyframes slideInAnimation {
43+
from {
44+
width: 0;
45+
}
46+
to {
47+
width: calc(100%-100px);
48+
}
49+
}
50+
@keyframes growWidthAnimation {
51+
from {
52+
width: 0;
53+
}
54+
to {
55+
width: 100%;
56+
}
57+
}
58+
.lang-name { font: 400 11px 'Segoe UI', Ubuntu, Sans-Serif; fill: #434d58 }
59+
#rect-mask rect{
60+
animation: slideInAnimation 1s ease-in-out forwards;
61+
}
62+
.lang-progress{
63+
animation: growWidthAnimation 0.6s ease-in-out forwards;
64+
}
65+
66+
67+
68+
69+
</style>
70+
71+
72+
73+
<rect
74+
data-testid="card-bg"
75+
x="0.5"
76+
y="0.5"
77+
rx="4.5"
78+
height="99%"
79+
stroke="#e4e2e2"
80+
width="494"
81+
fill="#fffefe"
82+
stroke-opacity="1"
83+
/>
84+
85+
86+
<g
87+
data-testid="card-title"
88+
transform="translate(25, 35)"
89+
>
90+
<g transform="translate(0, 0)">
91+
<text
92+
x="0"
93+
y="0"
94+
class="header"
95+
data-testid="header"
96+
>WakaTime Stats (last 7 days)</text>
97+
</g>
98+
</g>
99+
100+
101+
<g
102+
data-testid="main-card-body"
103+
transform="translate(0, 55)"
104+
>
105+
106+
<svg x="0" y="0" width="100%">
107+
<g transform="translate(0, 0)">
108+
<g class="stagger" style="animation-delay: 450ms" transform="translate(25, 0)">
109+
<text class="stat bold" y="12.5" data-testid="Other">Other:</text>
110+
<text
111+
class="stat"
112+
x="350"
113+
y="12.5"
114+
>19 mins</text>
115+
116+
<svg width="220" x="110" y="4">
117+
<rect rx="5" ry="5" x="0" y="0" width="220" height="8" fill="#434d58"></rect>
118+
<svg data-testid="lang-progress" width="89.38%">
119+
<rect
120+
height="8"
121+
fill="#2f80ed"
122+
rx="5" ry="5" x="0" y="0"
123+
class="lang-progress"
124+
style="animation-delay: 750ms;"
125+
/>
126+
</svg>
127+
</svg>
128+
129+
</g>
130+
</g><g transform="translate(0, 25)">
131+
<g class="stagger" style="animation-delay: 600ms" transform="translate(25, 0)">
132+
<text class="stat bold" y="12.5" data-testid="TypeScript">TypeScript:</text>
133+
<text
134+
class="stat"
135+
x="350"
136+
y="12.5"
137+
>1 min</text>
138+
139+
<svg width="220" x="110" y="4">
140+
<rect rx="5" ry="5" x="0" y="0" width="220" height="8" fill="#434d58"></rect>
141+
<svg data-testid="lang-progress" width="6.25%">
142+
<rect
143+
height="8"
144+
fill="#2f80ed"
145+
rx="5" ry="5" x="0" y="0"
146+
class="lang-progress"
147+
style="animation-delay: 900ms;"
148+
/>
149+
</svg>
150+
</svg>
151+
152+
</g>
153+
</g>
154+
</svg>
155+
156+
</g>
157+
</svg>
158+
"
159+
`;
4160

5161
exports[`Test Render WakaTime Card should render correctly with compact layout 1`] = `
6162
"

tests/renderWakatimeCard.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { queryByTestId } from "@testing-library/dom";
22
import "@testing-library/jest-dom";
33
import { renderWakatimeCard } from "../src/cards/wakatime.js";
4-
import { getCardColors } from "../src/common/utils.js";
54
import { wakaTimeData } from "./fetchWakatime.test.js";
65
import { expect, it, describe } from "@jest/globals";
76

87
describe("Test Render WakaTime Card", () => {
98
it("should render correctly", () => {
10-
// const card = renderWakatimeCard(wakaTimeData.data);
11-
expect(getCardColors).toMatchSnapshot();
9+
const card = renderWakatimeCard(wakaTimeData.data);
10+
expect(card).toMatchSnapshot();
1211
});
1312

1413
it("should render correctly with compact layout", () => {

0 commit comments

Comments
 (0)