diff --git a/src/DateTimeRangePicker/DatePicker/Header/__tests__/Header.test.tsx b/src/DateTimeRangePicker/DatePicker/Header/__tests__/Header.test.tsx index 5a39f4b..11f5105 100644 --- a/src/DateTimeRangePicker/DatePicker/Header/__tests__/Header.test.tsx +++ b/src/DateTimeRangePicker/DatePicker/Header/__tests__/Header.test.tsx @@ -1,10 +1,10 @@ -import React from 'react' -import { shallow } from 'enzyme' + import React from 'react' + import { shallow } from 'enzyme' -import Header from '../Header' -import moment from 'moment' + import Header from '../Header' + import moment from 'moment' -describe('Date/time range picker header', () => { + describe('Date/time range picker header', () => { it('should render correctly', () => { const component = shallow(
= { title: 'Example/Button', component: Button, - // More on argTypes: https://storybook.js.org/docs/react/api/argtypes argTypes: { - backgroundColor: { control: 'color' }, - }, -} as ComponentMeta; + backgroundColor: { control: 'color' } + } +} +export default componentMeta // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args -const Template: ComponentStory = (args) => - ); -}; + ) +} diff --git a/src/stories/Header.stories.tsx b/src/stories/Header.stories.tsx index 7e9283e..fea050d 100644 --- a/src/stories/Header.stories.tsx +++ b/src/stories/Header.stories.tsx @@ -1,25 +1,26 @@ -import React from 'react'; -import { ComponentStory, ComponentMeta } from '@storybook/react'; +import React from 'react' +import { ComponentStory, ComponentMeta } from '@storybook/react' -import { Header } from './Header'; +import { Header } from './Header' -export default { +const componentMeta: ComponentMeta = { title: 'Example/Header', component: Header, parameters: { - // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout - layout: 'fullscreen', - }, -} as ComponentMeta; + layout: 'fullscreen' + } +} -const Template: ComponentStory = (args) =>
; +export default componentMeta -export const LoggedIn = Template.bind({}); +const Template: ComponentStory = (args) =>
+ +export const LoggedIn = Template.bind({}) LoggedIn.args = { user: { - name: 'Jane Doe', - }, -}; + name: 'Jane Doe' + } +} -export const LoggedOut = Template.bind({}); -LoggedOut.args = {}; +export const LoggedOut = Template.bind({}) +LoggedOut.args = {} diff --git a/src/stories/Header.tsx b/src/stories/Header.tsx index dc3f3c1..19ca040 100644 --- a/src/stories/Header.tsx +++ b/src/stories/Header.tsx @@ -1,17 +1,17 @@ -import React from 'react'; +import React from 'react' -import { Button } from './Button'; -import './header.css'; +import { Button } from './Button' +import './header.css' type User = { - name: string; -}; + name: string +} interface HeaderProps { - user?: User; - onLogin: () => void; - onLogout: () => void; - onCreateAccount: () => void; + user?: User + onLogin: () => void + onLogout: () => void + onCreateAccount: () => void } export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => ( @@ -53,4 +53,4 @@ export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps
-); +) diff --git a/src/stories/Page.stories.tsx b/src/stories/Page.stories.tsx index a0ea79f..de42ca4 100644 --- a/src/stories/Page.stories.tsx +++ b/src/stories/Page.stories.tsx @@ -1,26 +1,26 @@ -import React from 'react'; -import { ComponentStory, ComponentMeta } from '@storybook/react'; -import { within, userEvent } from '@storybook/testing-library'; -import { Page } from './Page'; +import React from 'react' +import { ComponentStory, ComponentMeta } from '@storybook/react' +import { within, userEvent } from '@storybook/testing-library' +import { Page } from './Page' -export default { +const componentMeta: ComponentMeta = { title: 'Example/Page', component: Page, parameters: { - // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout - layout: 'fullscreen', - }, -} as ComponentMeta; + layout: 'fullscreen' + } +} +export default componentMeta -const Template: ComponentStory = (args) => ; +const Template: ComponentStory = (args) => -export const LoggedOut = Template.bind({}); +export const LoggedOut = Template.bind({}) -export const LoggedIn = Template.bind({}); +export const LoggedIn = Template.bind({}) // More on interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing LoggedIn.play = async ({ canvasElement }) => { - const canvas = within(canvasElement); - const loginButton = await canvas.getByRole('button', { name: /Log in/i }); - await userEvent.click(loginButton); -}; + const canvas = within(canvasElement) + const loginButton = await canvas.getByRole('button', { name: /Log in/i }) + await userEvent.click(loginButton) +} diff --git a/src/stories/Page.tsx b/src/stories/Page.tsx index 522d342..aa63413 100644 --- a/src/stories/Page.tsx +++ b/src/stories/Page.tsx @@ -1,14 +1,14 @@ -import React from 'react'; +import React from 'react' -import { Header } from './Header'; -import './page.css'; +import { Header } from './Header' +import './page.css' type User = { name: string; -}; +} export const Page: React.VFC = () => { - const [user, setUser] = React.useState(); + const [user, setUser] = React.useState() return (
@@ -69,5 +69,5 @@ export const Page: React.VFC = () => {
- ); -}; + ) +}