Skip to content

Commit dda2720

Browse files
committed
rebased
2 parents 9ef35b3 + 48c8e33 commit dda2720

30 files changed

+2670
-1007
lines changed

__tests__/actions/LogoutAction.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ describe('logout actions', () => {
4242
const request = moxios.requests.mostRecent()
4343
request.reject({
4444
status: 400,
45-
response:{
46-
data:{message:"Network Error"}
47-
}
45+
message: 'Network Error'
4846
})
4947
})
5048

__tests__/actions/fetchAccommodation.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ describe('Fetch accommodations actions', () => {
4848

4949
moxios.wait(() => {
5050
const request = moxios.requests.mostRecent()
51-
request.respondWith({
51+
request.reject({
5252
status: 500,
5353
response: {
54-
Error: 'Internal Error'
54+
data: 'internal server error',
5555
}
56-
5756
})
5857
})
5958

__tests__/actions/fetchLocationAction.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ describe('Fetch Location actions', () => {
4949

5050
moxios.wait(() => {
5151
const request = moxios.requests.mostRecent()
52-
request.respondWith({
52+
request.reject({
5353
status: 500,
5454
response: {
55-
Error: "Internal server error"
56-
}
55+
data: 'internal server error',
56+
}
5757
})
5858
})
5959

__tests__/actions/signupAction.test.js

Lines changed: 34 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const middlewares = [thunk]
1313
const mockStore = configureStore(middlewares);
1414
let store=mockStore({});
1515
let mock = new MockAdapter(axios)
16+
const nextStep = jest.fn();
17+
1618
describe('Fetch Signup actions', () => {
1719

1820
beforeEach(() => {
@@ -22,11 +24,22 @@ describe('Fetch Signup actions', () => {
2224
afterEach(() => moxios.uninstall())
2325

2426
it('Creates REQUEST_ERROR after task is unsuccessful', () => {
25-
mock.onGet(`${URL}/user/signup`)
26-
.reply(400,{response:{ error: "\"username\" length must be at least 5 characters long"}})
27-
store.dispatch(actions.requestSignup()).then((res)=>{
28-
//const action=[{type:'FETCH_LOCATIONS_SUCCESS',payload:locationsPayload }]
29-
const expectedActions = store.getActions()
27+
28+
moxios.wait(() => {
29+
const request = moxios.requests.mostRecent()
30+
request.reject({
31+
status: 400,
32+
response: {
33+
data:{
34+
error: "\"username\" length must be at least 5 characters long",
35+
}
36+
}
37+
38+
})
39+
})
40+
41+
return store.dispatch(actions.requestSignup()).then(() => {
42+
const expectedActions = store.getActions();
3043
expect(expectedActions[0].type).toEqual('REQUEST_SIGNUP')
3144
expect(expectedActions[1].type).toEqual('REQUEST_ERROR')
3245
//expect(store.getActions().type).toEqual(action.type)
@@ -42,63 +55,28 @@ describe('Fetch Signup actions', () => {
4255
// })
4356
// })
4457

45-
// return store.dispatch(actions.requestSignup()).then(() => {
46-
// const expectedActions = store.getActions();
47-
// expect(expectedActions[0].type).toEqual('REQUEST_SIGNUP')
48-
// expect(expectedActions[1].type).toEqual('REQUEST_ERROR')
49-
// })
50-
},5000)
51-
5258
it('Creates REQUEST_SUCCESS after task is successful', () => {
53-
mock.onGet(`${URL}/user/signup`)
54-
.reply(200,{response:{ Message: "User M has been created. Check email for verification"}})
55-
store.dispatch(actions.requestSignup()).then((res)=>{
56-
const expectedActions = store.getActions()
57-
expect(expectedActions[0].type).toEqual('REQUEST_SIGNUP')
58-
expect(expectedActions[1].type).toEqual('REQUEST_SUCCESS')
59-
//expect(store.getActions().type).toEqual(action.type)
60-
})
61-
// moxios.wait(() => {
62-
// const request = moxios.requests.mostRecent()
63-
// request.respondWith({
64-
// status: 200,
65-
// response: {
66-
// Message: "User M has been created. Check email for verification"
67-
// }
68-
// })
69-
// })
59+
60+
moxios.wait(() => {
61+
const request = moxios.requests.mostRecent()
62+
request.respondWith({
63+
status: 200,
64+
response: {
65+
Message: "User M has been created. Check email for verification"
66+
}
67+
})
68+
})
7069

71-
// return store.dispatch(actions.requestSignup()).then(() => {
72-
// const expectedActions = store.getActions();
73-
// expect(expectedActions[0].type).toEqual('REQUEST_SIGNUP')
74-
// expect(expectedActions[1].type).toEqual('REQUEST_SUCCESS')
75-
// })
76-
},5000)
70+
return store.dispatch(actions.requestSignup(user, nextStep)).then(() => {
71+
const expectedActions = store.getActions();
72+
expect(expectedActions[0].type).toEqual('REQUEST_SIGNUP')
73+
expect(expectedActions[1].type).toEqual('REQUEST_SUCCESS')
74+
})
75+
})
7776
it('should dispatch the CLOSE_SNACKBAR action', () => {
7877
store.clearActions();
7978
store.dispatch(actions.closeSnackbar())
8079
expect(store.getActions()).toEqual([{"type": "CLOSE_SNACKBAR"}]);
8180
})
8281

8382
})
84-
describe('signupStore(creds)', () =>{
85-
const store = mockStore({});
86-
const mock = new MockAdapter(axios);
87-
beforeEach(()=>{
88-
store.clearActions();
89-
});
90-
91-
it('dispatches REQUEST_SIGNUP after signup success', () =>{
92-
mock.onPost(process.env.REACT_APP_BACKEND_LINK+'/user/signup')
93-
.reply(200, {response:{data:{data:'User M has been created. Check email for verification'}}});
94-
store.dispatch(actions.requestSignup(user)).then(()=>{
95-
let expectedActions =[
96-
{type: actions.REQUEST_SIGNUP},
97-
{type: actions.REQUEST_SUCCESS}
98-
];
99-
expect(store.getActions()).toEqual(expectedActions);
100-
}).catch(err => {});
101-
102-
},50000)
103-
104-
})

0 commit comments

Comments
 (0)