Skip to content

Instantly share code, notes, and snippets.

@jpzwarte
Created March 7, 2023 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpzwarte/ff156a89e2b7eee18094638b5712d3e2 to your computer and use it in GitHub Desktop.
Save jpzwarte/ff156a89e2b7eee18094638b5712d3e2 to your computer and use it in GitHub Desktop.
import type { StoryObj } from '@storybook/web-components';
import type { RouterLocation } from '@vaadin/router';
import { html } from 'lit';
import { rest } from 'msw';
import { absenceNotices } from '../../data-mocks.js';
import './register.js';
export default {
title: 'Absence/Pages/Details',
render: ({ id }: { id: string }) =>
html`<att-absence-details .location=${{ params: { id: id } } as unknown as RouterLocation}></att-absence-details>`,
args: {
id: '0'
},
parameters: {
layout: 'fullscreen',
msw: {
handlers: [
rest.get('/api/v2/absence-notices/0', async (_, res, ctx) => res(ctx.json(absenceNotices[0]))),
rest.get('/api/v2/absence-notices/1', async (_, res, ctx) => res(ctx.status(404))),
rest.get('/api/v2/absence-notices/2', async (_, res, ctx) => res(ctx.delay(3000), ctx.json(absenceNotices[1])))
]
}
}
};
export const Desktop: StoryObj = {};
export const Mobile: StoryObj = {
parameters: {
viewport: {
defaultViewport: 'iphone6'
}
}
};
export const NotFound: StoryObj = {
...Mobile,
args: {
id: '1'
}
};
export const Loading: StoryObj = {
...Mobile,
args: {
id: '2'
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment