Skip to content

Commit bbadc0b

Browse files
authored
tests(wakatime card): add percent display format test (#3505)
1 parent 411e799 commit bbadc0b

File tree

2 files changed

+165
-0
lines changed

2 files changed

+165
-0
lines changed

tests/__snapshots__/renderWakatimeCard.test.js.snap

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,3 +461,161 @@ exports[`Test Render WakaTime Card should render correctly with compact layout w
461461
</svg>
462462
"
463463
`;
464+
465+
exports[`Test Render WakaTime Card should render correctly with percent display format 1`] = `
466+
"
467+
<svg
468+
width="495"
469+
height="150"
470+
viewBox="0 0 495 150"
471+
fill="none"
472+
xmlns="http://www.w3.org/2000/svg"
473+
role="img"
474+
aria-labelledby="descId"
475+
>
476+
<title id="titleId"></title>
477+
<desc id="descId"></desc>
478+
<style>
479+
.header {
480+
font: 600 18px 'Segoe UI', Ubuntu, Sans-Serif;
481+
fill: #2f80ed;
482+
animation: fadeInAnimation 0.8s ease-in-out forwards;
483+
}
484+
@supports(-moz-appearance: auto) {
485+
/* Selector detects Firefox */
486+
.header { font-size: 15.5px; }
487+
}
488+
489+
490+
.stat {
491+
font: 600 14px 'Segoe UI', Ubuntu, "Helvetica Neue", Sans-Serif; fill: #434d58;
492+
}
493+
@supports(-moz-appearance: auto) {
494+
/* Selector detects Firefox */
495+
.stat { font-size:12px; }
496+
}
497+
.stagger {
498+
opacity: 0;
499+
animation: fadeInAnimation 0.3s ease-in-out forwards;
500+
}
501+
.not_bold { font-weight: 400 }
502+
.bold { font-weight: 700 }
503+
504+
@keyframes slideInAnimation {
505+
from {
506+
width: 0;
507+
}
508+
to {
509+
width: calc(100%-100px);
510+
}
511+
}
512+
@keyframes growWidthAnimation {
513+
from {
514+
width: 0;
515+
}
516+
to {
517+
width: 100%;
518+
}
519+
}
520+
.lang-name { font: 400 11px 'Segoe UI', Ubuntu, Sans-Serif; fill: #434d58 }
521+
#rect-mask rect{
522+
animation: slideInAnimation 1s ease-in-out forwards;
523+
}
524+
.lang-progress{
525+
animation: growWidthAnimation 0.6s ease-in-out forwards;
526+
}
527+
528+
529+
530+
531+
</style>
532+
533+
534+
535+
<rect
536+
data-testid="card-bg"
537+
x="0.5"
538+
y="0.5"
539+
rx="4.5"
540+
height="99%"
541+
stroke="#e4e2e2"
542+
width="494"
543+
fill="#fffefe"
544+
stroke-opacity="1"
545+
/>
546+
547+
548+
<g
549+
data-testid="card-title"
550+
transform="translate(25, 35)"
551+
>
552+
<g transform="translate(0, 0)">
553+
<text
554+
x="0"
555+
y="0"
556+
class="header"
557+
data-testid="header"
558+
>WakaTime Stats (last 7 days)</text>
559+
</g>
560+
</g>
561+
562+
563+
<g
564+
data-testid="main-card-body"
565+
transform="translate(0, 55)"
566+
>
567+
568+
<svg x="0" y="0" width="100%">
569+
<g transform="translate(0, 0)">
570+
<g class="stagger" style="animation-delay: 450ms" transform="translate(25, 0)">
571+
<text class="stat bold" y="12.5" data-testid="Other">Other:</text>
572+
<text
573+
class="stat"
574+
x="350"
575+
y="12.5"
576+
>47.39 %</text>
577+
578+
<svg width="220" x="110" y="4">
579+
<rect rx="5" ry="5" x="0" y="0" width="220" height="8" fill="#434d58"></rect>
580+
<svg data-testid="lang-progress" width="47.39%">
581+
<rect
582+
height="8"
583+
fill="#2f80ed"
584+
rx="5" ry="5" x="0" y="0"
585+
class="lang-progress"
586+
style="animation-delay: 750ms;"
587+
/>
588+
</svg>
589+
</svg>
590+
591+
</g>
592+
</g><g transform="translate(0, 25)">
593+
<g class="stagger" style="animation-delay: 600ms" transform="translate(25, 0)">
594+
<text class="stat bold" y="12.5" data-testid="TypeScript">TypeScript:</text>
595+
<text
596+
class="stat"
597+
x="350"
598+
y="12.5"
599+
>50.48 %</text>
600+
601+
<svg width="220" x="110" y="4">
602+
<rect rx="5" ry="5" x="0" y="0" width="220" height="8" fill="#434d58"></rect>
603+
<svg data-testid="lang-progress" width="50.48%">
604+
<rect
605+
height="8"
606+
fill="#2f80ed"
607+
rx="5" ry="5" x="0" y="0"
608+
class="lang-progress"
609+
style="animation-delay: 900ms;"
610+
/>
611+
</svg>
612+
</svg>
613+
614+
</g>
615+
</g>
616+
</svg>
617+
618+
</g>
619+
</svg>
620+
"
621+
`;

tests/renderWakatimeCard.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,11 @@ describe("Test Render WakaTime Card", () => {
8282
"No coding activity this week",
8383
);
8484
});
85+
86+
it("should render correctly with percent display format", () => {
87+
const card = renderWakatimeCard(wakaTimeData.data, {
88+
display_format: "percent",
89+
});
90+
expect(card).toMatchSnapshot();
91+
});
8592
});

0 commit comments

Comments
 (0)