This repository has no description
1<script module lang="ts">
2 import { defineMeta, type StoryContext } from "@storybook/addon-svelte-csf";
3 import { expect } from "storybook/test";
4 import DiffStatPill from "./DiffStatPill.svelte";
5
6 type PlayContext = Pick<StoryContext<Record<string, unknown>>, "canvas" | "canvasElement">;
7
8 const showsBoth = async ({ canvas }: PlayContext) => {
9 await expect(canvas.getByText("+12")).toBeVisible();
10 await expect(canvas.getByText("-4")).toBeVisible();
11 };
12
13 const rendersNothing = async ({ canvasElement }: PlayContext) => {
14 await expect(canvasElement.textContent?.trim()).toBe("");
15 };
16
17 const { Story } = defineMeta({
18 title: "Repo/DiffStatPill",
19 component: DiffStatPill,
20 tags: ["autodocs"],
21 args: {
22 stat: { insertions: 12, deletions: 4, files_changed: 3 }
23 }
24 });
25</script>
26
27<Story name="Insertions and deletions" play={showsBoth} />
28
29<Story name="Insertions only" args={{ stat: { insertions: 12, deletions: 0, files_changed: 1 } }} />
30
31<Story name="Deletions only" args={{ stat: { insertions: 0, deletions: 4, files_changed: 1 } }} />
32
33<Story
34 name="Empty"
35 args={{ stat: { insertions: 0, deletions: 0, files_changed: 0 } }}
36 play={rendersNothing}
37/>