Skip to content

Commit ef4eba2

Browse files
committed
Resolving travis error [2]
1 parent 2a95758 commit ef4eba2

File tree

11 files changed

+112
-59
lines changed

11 files changed

+112
-59
lines changed

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ script:
1212
- npm test
1313
after_success:
1414
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
15+
git:
16+
depth: 25
17+
quiet: true

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"moxios": "^0.4.0",
5959
"node-sass": "^4.14.1",
6060
"prop-types": "^15.7.2",
61-
"query-string": "^6.13.0",
61+
"query-string": "^6.13.1",
6262
"react": "^16.13.1",
6363
"react-dom": "^16.13.1",
6464
"react-redux": "^7.2.0",

src/components/home.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import M from 'materialize-css'; // Materialize JS ~ https://www.youtube.com/watch?v=EboLM8OjlP4
3+
4+
export default class Home extends React.Component {
5+
componentDidMount() {
6+
M.AutoInit();
7+
}
8+
9+
render() {
10+
return (
11+
<div>
12+
<div className='row'>
13+
<h1>BareFoot Nomad Welcomes You!!</h1>
14+
<a className='waves-effect waves-light btn' href='/login'>
15+
Login
16+
</a>
17+
<a className='waves-effect waves-light btn' href='/signup'>
18+
Signup
19+
</a>
20+
</div>
21+
</div>
22+
);
23+
}
24+
}

src/components/resetpassword.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,7 @@ export class resetpassword extends Component {
6969
className="btn waves-effect waves-light btn-send"
7070
onClick={this.handleResetPasswordEvent}
7171
>
72-
{this.state.isResetInProgress ? (
73-
<SyncLoader
74-
size={5}
75-
margin={5}
76-
color={"#fff"}
77-
loading={this.state.isResetInProgress}
78-
/>
79-
) : (
80-
"Reset password"
81-
)}
72+
Reset password
8273
</button>
8374
</div>
8475
</div>
+28-19
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
1-
import {RESET_ACTION,SEND_RESET_EMAIL_ACTION,SEND_RESET_EMAIL_IN_PROGRESS,RESET_IN_PROGRESS} from './actionTypes';
2-
import axios from 'axios';
3-
const sendResetEmailAPILink='https://warriorz-staging.herokuapp.com/api/v1/password/forgot';
4-
const resetPasswordAPILink="https://warriorz-staging.herokuapp.com/api/v1/password/reset";
5-
let resetResponse,sendResetResponse;
1+
import {
2+
RESET_ACTION,
3+
SEND_RESET_EMAIL_ACTION,
4+
SEND_RESET_EMAIL_IN_PROGRESS,
5+
RESET_IN_PROGRESS,
6+
} from "./actionTypes";
7+
import axios from "axios";
8+
const sendResetEmailAPILink = 'https://warriorz-staging.herokuapp.com/api/v1/password/forgot';
9+
const resetPasswordAPILink = 'https://warriorz-staging.herokuapp.com/api/v1/password/reset';
10+
let resetResponse, sendResetResponse;
611

12+
export const resetPassword = (password, token) => async (dispatch) => {
13+
resetResponse = await axios.patch(`${resetPasswordAPILink}/${token}`, {
14+
password,
15+
});
16+
dispatch({
17+
type: RESET_ACTION,
18+
payload: resetResponse.data.status === 200 ? true : false,
19+
});
20+
};
721

8-
export const resetPassword=(password,token)=> async (dispatch)=>{
9-
10-
resetResponse=await axios.patch(`${resetPasswordAPILink}/${token}`,{password});
11-
dispatch({'type':RESET_ACTION,payload:resetResponse.data.status===200?true:false})
12-
13-
14-
}
15-
16-
17-
export const sendResetEmail=(emailInput)=> async (dispatch)=>{
18-
sendResetResponse=await axios.post(sendResetEmailAPILink,{email:emailInput});
19-
dispatch({'type':SEND_RESET_EMAIL_ACTION,payload:sendResetResponse.data.status===200?true:false})
20-
21-
}
22+
export const sendResetEmail = (emailInput) => async (dispatch) => {
23+
sendResetResponse = await axios.post(sendResetEmailAPILink, {
24+
email: emailInput,
25+
});
26+
dispatch({
27+
type: SEND_RESET_EMAIL_ACTION,
28+
payload: sendResetResponse.data.status === 200 ? true : false,
29+
});
30+
};

src/routes/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { BrowserRouter, Switch, Route } from 'react-router-dom';
3-
import Home from '../components/Home';
3+
import Home from '../components/home';
44
import Dashboard from '../components/dashboard';
55
import Login from '../components/login';
66
import Signup from '../components/signup';

src/tests/components/home.test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from 'react';
2-
import { mount } from 'enzyme';
3-
import { Provider } from 'react-redux';
4-
import Home from '../../components/home';
5-
import configureStore from '../../redux/configureStore';
1+
import React from "react";
2+
import { mount } from "enzyme";
3+
import { Provider } from "react-redux";
4+
import Home from "../../components/home";
5+
import configureStore from "../../redux/configureStore";
66

7-
describe('*************** Testing the Home component ***************',()=>{
8-
const store = configureStore();
7+
describe("*************** Testing the Home component ***************", () => {
8+
const store = configureStore();
99

1010
it('Should render the Home page correctly', ()=>{
1111
const wrapper = mount(

src/tests/redux/actions/resetpassword.test.js

+27-5
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,49 @@ describe("Send reset ", () => {
1818
moxios.uninstall();
1919
store.clearActions();
2020
});
21-
21+
//resetResponse.data.status
2222
test("Should send reset email action", async () => {
2323
moxios.wait(() => {
2424
const request = moxios.requests.mostRecent();
25-
request.respondWith({ status:200,
26-
response:{message:"Sent successfully"}});
25+
request.respondWith({ response:{status:200,message:"Sent successfully"}});
2726
});
2827
return store.dispatch(sendResetEmail("[email protected]")).then(()=>{
2928
expect(store.getActions().length).toEqual(1);
29+
expect(store.getActions()[0].payload).toEqual(true);
3030
})
3131
});
3232

3333

3434
test("Should reset password action", async () => {
3535
moxios.wait(() => {
3636
const request = moxios.requests.mostRecent();
37-
request.respondWith({ status:200,
38-
response:{message:"Password changed successfully!"}});
37+
request.respondWith({response:{status:200,message:"Password changed successfully!"}});
38+
});
39+
return store.dispatch(resetPassword("dann123",token)).then(()=>{
40+
expect(store.getActions().length).toEqual(1);
41+
expect(store.getActions()[0].payload).toEqual(true);
42+
})
43+
});
44+
45+
test("Should not reset password (wrong response)", async () => {
46+
moxios.wait(() => {
47+
const request = moxios.requests.mostRecent();
48+
request.respondWith({response:{status:400,message:"Password not changed !"}});
3949
});
4050
return store.dispatch(resetPassword("dann123",token)).then(()=>{
4151
expect(store.getActions().length).toEqual(1);
52+
expect(store.getActions()[0].payload).toEqual(false);
53+
})
54+
});
55+
56+
test("Should not send link (wrong response)", async () => {
57+
moxios.wait(() => {
58+
const request = moxios.requests.mostRecent();
59+
request.respondWith({response:{status:400,message:"Password not changed !"}});
60+
});
61+
return store.dispatch(sendResetEmail("[email protected]")).then(()=>{
62+
expect(store.getActions().length).toEqual(1);
63+
expect(store.getActions()[0].payload).toEqual(false);
4264
})
4365
});
4466

src/tests/routes.test.js

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import React from 'react';
2-
import { MemoryRouter } from 'react-router-dom';
3-
import { mount } from 'enzyme';
4-
import App from '../App';
1+
import React from "react";
2+
import { MemoryRouter } from "react-router-dom";
3+
import { shallow } from "enzyme";
4+
import App from "../App";
5+
import { Provider } from "react-redux";
6+
import configureStore from "../redux/configureStore";
7+
const store = configureStore();
58

6-
describe('app component', () => {
7-
test('it should render the Home component', () => {
8-
const component = mount(
9-
<MemoryRouter initialEntries={['/']}>
10-
{ App }
11-
</MemoryRouter>
12-
);
13-
expect(component).toHaveLength(1);
14-
});
9+
describe("app component", () => {
10+
test("it should render the Home component", () => {
11+
const component = shallow(
12+
<Provider store={store}>
13+
<App />
14+
</Provider>
15+
);
16+
expect(component).toHaveLength(1);
17+
});
1518
});

webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ module.exports = (env) => {
9090
new webpack.DefinePlugin({
9191
'process.env': {
9292
'API_BASE_URL': JSON.stringify(process.env.API_BASE_URL),
93+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
9394
}
9495
}),
9596
]

0 commit comments

Comments
 (0)