Skip to content

Commit

Permalink
feature(read-book): add more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
segunolalive committed Dec 11, 2017
1 parent 83da69c commit 3e19e26
Show file tree
Hide file tree
Showing 7 changed files with 371 additions and 225 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ npm run start

#### API Documentation

* <https://www.segunolalive-hellobooks.com.herokuapp/api-docs>
* <https://www.segunolalive-hellobooks.herokuapp.com/api-docs>

#### Testing

Expand Down
45 changes: 45 additions & 0 deletions client/__tests__/__mocks__/superagent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
let mockDelay;
let mockError;
let mockResponse = {
status() {
return 200;
},
ok: true,
get: jest.genMockFunction(),
toError: jest.genMockFunction(),
data: { message: 'success' }
};

const request = {
post: jest.genMockFunction().mockReturnThis(),
get: jest.genMockFunction().mockReturnThis(),
send: jest.genMockFunction().mockReturnThis(),
query: jest.genMockFunction().mockReturnThis(),
field: jest.genMockFunction().mockReturnThis(),
set: jest.genMockFunction().mockReturnThis(),
accept: jest.genMockFunction().mockReturnThis(),
timeout: jest.genMockFunction().mockReturnThis(),
end: jest.genMockFunction().mockImplementation(function cb(callback) {
if (mockDelay) {
this.delayTimer = setTimeout(callback, 0, mockError, mockResponse);
return;
}

callback(mockError, mockResponse);
}),

__setMockDelay(boolValue) {
mockDelay = boolValue;
},
__setMockResponse(mockRes) {
mockResponse = mockRes;
},
__setMockError(mockErr) {
mockError = mockErr;
},
__setMockResponseBody(body) {
mockResponse.body = body;
}
};

export default request;
14 changes: 7 additions & 7 deletions client/actions/authActions/resetPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import notify from '../notify';
* send request to reset password
* @param {String} password new password
* @param {String} token json web token
* @returns {Undefined} sends an http request
*
* @returns {undefined} success or failure notification
*/
const resetPassword = (password, token) => () => (
axios.put(`${API}/users/reset-password/${token}`, { password })
.then(response => notify.success(response.data.message)
).catch(error => notify.error(error.response.data.message))
);

const resetPassword = (password, token) => () =>
axios
.put(`${API}/users/reset-password/${token}`, { password })
.then(response => notify.success(response.data.message))
.catch(error => notify.error(error.response.data.message));
export default resetPassword;
7 changes: 6 additions & 1 deletion server/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ module.exports = {
dialect: process.env.dialect,
},
test: {
use_env_variable: 'DATABASE_URL_TEST',
// use_env_variable: 'DATABASE_URL_TEST',
username: process.env.test_username,
password: process.env.test_password,
database: process.env.test_database,
host: process.env.test_host,
dialect: process.env.dialect,
},
production: {
use_env_variable: 'DATABASE_URL',
Expand Down
Loading

0 comments on commit 3e19e26

Please sign in to comment.