generated from UnBArqDsw2021-1/RepositorioTemplate
-
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.
Co-authored-by: Sergio Cipriano <sergiosacj@protonmail.com>
- Loading branch information
1 parent
687d4f1
commit 3da09c9
Showing
5 changed files
with
228 additions
and
169 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
SKIP_PREFLIGHT_CHECK=true |
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
66 changes: 66 additions & 0 deletions
66
frontend/src/__tests__/components/Modal/LoginModal/LoginModal.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,66 @@ | ||
import React from 'react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import '@testing-library/jest-dom'; | ||
import LoginModal from '../../../../components/Modal/LoginModal/index'; | ||
|
||
describe('LoginModal', () => { | ||
it('renders nothing when not visible', () => { | ||
const props = { | ||
title: 'Some content', | ||
visible: false, | ||
onClose: () => { | ||
return; | ||
}, | ||
}; | ||
render(<LoginModal {...props} />); | ||
|
||
expect(screen.queryByText('Some content')).not.toBeVisible(); | ||
}); | ||
|
||
it('renders content when visible', () => { | ||
const props = { | ||
title: 'Some content', | ||
visible: true, | ||
onClose: () => { | ||
return; | ||
}, | ||
}; | ||
render(<LoginModal {...props} />); | ||
|
||
expect(screen.getByText('Some content')).toBeVisible(); | ||
}); | ||
|
||
it('fires onClosed when clicking the button', () => { | ||
const onCloseHandler = jest.fn(); | ||
const props = { | ||
title: 'Some content', | ||
visible: true, | ||
onClose: onCloseHandler, | ||
}; | ||
render(<LoginModal {...props} />); | ||
|
||
const button = screen.getByRole('button'); | ||
fireEvent.click(button); | ||
|
||
expect(onCloseHandler).toHaveBeenCalled(); | ||
}); | ||
|
||
it('fires onClosed when pressing esc', () => { | ||
const onCloseHandler = jest.fn(); | ||
const props = { | ||
title: 'Some content', | ||
visible: true, | ||
onClose: onCloseHandler, | ||
}; | ||
render(<LoginModal {...props} />); | ||
|
||
fireEvent.keyDown(document.body, { | ||
key: 'Escape', | ||
keyCode: 27, | ||
which: 27, | ||
}); | ||
|
||
expect(onCloseHandler).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
Oops, something went wrong.