From cea60d6dbdbc12ab65a642b3504698305af7ac4a Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Thu, 7 Dec 2023 12:05:47 -0500 Subject: [PATCH] Update Calendar to fixed "now" date for snapshots --- .storybook/preview.ts | 3 +++ package.json | 1 + src/common/stories/Calendar.stories.ts | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.storybook/preview.ts b/.storybook/preview.ts index 2b70fc18c..2098824b0 100644 --- a/.storybook/preview.ts +++ b/.storybook/preview.ts @@ -1,5 +1,6 @@ import type { Preview } from "@storybook/svelte"; import { initialize, mswLoader } from "msw-storybook-addon"; +import { mockDateDecorator } from "storybook-mock-date-decorator"; import "../src/langs/i18n.js"; import "../src/style/variables.css"; @@ -24,4 +25,6 @@ const preview: Preview = { loaders: [mswLoader], }; +export let decorators = [mockDateDecorator]; + export default preview; diff --git a/package.json b/package.json index 6872e6042..3ffa7bdf9 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "react-dom": "^18.2.0", "serve": "^14.2.0", "storybook": "7.5.3", + "storybook-mock-date-decorator": "^1.0.1", "svelte-jester": "^3.0.0", "tape": "^5.7.2" }, diff --git a/src/common/stories/Calendar.stories.ts b/src/common/stories/Calendar.stories.ts index 06d1a3a5f..f5340ab16 100644 --- a/src/common/stories/Calendar.stories.ts +++ b/src/common/stories/Calendar.stories.ts @@ -3,7 +3,6 @@ import type { Meta, StoryObj } from "@storybook/svelte"; import "@/langs/i18n.js"; import Calendar from "../Calendar.svelte"; -// More on how to set up stories at: https://storybook.js.org/docs/7.0/svelte/writing-stories/introduction const meta: Meta = { title: "Common/Calendar", component: Calendar, @@ -11,12 +10,14 @@ const meta: Meta = { argTypes: { value: { control: { type: "date" } }, }, + parameters: { + date: new Date("December 5, 2023 10:00:00"), + }, }; export default meta; type Story = StoryObj; -// More on writing stories with args: https://storybook.js.org/docs/7.0/svelte/writing-stories/args export const Default: Story = { args: {}, };