-
Notifications
You must be signed in to change notification settings - Fork 0
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
0bf14f3
commit 35f5636
Showing
18 changed files
with
647 additions
and
13 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 |
---|---|---|
|
@@ -23,9 +23,9 @@ jobs: | |
node-version: '20.x' | ||
- name: Install dependencies | ||
run: npm install | ||
- uses: bitovi/[email protected].1 | ||
- uses: bitovi/[email protected].3 | ||
with: | ||
path: storybook-static | ||
checkout: false | ||
env: | ||
GH_TOKEN: ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} | ||
env: | ||
GH_TOKEN: ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { render } from '@testing-library/react' | ||
import ColorPicker from './ColorPicker' | ||
|
||
describe('<ColorPicker>', () => { | ||
it('renders without crashing', () => { | ||
const { container, asFragment } = render(<ColorPicker />) | ||
expect(container).toBeInTheDocument() | ||
|
||
expect(asFragment()).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
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
49 changes: 49 additions & 0 deletions
49
src/components/Atomic/ColorPicker/__snapshots__/ColorPicker.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,49 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<ColorPicker> renders without crashing 1`] = ` | ||
<DocumentFragment> | ||
.emotion-0 { | ||
display: -webkit-inline-box; | ||
display: -webkit-inline-flex; | ||
display: -ms-inline-flexbox; | ||
display: inline-flex; | ||
-webkit-align-items: center; | ||
-webkit-box-align: center; | ||
-ms-flex-align: center; | ||
align-items: center; | ||
padding: 4px; | ||
border-radius: 8px; | ||
cursor: pointer; | ||
border: 1px solid; | ||
width: 115px; | ||
} | ||
.emotion-1 { | ||
width: 40px; | ||
height: 16px; | ||
border-radius: 8px; | ||
} | ||
.emotion-2 { | ||
font-size: 12px; | ||
display: block; | ||
padding: 0 8px; | ||
} | ||
<div> | ||
<div | ||
class="emotion-0" | ||
> | ||
<div | ||
class="emotion-1" | ||
style="background: rgb(34, 97, 174);" | ||
/> | ||
<span | ||
class="emotion-2" | ||
> | ||
#2261ae | ||
</span> | ||
</div> | ||
</div> | ||
</DocumentFragment> | ||
`; |
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
79 changes: 79 additions & 0 deletions
79
src/components/Atomic/ConfirmButton/ConfirmButton.test.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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { render, fireEvent, waitFor } from '@testing-library/react' | ||
import ConfirmButton from './ConfirmButton' | ||
|
||
describe('<ConfirmButton>', () => { | ||
it('renders without crashing', () => { | ||
const { container, asFragment } = render( | ||
<ConfirmButton body={<div>body</div>} cancelButtonText='Cancel' confirmButtonText='Confirm' onConfirm={() => {}} title='Title'> | ||
Action | ||
</ConfirmButton> | ||
) | ||
expect(container).toBeInTheDocument() | ||
|
||
expect(asFragment()).toMatchSnapshot() | ||
}) | ||
|
||
it('opens ConfirmModal when clicked', () => { | ||
const { getByRole, queryByRole } = render( | ||
<ConfirmButton body={<div>body</div>} cancelButtonText='Cancel' confirmButtonText='Confirm' onConfirm={() => {}} title='Title'> | ||
Action | ||
</ConfirmButton> | ||
) | ||
const button = getByRole('button') | ||
fireEvent.click(button) | ||
const modal = queryByRole('dialog') | ||
expect(modal).toBeInTheDocument() | ||
}) | ||
|
||
it('calls onConfirm when confirm button in modal is clicked', () => { | ||
const mockOnConfirm = jest.fn() | ||
const { getByRole, getByText } = render( | ||
<ConfirmButton body={<div>body</div>} cancelButtonText='Cancel' confirmButtonText='Confirm' onConfirm={mockOnConfirm} title='Title'> | ||
Action | ||
</ConfirmButton> | ||
) | ||
const button = getByRole('button') | ||
fireEvent.click(button) | ||
const confirmButton = getByText('Confirm') | ||
fireEvent.click(confirmButton) | ||
expect(mockOnConfirm).toHaveBeenCalled() | ||
}) | ||
|
||
it('closes ConfirmModal when closeOnConfirm is true', async () => { | ||
const { getByRole, queryByRole } = render( | ||
<ConfirmButton closeOnConfirm body={<div>body</div>} cancelButtonText='Cancel' confirmButtonText='Confirm' onConfirm={() => {}} title='Title'> | ||
Action | ||
</ConfirmButton> | ||
) | ||
const button = getByRole('button') | ||
fireEvent.click(button) | ||
const confirmButton = getByRole('button', { name: /Confirm/i }) | ||
fireEvent.click(confirmButton) | ||
const modal = queryByRole('dialog') | ||
|
||
await waitFor(() => { | ||
expect(modal).not.toBeInTheDocument() | ||
}) | ||
}) | ||
|
||
it('does not close ConfirmModal when closeOnConfirm is false', () => { | ||
const { getByRole, queryByRole } = render( | ||
<ConfirmButton | ||
body={<div>body</div>} | ||
cancelButtonText='Cancel' | ||
closeOnConfirm={false} | ||
confirmButtonText='Confirm' | ||
onConfirm={() => {}} | ||
title='Title' | ||
> | ||
Action | ||
</ConfirmButton> | ||
) | ||
const button = getByRole('button') | ||
fireEvent.click(button) | ||
const confirmButton = getByRole('button', { name: /Confirm/i }) | ||
fireEvent.click(confirmButton) | ||
const modal = queryByRole('dialog') | ||
expect(modal).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
43 changes: 43 additions & 0 deletions
43
src/components/Atomic/ConfirmButton/__snapshots__/ConfirmButton.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,43 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<ConfirmButton> renders without crashing 1`] = ` | ||
<DocumentFragment> | ||
.emotion-0 { | ||
display: -webkit-inline-box; | ||
display: -webkit-inline-flex; | ||
display: -ms-inline-flexbox; | ||
display: inline-flex; | ||
-webkit-align-items: center; | ||
-webkit-box-align: center; | ||
-ms-flex-align: center; | ||
align-items: center; | ||
-webkit-box-pack: center; | ||
-ms-flex-pack: center; | ||
-webkit-justify-content: center; | ||
justify-content: center; | ||
-webkit-transition: all 0.25s; | ||
transition: all 0.25s; | ||
font-family: 'Poppins',sans-serif; | ||
font-style: normal; | ||
font-weight: 600; | ||
text-align: center; | ||
border-radius: 8px; | ||
white-space: nowrap; | ||
box-sizing: border-box; | ||
cursor: pointer; | ||
border: 1px solid; | ||
padding: 10px 24px; | ||
font-size: 14px; | ||
line-height: 16px; | ||
height: 48px; | ||
} | ||
<button | ||
class="emotion-0" | ||
tabindex="1" | ||
type="submit" | ||
> | ||
Action | ||
</button> | ||
</DocumentFragment> | ||
`; |
110 changes: 110 additions & 0 deletions
110
src/components/Atomic/ConfirmModal/ConfirmModal.test.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 |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import React from 'react' | ||
import { render, fireEvent } from '@testing-library/react' | ||
import ConfirmModal from './ConfirmModal' | ||
|
||
describe('<ConfirmModal>', () => { | ||
it('renders without crashing', () => { | ||
const { getByText, asFragment } = render( | ||
<ConfirmModal | ||
body={<div>ConfirmModal</div>} | ||
cancelButtonText='Cancel' | ||
confirmButtonText='Confirm' | ||
onClose={() => {}} | ||
onConfirm={() => {}} | ||
show={true} | ||
title='Title' | ||
/> | ||
) | ||
expect(getByText('ConfirmModal')).toBeInTheDocument() | ||
|
||
expect(asFragment()).toMatchSnapshot() | ||
}) | ||
|
||
it('calls onClose when cancel button is clicked', () => { | ||
const onClose = jest.fn() | ||
const { getByText } = render( | ||
<ConfirmModal | ||
body={<div>Body</div>} | ||
cancelButtonText='Cancel' | ||
confirmButtonText='Confirm' | ||
onClose={onClose} | ||
onConfirm={() => {}} | ||
show={true} | ||
title='Title' | ||
/> | ||
) | ||
fireEvent.click(getByText('Cancel')) | ||
expect(onClose).toHaveBeenCalled() | ||
}) | ||
|
||
it('calls onConfirm when confirm button is clicked', () => { | ||
const onConfirm = jest.fn() | ||
const { getByText } = render( | ||
<ConfirmModal | ||
body={<div>Body</div>} | ||
cancelButtonText='Cancel' | ||
confirmButtonText='Confirm' | ||
onClose={() => {}} | ||
onConfirm={onConfirm} | ||
show={true} | ||
title='Title' | ||
/> | ||
) | ||
fireEvent.click(getByText('Confirm')) | ||
expect(onConfirm).toHaveBeenCalled() | ||
}) | ||
|
||
it('does not call onClose when loading', () => { | ||
const onClose = jest.fn() | ||
const { getByText } = render( | ||
<ConfirmModal | ||
body={<div>Body</div>} | ||
cancelButtonText='Cancel' | ||
confirmButtonText='Confirm' | ||
loading={true} | ||
onClose={onClose} | ||
onConfirm={() => {}} | ||
show={true} | ||
title='Title' | ||
/> | ||
) | ||
fireEvent.click(getByText('Cancel')) | ||
expect(onClose).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('does not call onConfirm when loading', () => { | ||
const onConfirm = jest.fn() | ||
const { getByText } = render( | ||
<ConfirmModal | ||
body={<div>Body</div>} | ||
cancelButtonText='Cancel' | ||
confirmButtonText='Confirm' | ||
loading={true} | ||
onClose={() => {}} | ||
onConfirm={onConfirm} | ||
show={true} | ||
title='Title' | ||
/> | ||
) | ||
fireEvent.click(getByText('Confirm')) | ||
expect(onConfirm).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('does not call onConfirm when confirmDisabled', () => { | ||
const onConfirm = jest.fn() | ||
const { getByText } = render( | ||
<ConfirmModal | ||
body={<div>Body</div>} | ||
cancelButtonText='Cancel' | ||
confirmButtonText='Confirm' | ||
confirmDisabled={true} | ||
onClose={() => {}} | ||
onConfirm={onConfirm} | ||
show={true} | ||
title='Title' | ||
/> | ||
) | ||
fireEvent.click(getByText('Confirm')) | ||
expect(onConfirm).not.toHaveBeenCalled() | ||
}) | ||
}) |
Oops, something went wrong.