-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2325 from ofhope/error-modal-tests
test: add ErrorModal tests and story
- Loading branch information
Showing
3 changed files
with
94 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import ErrorModal from './ErrorModal'; | ||
|
||
export default { | ||
title: 'IDE/ErrorModal', | ||
component: ErrorModal, | ||
argTypes: { | ||
closeModal: { action: 'closed' } | ||
} | ||
}; | ||
|
||
export const ForceAuthenticationErrorModal = { | ||
args: { | ||
type: 'forceAuthentication' | ||
} | ||
}; | ||
export const StaleSessionErrorModal = { | ||
args: { | ||
type: 'staleSession' | ||
} | ||
}; | ||
export const StaleProjectErrorModal = { | ||
args: { | ||
type: 'staleProject' | ||
} | ||
}; | ||
export const OauthErrorModal = { | ||
args: { | ||
type: 'oauthError' | ||
} | ||
}; |
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,57 @@ | ||
import React from 'react'; | ||
|
||
import { render, screen } from '../../../test-utils'; | ||
|
||
import ErrorModal from './ErrorModal'; | ||
|
||
jest.mock('../../../i18n'); | ||
|
||
describe('<ErrorModal />', () => { | ||
it('renders type forceAuthentication', () => { | ||
render(<ErrorModal type="forceAuthentication" closeModal={jest.fn()} />); | ||
|
||
expect(screen.getByText('Login')).toBeVisible(); | ||
expect(screen.getByText('Sign Up')).toBeVisible(); | ||
}); | ||
|
||
it('renders type staleSession', () => { | ||
render(<ErrorModal type="staleSession" closeModal={jest.fn()} />); | ||
|
||
expect(screen.getByText('log in')).toBeVisible(); | ||
}); | ||
|
||
it('renders type staleProject', () => { | ||
render(<ErrorModal type="staleProject" closeModal={jest.fn()} />); | ||
|
||
expect( | ||
screen.getByText( | ||
'The project you have attempted to save has been saved from another window', | ||
{ exact: false } | ||
) | ||
).toBeVisible(); | ||
}); | ||
|
||
it('renders type oauthError with service google', () => { | ||
render( | ||
<ErrorModal type="oauthError" service="google" closeModal={jest.fn()} /> | ||
); | ||
|
||
expect( | ||
screen.getByText('There was a problem linking your Google account', { | ||
exact: false | ||
}) | ||
).toBeVisible(); | ||
}); | ||
|
||
it('renders type oauthError with service github', () => { | ||
render( | ||
<ErrorModal type="oauthError" service="github" closeModal={jest.fn()} /> | ||
); | ||
|
||
expect( | ||
screen.getByText('There was a problem linking your GitHub account', { | ||
exact: false | ||
}) | ||
).toBeVisible(); | ||
}); | ||
}); |