-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: convert type from cva, upgrade storybook and update test file
- Loading branch information
Showing
18 changed files
with
26,931 additions
and
26,961 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import { screen, render } from 'test-utils' | ||
import userEvent from '@testing-library/user-event' | ||
import Close from '.' | ||
import { screen, render } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import Close from "."; | ||
|
||
describe('<ActionSheet.Close/>', () => { | ||
it('should render correctly with children', () => { | ||
render(<Close>close</Close>) | ||
const close = screen.getByText('close') | ||
expect(close).toBeInTheDocument() | ||
}) | ||
it('should call `handleToggle` method on click', async () => { | ||
const handleClickMock = jest.fn() | ||
render(<Close onClick={handleClickMock}>close</Close>) | ||
const close = screen.getByText('close') | ||
await userEvent.click(close) | ||
expect(handleClickMock).toHaveBeenCalled() | ||
}) | ||
}) | ||
describe("<ActionSheet.Close/>", () => { | ||
it("should render correctly with children", () => { | ||
render(<Close>close</Close>); | ||
const close = screen.getByText("close"); | ||
expect(close).toBeInTheDocument(); | ||
}); | ||
it("should call `handleToggle` method on click", async () => { | ||
const handleClickMock = jest.fn(); | ||
render(<Close onClick={handleClickMock}>close</Close>); | ||
const close = screen.getByText("close"); | ||
await userEvent.click(close); | ||
expect(handleClickMock).toHaveBeenCalled(); | ||
}); | ||
}); |
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,11 +1,15 @@ | ||
import { screen, render } from 'test-utils' | ||
import ActionSheet from '..' | ||
import { screen, render } from "@testing-library/react"; | ||
import ActionSheet from ".."; | ||
|
||
describe('<ActionSheet.Content/>', () => { | ||
it('should render correctly with className and children', () => { | ||
render(<ActionSheet.Content className="px-50">Content</ActionSheet.Content>) | ||
const contentEl = screen.getByText('Content') | ||
expect(contentEl).toBeInTheDocument() | ||
expect(contentEl).toHaveClass('px-50') | ||
}) | ||
}) | ||
describe("<ActionSheet.Content/>", () => { | ||
it("should render correctly with className and children", () => { | ||
render( | ||
<ActionSheet.Content className="px-50"> | ||
Content | ||
</ActionSheet.Content>, | ||
); | ||
const contentEl = screen.getByText("Content"); | ||
expect(contentEl).toBeInTheDocument(); | ||
expect(contentEl).toHaveClass("px-50"); | ||
}); | ||
}); |
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
23 changes: 23 additions & 0 deletions
23
lib/components/action-sheet/footer/__snapshots__/footer.test.tsx.snap
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<ActionSheet.Footer/> should render correctly with horizontal 1`] = ` | ||
<div | ||
aria-label="horizontal footer" | ||
class="quill-action-sheet--footer quill-action-sheet--footer__variant--horizontal" | ||
> | ||
<button> | ||
action | ||
</button> | ||
</div> | ||
`; | ||
|
||
exports[`<ActionSheet.Footer/> should render correctly with vertical 1`] = ` | ||
<div | ||
aria-label="vertical footer" | ||
class="quill-action-sheet--footer quill-action-sheet--footer__variant--vertical" | ||
> | ||
<button> | ||
action | ||
</button> | ||
</div> | ||
`; |
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,68 +1,76 @@ | ||
import { screen, render } from 'test-utils' | ||
import ActionSheet from '..' | ||
import userEvent from '@testing-library/user-event' | ||
import { FooterAlignment } from '../types' | ||
import { screen, render } from "@testing-library/react"; | ||
import ActionSheet from ".."; | ||
import userEvent from "@testing-library/user-event"; | ||
import { FooterAlignment } from "../types"; | ||
|
||
describe('<ActionSheet.Footer/>', () => { | ||
it('should not render footer if no action passed', () => { | ||
render(<ActionSheet.Footer aria-label="Footer" />) | ||
const footerEl = screen.queryByLabelText('Footer') | ||
expect(footerEl).not.toBeInTheDocument() | ||
}) | ||
it('should render correctly with className', () => { | ||
const onActionButton = jest.fn() | ||
render( | ||
<ActionSheet.Footer | ||
className="px-50" | ||
aria-label="Footer" | ||
primaryAction={{ content: 'Primary action', onAction: onActionButton }} | ||
/>, | ||
) | ||
const footerEl = screen.getByLabelText('Footer') | ||
expect(footerEl).toHaveClass('px-50') | ||
}) | ||
it('should render with primaryAction correctly', async () => { | ||
const onActionButton = jest.fn() | ||
render( | ||
<ActionSheet.Footer | ||
primaryAction={{ content: 'Primary action', onAction: onActionButton }} | ||
/>, | ||
) | ||
const primaryBtn = screen.getByRole('button', { name: 'Primary action' }) | ||
expect(primaryBtn).toBeInTheDocument() | ||
await userEvent.click(primaryBtn) | ||
expect(onActionButton).toHaveBeenCalled() | ||
}) | ||
it('should render secondaryAction correctly', async () => { | ||
const onSecondaryAction = jest.fn() | ||
render( | ||
<ActionSheet.Footer | ||
secondaryAction={{ | ||
content: 'Secondary action', | ||
onAction: onSecondaryAction, | ||
}} | ||
/>, | ||
) | ||
const secondaryBtn = screen.getByRole('button', { | ||
name: 'Secondary action', | ||
}) | ||
expect(secondaryBtn).toBeInTheDocument() | ||
await userEvent.click(secondaryBtn) | ||
expect(onSecondaryAction).toHaveBeenCalled() | ||
}) | ||
const alignments: FooterAlignment[] = ['vertical', 'horizontal'] | ||
describe("<ActionSheet.Footer/>", () => { | ||
it("should not render footer if no action passed", () => { | ||
render(<ActionSheet.Footer aria-label="Footer" />); | ||
const footerEl = screen.queryByLabelText("Footer"); | ||
expect(footerEl).not.toBeInTheDocument(); | ||
}); | ||
it("should render correctly with className", () => { | ||
const onActionButton = jest.fn(); | ||
render( | ||
<ActionSheet.Footer | ||
className="px-50" | ||
aria-label="Footer" | ||
primaryAction={{ | ||
content: "Primary action", | ||
onAction: onActionButton, | ||
}} | ||
/>, | ||
); | ||
const footerEl = screen.getByLabelText("Footer"); | ||
expect(footerEl).toHaveClass("px-50"); | ||
}); | ||
it("should render with primaryAction correctly", async () => { | ||
const onActionButton = jest.fn(); | ||
render( | ||
<ActionSheet.Footer | ||
primaryAction={{ | ||
content: "Primary action", | ||
onAction: onActionButton, | ||
}} | ||
/>, | ||
); | ||
const primaryBtn = screen.getByRole("button", { | ||
name: "Primary action", | ||
}); | ||
expect(primaryBtn).toBeInTheDocument(); | ||
await userEvent.click(primaryBtn); | ||
expect(onActionButton).toHaveBeenCalled(); | ||
}); | ||
it("should render secondaryAction correctly", async () => { | ||
const onSecondaryAction = jest.fn(); | ||
render( | ||
<ActionSheet.Footer | ||
secondaryAction={{ | ||
content: "Secondary action", | ||
onAction: onSecondaryAction, | ||
}} | ||
/>, | ||
); | ||
const secondaryBtn = screen.getByRole("button", { | ||
name: "Secondary action", | ||
}); | ||
expect(secondaryBtn).toBeInTheDocument(); | ||
await userEvent.click(secondaryBtn); | ||
expect(onSecondaryAction).toHaveBeenCalled(); | ||
}); | ||
const alignments: FooterAlignment[] = ["vertical", "horizontal"]; | ||
|
||
alignments.forEach((alignment) => { | ||
it(`should render correctly with ${alignment}`, () => { | ||
render( | ||
<ActionSheet.Footer | ||
alignment={alignment} | ||
aria-label={`${alignment} footer`} | ||
primaryAction={{ content: 'action', onAction: () => null }} | ||
/>, | ||
) | ||
const footer = screen.getByLabelText(`${alignment} footer`) | ||
expect(footer).toMatchSnapshot() | ||
}) | ||
}) | ||
}) | ||
alignments.forEach((alignment) => { | ||
it(`should render correctly with ${alignment}`, () => { | ||
render( | ||
<ActionSheet.Footer | ||
alignment={alignment} | ||
aria-label={`${alignment} footer`} | ||
primaryAction={{ content: "action", onAction: () => null }} | ||
/>, | ||
); | ||
const footer = screen.getByLabelText(`${alignment} footer`); | ||
expect(footer).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
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,10 +1,10 @@ | ||
import { screen, render } from 'test-utils' | ||
import ActionSheet from '..' | ||
import { screen, render } from "@testing-library/react"; | ||
import ActionSheet from ".."; | ||
|
||
describe('<ActionSheet.HandleBar/>', () => { | ||
it('should render correctly with props', () => { | ||
render(<ActionSheet.HandleBar aria-label="Handle Bar" />) | ||
const handleBarEl = screen.getByLabelText('Handle Bar') | ||
expect(handleBarEl).toBeInTheDocument() | ||
}) | ||
}) | ||
describe("<ActionSheet.HandleBar/>", () => { | ||
it("should render correctly with props", () => { | ||
render(<ActionSheet.HandleBar aria-label="Handle Bar" />); | ||
const handleBarEl = screen.getByLabelText("Handle Bar"); | ||
expect(handleBarEl).toBeInTheDocument(); | ||
}); | ||
}); |
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,11 +1,13 @@ | ||
import { render, screen } from 'test-utils' | ||
import ActionSheet from '..' | ||
import { render, screen } from "@testing-library/react"; | ||
import ActionSheet from ".."; | ||
|
||
describe('<ActionSheet.Header/>', () => { | ||
it('should render correctly with className and children', () => { | ||
render(<ActionSheet.Header className="px-50">Header</ActionSheet.Header>) | ||
const headerEl = screen.getByText('Header') | ||
expect(headerEl).toBeInTheDocument() | ||
expect(headerEl).toHaveClass('px-50') | ||
}) | ||
}) | ||
describe("<ActionSheet.Header/>", () => { | ||
it("should render correctly with className and children", () => { | ||
render( | ||
<ActionSheet.Header className="px-50">Header</ActionSheet.Header>, | ||
); | ||
const headerEl = screen.getByText("Header"); | ||
expect(headerEl).toBeInTheDocument(); | ||
expect(headerEl).toHaveClass("px-50"); | ||
}); | ||
}); |
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
Oops, something went wrong.