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
import { Auth } from 'aws-amplify'; | |
import GetJwtToken from './GetJwtToken'; | |
describe('jwt', () => { | |
describe('GetJwtToken', () => { | |
it('Original mock for Auth class', async () => { | |
const result: Error = (await GetJwtToken()) as Error; | |
expect(result.message).toBe('Could not get session'); | |
}); |
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
it('Error label should contain `No userPool`', async () => { | |
const wrapper = TestRenderer.create(<CognitoLogin />); | |
const child = wrapper.root.findByProps({ iconName: 'sign-in' }); | |
await child.props.onPress(); | |
const errorLabel = wrapper.root.findByProps({ isCaption: true }); | |
expect(errorLabel.props.children).toBe('No userPool'); | |
}); |
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
it('`onEmailChanged` should update state', () => { | |
const wrapper = TestRenderer.create(<CognitoLogin />); | |
const expectedEmail = '[email protected]'; | |
wrapper.root.instance.onEmailChanged(expectedEmail); | |
expect(wrapper.root.instance.state.userInput.email).toBe(expectedEmail); | |
}); |
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
export class CognitoLogin extends React.Component< | |
ICognitoLoginProps, | |
ICognitoLoginState | |
> { | |
constructor(props: ICognitoLoginProps) { | |
super(props); | |
this.state = { | |
userInput: __DEV__ | |
? { | |
email: '[email protected]', |
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
import React from 'react'; | |
import TestRenderer from 'react-test-renderer'; | |
import CognitoLogin from './CognitoLogin'; | |
import _ from 'lodash'; | |
it('When no `code` or `email` `onSavePress` should set `message` to `Need code and user e-mail`', async (done) => { | |
// Arrange | |
const wrapper = TestRenderer.create(<CognitoLogin />); | |
const child = wrapper.root.findByProps({ | |
testID: 'ForgotForm', |
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
it('On forgot password should not throw', () => { | |
const wrapper = TestRenderer.create(<CognitoLogin />); | |
const child = wrapper.root.findByProps({ | |
testID: 'ForgotForm', | |
}); | |
expect(child).toBeDefined(); | |
}); |
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
const wrapper = TestRenderer.create(<CognitoLogin />); | |
const state: ICognitoLoginState = { | |
formState: 'Register', | |
code: 'testcode', | |
userInput: { email: '[email protected]', password: 'testPw' }, | |
result: undefined, | |
}; | |
wrapper.root.instance.setState(state); |
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
echo Upload code coverage | |
echo Token: "$(CODECOV_TOKEN)" | |
codecov -t "$(CODECOV_TOKEN)" |
NewerOlder