This repository was archived by the owner on Feb 19, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 166
test: fix old tests, add react scripts #214
Merged
MildTomato
merged 8 commits into
supabase:develop
from
YashKandalkar:test/fix-old-tests-add-react-scripts
Jun 24, 2021
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8911185
test: fixed old tests, add react-scripts package for running tests
YashKandalkar e9aa007
chore: merge conflics resolved
YashKandalkar 30e603f
test: add tests for Alert component
YashKandalkar 6ac8e98
fix: fixed typing errors
YashKandalkar 3ab2185
chore: resolved requested changes
YashKandalkar 4c15a0a
chore: mer conflicts, typescript error in InputNumber
YashKandalkar 4da517e
chore: remove webpack
MildTomato 3183607
Merge branch 'test/add-alert-tests' into test/fix-old-tests-add-react…
YashKandalkar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 +1,6 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"printWidth": 80 | ||
"printWidth": 80, | ||
"endOfLine": "auto" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,67 @@ | ||
import { fireEvent, render, screen } from '@testing-library/react' | ||
import Alert from './Alert' | ||
|
||
const VARIANTS = ['success', 'danger', 'warning', 'info'] | ||
|
||
describe('#Alert', () => { | ||
it('should render elements correctly', () => { | ||
render(<Alert title="Required Title">{'Description'}</Alert>) | ||
expect(screen.queryByText('Required Title')).toBeInTheDocument() | ||
expect(screen.queryByText('Description')).toBeInTheDocument() | ||
}) | ||
|
||
it('should add custom classes to container div', () => { | ||
const { container } = render( | ||
<Alert title="Required Title" className={'custom classes'}> | ||
{'Description'} | ||
</Alert> | ||
) | ||
expect(container.querySelector('div')).toHaveClass( | ||
`sbui-alert-container sbui-alert-container--success custom classes` | ||
) | ||
}) | ||
|
||
it('should close alert when close button clicked', () => { | ||
render( | ||
<Alert title="Required Title" closable> | ||
{'Description'} | ||
</Alert> | ||
) | ||
|
||
const closeButton = screen.getByRole('button') | ||
|
||
fireEvent.click(closeButton) | ||
|
||
expect(screen.queryByText('Description')).not.toBeInTheDocument() | ||
}) | ||
|
||
it('should render an icon when passed withIcon', () => { | ||
const { container } = render( | ||
<Alert title="Required Title" withIcon> | ||
{'Description'} | ||
</Alert> | ||
) | ||
|
||
expect( | ||
container.querySelector('div.flex-shrink-0 > svg') | ||
).toBeInTheDocument() | ||
}) | ||
|
||
it.each(VARIANTS)( | ||
'should have "sbui-alert-[container|description]--%s" class', | ||
(variant) => { | ||
const { container } = render( | ||
<Alert title="Required Title" variant={variant}> | ||
{'Description'} | ||
</Alert> | ||
) | ||
|
||
expect(container.querySelector('div')).toHaveClass( | ||
`sbui-alert-container sbui-alert-container--${variant}` | ||
) | ||
expect(screen.queryByText('Description')).toHaveClass( | ||
`sbui-alert-description sbui-alert-description--${variant}` | ||
) | ||
} | ||
) | ||
}) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.