-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4def705
commit 57761a4
Showing
9 changed files
with
80 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// Define your own mock data here: | ||
export const standard = (/* vars, { ctx, req } */) => ({ | ||
sitesList: { | ||
__typename: "sitesList" as const, | ||
__typename: 'sitesList' as const, | ||
id: 42, | ||
}, | ||
}); | ||
}) |
30 changes: 15 additions & 15 deletions
30
web/src/components/SitesListCell/SitesListCell.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
import { Loading, Empty, Failure, Success } from "./SitesListCell"; | ||
import { standard } from "./SitesListCell.mock"; | ||
import { Loading, Empty, Failure, Success } from './SitesListCell' | ||
import { standard } from './SitesListCell.mock' | ||
|
||
const meta: Meta = { | ||
title: "Cells/SitesListCell", | ||
tags: ["autodocs"], | ||
}; | ||
title: 'Cells/SitesListCell', | ||
tags: ['autodocs'], | ||
} | ||
|
||
export default meta; | ||
export default meta | ||
|
||
export const loading: StoryObj<typeof Loading> = { | ||
render: () => { | ||
return Loading ? <Loading /> : <></>; | ||
return Loading ? <Loading /> : <></> | ||
}, | ||
}; | ||
} | ||
|
||
export const empty: StoryObj<typeof Empty> = { | ||
render: () => { | ||
return Empty ? <Empty /> : <></>; | ||
return Empty ? <Empty /> : <></> | ||
}, | ||
}; | ||
} | ||
|
||
export const failure: StoryObj<typeof Failure> = { | ||
render: (args) => { | ||
return Failure ? <Failure error={new Error("Oh no")} {...args} /> : <></>; | ||
return Failure ? <Failure error={new Error('Oh no')} {...args} /> : <></> | ||
}, | ||
}; | ||
} | ||
|
||
export const success: StoryObj<typeof Success> = { | ||
render: (args) => { | ||
return Success ? <Success {...standard()} {...args} /> : <></>; | ||
return Success ? <Success {...standard()} {...args} /> : <></> | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
import { render } from "@redwoodjs/testing/web"; | ||
import { render } from '@redwoodjs/testing/web' | ||
|
||
import { Loading, Empty, Failure, Success } from "./SitesListCell"; | ||
import { standard } from "./SitesListCell.mock"; | ||
import { Loading, Empty, Failure, Success } from './SitesListCell' | ||
import { standard } from './SitesListCell.mock' | ||
|
||
// Generated boilerplate tests do not account for all circumstances | ||
// and can fail without adjustments, e.g. Float and DateTime types. | ||
// Please refer to the RedwoodJS Testing Docs: | ||
// https://redwoodjs.com/docs/testing#testing-cells | ||
// https://redwoodjs.com/docs/testing#jest-expect-type-considerations | ||
|
||
describe("SitesListCell", () => { | ||
it("renders Loading successfully", () => { | ||
describe('SitesListCell', () => { | ||
it('renders Loading successfully', () => { | ||
expect(() => { | ||
render(<Loading />); | ||
}).not.toThrow(); | ||
}); | ||
render(<Loading />) | ||
}).not.toThrow() | ||
}) | ||
|
||
it("renders Empty successfully", async () => { | ||
it('renders Empty successfully', async () => { | ||
expect(() => { | ||
render(<Empty />); | ||
}).not.toThrow(); | ||
}); | ||
render(<Empty />) | ||
}).not.toThrow() | ||
}) | ||
|
||
it("renders Failure successfully", async () => { | ||
it('renders Failure successfully', async () => { | ||
expect(() => { | ||
render(<Failure error={new Error("Oh no")} />); | ||
}).not.toThrow(); | ||
}); | ||
render(<Failure error={new Error('Oh no')} />) | ||
}).not.toThrow() | ||
}) | ||
|
||
// When you're ready to test the actual output of your component render | ||
// you could test that, for example, certain text is present: | ||
// | ||
// 1. import { screen } from '@redwoodjs/testing/web' | ||
// 2. Add test: expect(screen.getByText('Hello, world')).toBeInTheDocument() | ||
|
||
it("renders Success successfully", async () => { | ||
it('renders Success successfully', async () => { | ||
expect(() => { | ||
render(<Success sitesList={standard().sitesList} />); | ||
}).not.toThrow(); | ||
}); | ||
}); | ||
render(<Success sitesList={standard().sitesList} />) | ||
}).not.toThrow() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
import SitesPage from "./SitesPage"; | ||
import SitesPage from './SitesPage' | ||
|
||
const meta: Meta<typeof SitesPage> = { | ||
component: SitesPage, | ||
}; | ||
} | ||
|
||
export default meta; | ||
export default meta | ||
|
||
type Story = StoryObj<typeof SitesPage>; | ||
type Story = StoryObj<typeof SitesPage> | ||
|
||
export const Primary: Story = {}; | ||
export const Primary: Story = {} |
Oops, something went wrong.