Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests(wakatime card): fix correct render test #3506

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
158 changes: 157 additions & 1 deletion tests/__snapshots__/renderWakatimeCard.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,162 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Test Render WakaTime Card should render correctly 1`] = `[Function]`;
exports[`Test Render WakaTime Card should render correctly 1`] = `
"
<svg
width="495"
height="150"
viewBox="0 0 495 150"
fill="none"
xmlns="http://www.w3.org/2000/svg"
role="img"
aria-labelledby="descId"
>
<title id="titleId"></title>
<desc id="descId"></desc>
<style>
.header {
font: 600 18px 'Segoe UI', Ubuntu, Sans-Serif;
fill: #2f80ed;
animation: fadeInAnimation 0.8s ease-in-out forwards;
}
@supports(-moz-appearance: auto) {
/* Selector detects Firefox */
.header { font-size: 15.5px; }
}


.stat {
font: 600 14px 'Segoe UI', Ubuntu, "Helvetica Neue", Sans-Serif; fill: #434d58;
}
@supports(-moz-appearance: auto) {
/* Selector detects Firefox */
.stat { font-size:12px; }
}
.stagger {
opacity: 0;
animation: fadeInAnimation 0.3s ease-in-out forwards;
}
.not_bold { font-weight: 400 }
.bold { font-weight: 700 }

@keyframes slideInAnimation {
from {
width: 0;
}
to {
width: calc(100%-100px);
}
}
@keyframes growWidthAnimation {
from {
width: 0;
}
to {
width: 100%;
}
}
.lang-name { font: 400 11px 'Segoe UI', Ubuntu, Sans-Serif; fill: #434d58 }
#rect-mask rect{
animation: slideInAnimation 1s ease-in-out forwards;
}
.lang-progress{
animation: growWidthAnimation 0.6s ease-in-out forwards;
}




</style>



<rect
data-testid="card-bg"
x="0.5"
y="0.5"
rx="4.5"
height="99%"
stroke="#e4e2e2"
width="494"
fill="#fffefe"
stroke-opacity="1"
/>


<g
data-testid="card-title"
transform="translate(25, 35)"
>
<g transform="translate(0, 0)">
<text
x="0"
y="0"
class="header"
data-testid="header"
>WakaTime Stats (last 7 days)</text>
</g>
</g>


<g
data-testid="main-card-body"
transform="translate(0, 55)"
>

<svg x="0" y="0" width="100%">
<g transform="translate(0, 0)">
<g class="stagger" style="animation-delay: 450ms" transform="translate(25, 0)">
<text class="stat bold" y="12.5" data-testid="Other">Other:</text>
<text
class="stat"
x="350"
y="12.5"
>19 mins</text>

<svg width="220" x="110" y="4">
<rect rx="5" ry="5" x="0" y="0" width="220" height="8" fill="#434d58"></rect>
<svg data-testid="lang-progress" width="89.38%">
<rect
height="8"
fill="#2f80ed"
rx="5" ry="5" x="0" y="0"
class="lang-progress"
style="animation-delay: 750ms;"
/>
</svg>
</svg>

</g>
</g><g transform="translate(0, 25)">
<g class="stagger" style="animation-delay: 600ms" transform="translate(25, 0)">
<text class="stat bold" y="12.5" data-testid="TypeScript">TypeScript:</text>
<text
class="stat"
x="350"
y="12.5"
>1 min</text>

<svg width="220" x="110" y="4">
<rect rx="5" ry="5" x="0" y="0" width="220" height="8" fill="#434d58"></rect>
<svg data-testid="lang-progress" width="6.25%">
<rect
height="8"
fill="#2f80ed"
rx="5" ry="5" x="0" y="0"
class="lang-progress"
style="animation-delay: 900ms;"
/>
</svg>
</svg>

</g>
</g>
</svg>

</g>
</svg>
"
`;

exports[`Test Render WakaTime Card should render correctly with compact layout 1`] = `
"
Expand Down
5 changes: 2 additions & 3 deletions tests/renderWakatimeCard.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { queryByTestId } from "@testing-library/dom";
import "@testing-library/jest-dom";
import { renderWakatimeCard } from "../src/cards/wakatime-card.js";
import { getCardColors } from "../src/common/utils.js";
import { wakaTimeData } from "./fetchWakatime.test.js";
import { expect, it, describe } from "@jest/globals";

describe("Test Render WakaTime Card", () => {
it("should render correctly", () => {
// const card = renderWakatimeCard(wakaTimeData.data);
expect(getCardColors).toMatchSnapshot();
const card = renderWakatimeCard(wakaTimeData.data);
expect(card).toMatchSnapshot();
});

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