-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- user should be able to login - user should receive appropriate error message [Finishes #171380695]
- Loading branch information
1 parent
8c78fbd
commit 14e3e20
Showing
35 changed files
with
13,578 additions
and
40 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 |
---|---|---|
|
@@ -20,3 +20,9 @@ yarn-error.log | |
|
||
#test coverage | ||
coverage | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ install: | |
- yarn | ||
|
||
script: | ||
- yarn test | ||
- yarn test --updateSnapshot | ||
|
||
notification: | ||
- email: false | ||
|
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,2 @@ | ||
[0609/102203.692:ERROR:process_info.cc(98)] ReadProcessMemory UNICODE_STRING: Only part of a ReadProcessMemory or WriteProcessMemory request was completed. (0x12B) | ||
[0609/102204.114:ERROR:process_info.cc(551)] ReadProcessData failed |
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
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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
/* eslint-disable no-undef */ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import { BrowserRouter as Router } from 'react-router-dom'; | ||
import { cleanup } from '@testing-library/react'; | ||
import NavBar from '../views/NavBar/NavBar'; | ||
|
||
describe('<NavBar/>', () => { | ||
afterEach(cleanup); | ||
it('Should match the NavBar component snapshot', () => { | ||
const tree = renderer.create(<NavBar />).toJSON(); | ||
const tree = renderer.create(<Router><NavBar /></Router>).toJSON(); | ||
expect(tree).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
14 changes: 14 additions & 0 deletions
14
src/__tests__/action/__snapshots__/loginAction.test.js.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,14 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`login actions Dispatches the correct action and payload 1`] = `Array []`; | ||
|
||
exports[`login actions Dispatches the correct action and payload of wrong email 1`] = ` | ||
Array [ | ||
Object { | ||
"payload": Object { | ||
"error": "Invalid email", | ||
}, | ||
"type": "LOGIN_HANDLE", | ||
}, | ||
] | ||
`; |
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,31 @@ | ||
/* eslint-disable no-undef */ | ||
import 'regenerator-runtime/runtime'; | ||
import configureStore from 'redux-mock-store'; | ||
import thunk from 'redux-thunk'; | ||
import handleLogin from '../../redux/login/loginActions'; | ||
|
||
const mockStore = configureStore([thunk]); | ||
const store = mockStore(); | ||
|
||
global.fetch = jest.fn(() => Promise.resolve({ | ||
json: () => Promise.resolve({}), | ||
})); | ||
describe('login actions', () => { | ||
beforeEach(() => { | ||
store.clearActions(); | ||
}); | ||
test('Dispatches the correct action and payload', () => { | ||
store.dispatch(handleLogin({ | ||
email: '[email protected]', | ||
password: 'Diny@2020', | ||
})); | ||
expect(store.getActions()).toMatchSnapshot(); | ||
}); | ||
test('Dispatches the correct action and payload of wrong email', () => { | ||
store.dispatch(handleLogin({ | ||
email: 'din', | ||
password: 'Diny@2020', | ||
})); | ||
expect(store.getActions()).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* eslint-disable no-undef */ | ||
import { mount } from 'enzyme'; | ||
import React from 'react'; | ||
import 'regenerator-runtime/runtime'; | ||
import { Provider } from 'react-redux'; | ||
import configureStore from 'redux-mock-store'; | ||
import TextField from '@material-ui/core/TextField'; | ||
import Login, { | ||
mapDispatchToProps, | ||
mapStateToProps, | ||
} from '../../components/forms/UserLogin'; | ||
import InputField from '../../components/forms/InputField'; | ||
import Lines from '../../components/forms/Lines'; | ||
import Links from '../../components/forms/Link'; | ||
import SubmitButton from '../../components/forms/SubmitButton'; | ||
import SocialLogin from '../../components/forms/SocialLogin'; | ||
|
||
const defaultProps = { | ||
errors: '', | ||
success: false, | ||
token: '', | ||
}; | ||
const mockStore = configureStore([]); | ||
const store = mockStore({ | ||
message: 'Welcome', | ||
errors: '', | ||
success: false, | ||
token: '', | ||
}); | ||
store.dispatch = jest.fn(); | ||
|
||
describe('App tests', () => { | ||
it('rendering the user login component', () => { | ||
const submit = jest.fn(); | ||
const change = jest.fn(); | ||
const chi = 'forget Password?'; | ||
const login = mount(<Provider store={store}><Login /></Provider>); | ||
expect(login.contains( | ||
<InputField name="email" handleLoginChange={change} />, | ||
<SubmitButton submitForm={submit}>Login</SubmitButton>, | ||
<Links>{chi}</Links>, | ||
<Lines />, | ||
<SocialLogin />, | ||
)); | ||
}); | ||
it('login', () => { | ||
const event = { | ||
preventDefault() {}, | ||
target: { value: '[email protected]' }, | ||
}; | ||
const dispatch = jest.fn(); | ||
mapDispatchToProps(dispatch).login(); | ||
mapStateToProps({ defaultProps }); | ||
const wrapper = mount(<Provider store={store}><Login /></Provider>); | ||
|
||
wrapper | ||
.find(TextField) | ||
.at(0) | ||
.simulate('change', event); | ||
wrapper | ||
.find(TextField) | ||
.at(1) | ||
.simulate('change', { target: { value: 'Example@2020' } }); | ||
wrapper | ||
.find(SubmitButton) | ||
.simulate('click'); | ||
expect(dispatch).toBeCalledTimes(1); | ||
}); | ||
}); |
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,26 @@ | ||
/* eslint-disable no-undef */ | ||
import 'regenerator-runtime/runtime'; | ||
import userLogin from '../../helpers/userLogin'; | ||
|
||
describe('login helpers', () => { | ||
it('login functionality success', async () => { | ||
const credentials = { | ||
email: '[email protected]', | ||
password: 'TravelAdmin2@', | ||
}; | ||
global.fetch = jest.fn(() => Promise.resolve({ | ||
json: () => Promise.resolve({}), | ||
})); | ||
await userLogin(credentials); | ||
expect(fetch).toHaveBeenCalledTimes(1); | ||
}); | ||
it('login functionality fail', async () => { | ||
const credentials = { | ||
email: 'travel', | ||
password: 'Travel', | ||
}; | ||
global.fetch = jest.fn(() => Promise.reject()); | ||
await userLogin(credentials); | ||
expect(fetch).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
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,18 @@ | ||
/* eslint-disable no-undef */ | ||
import 'regenerator-runtime/runtime'; | ||
import reducer, { initialState } from '../../redux/login/reducer'; | ||
import LOGIN_HANDLE from '../../redux/login/loginTypes'; | ||
|
||
|
||
describe('', () => { | ||
it('should return Redux when action is provided with value', () => { | ||
const payload = { | ||
error: 'invalid email', | ||
}; | ||
const expected = { | ||
...initialState, | ||
errors: payload.error, | ||
}; | ||
expect(reducer(undefined, { type: LOGIN_HANDLE, payload })).toEqual(expected); | ||
}); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,5 +1,24 @@ | ||
h1 { | ||
font-family: Arial, Helvetica, sans-serif; | ||
text-align: center; | ||
padding: 20px; | ||
font-size: larger; | ||
} | ||
body{ | ||
height: 100%; | ||
} | ||
.span { | ||
color: red; | ||
} | ||
.main{ | ||
width: 100% ; | ||
padding-top: 1.5%; | ||
box-sizing: border-box; | ||
background-image: url("../../HomePic.jpg"); | ||
height: 100%; | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
} | ||
.main h1{ | ||
color: white; | ||
} |
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,44 @@ | ||
import React from 'react'; | ||
import TextField from '@material-ui/core/TextField'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const useStyles = makeStyles({ | ||
textField: { | ||
marginBottom: '7%', | ||
marginTop: '1%', | ||
'& div': { | ||
borderRadius: 18, | ||
}, | ||
}, | ||
input: { | ||
color: 'black', | ||
backgroundColor: 'white', | ||
}, | ||
}); | ||
|
||
const InputField = ({ handleLoginChange, name }) => { | ||
const classes = useStyles(); | ||
return ( | ||
<TextField | ||
variant="outlined" | ||
required | ||
fullWidth | ||
id={name} | ||
label={name} | ||
name={name} | ||
type={name} | ||
className={classes.textField} | ||
InputProps={{ | ||
className: classes.input, | ||
}} | ||
size="small" | ||
onChange={handleLoginChange} | ||
/> | ||
); | ||
}; | ||
InputField.propTypes = { | ||
name: PropTypes.string.isRequired, | ||
handleLoginChange: PropTypes.func.isRequired, | ||
}; | ||
export default InputField; |
Oops, something went wrong.