-
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.
Relates #54
- Loading branch information
Showing
7 changed files
with
48 additions
and
71 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 |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
"jsxBracketSameLine": false, | ||
"arrowParens": "avoid", | ||
"proseWrap": "never" | ||
} | ||
} |
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,7 +1,6 @@ | ||
function handleError(err, req, res, next) { | ||
const errorStatus = err.status || 400; | ||
res.status(errorStatus).send({error: err}); | ||
// console.error(err); | ||
} | ||
|
||
module.exports = handleError; |
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
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 |
---|---|---|
|
@@ -33,6 +33,15 @@ test("Can create new user", t => { | |
}); | ||
}); | ||
|
||
test("Returns error if no user found", t => { | ||
build().then(() => { | ||
getUser("[email protected]").catch(err => { | ||
t.equals(err.message, "User does not exist"); | ||
t.end(); | ||
}); | ||
}); | ||
}); | ||
|
||
test("Returns user with a given email address", t => { | ||
build().then(() => { | ||
getUser("[email protected]") | ||
|
@@ -84,69 +93,34 @@ test("Can get update an example by id without all values", t => { | |
}); | ||
}); | ||
|
||
// test.only("Can update an example by id", (t) => { | ||
// build().then(() => { | ||
// const data = { | ||
// language: "sql", | ||
// example: "This is an example of SQL", | ||
// }; | ||
// updateExample(4, data) | ||
// .then((res) => { | ||
// t.equal(res.language, "sql"); | ||
// // t.equal(res.title, 'SQL example snippet') | ||
// t.equal(res.title, null); | ||
// t.equal(res.example, "This is an example of SQL"); | ||
// t.end(); | ||
// }) | ||
// .catch((err) => { | ||
// t.error(err); | ||
// t.end(); | ||
// }); | ||
// }); | ||
// }); | ||
|
||
// test("Returns a users row by id", (t) => { | ||
// build().then(() => { | ||
// getUserById("2") | ||
// .then((res) => { | ||
// t.equal(res.username, "Tom"); | ||
// t.equal(res.adminusr, false); | ||
// t.end(); | ||
// }) | ||
// .catch((err) => { | ||
// t.error(err); | ||
// t.end(); | ||
// }); | ||
// }); | ||
// }); | ||
|
||
// test("Returns error if no user found", (t) => { | ||
// build().then(() => { | ||
// t.throws(() => getUser("[email protected]")) | ||
// t.end(); | ||
// }) | ||
// }); | ||
test("Returns a users row by id", t => { | ||
build().then(() => { | ||
getUserById("2") | ||
.then(res => { | ||
t.equal(res.username, "Tom"); | ||
t.equal(res.adminusr, false); | ||
t.end(); | ||
}) | ||
.catch(err => { | ||
t.error(err); | ||
t.end(); | ||
}); | ||
}); | ||
}); | ||
|
||
// test("Does not allow duplicate users when email is already in use", (t) => { | ||
// build() | ||
// .then(() => { | ||
// const user = { | ||
// username: "Tommy", | ||
// email: "[email protected]", | ||
// password: | ||
// "$2a$10$3IAfxI7ekmnHqMv1T8a46O./avVNcq/YYk6SGkRwxEHsy9cQasuUy", | ||
// }; | ||
// createUser(user).then(() => { | ||
// getUsers().then((res) => { | ||
// console.log("hello"); | ||
// t.equal(res[res.length - 1].username, "Roger"); | ||
// t.equal(res.length, 5); | ||
// t.end(); | ||
// }); | ||
// }); | ||
// }) | ||
// .catch((err) => { | ||
// t.error(err); | ||
// t.end(); | ||
// }); | ||
// }); | ||
test("Does not allow duplicate users when email is already in use", t => { | ||
build().then(() => { | ||
const user = { | ||
username: "Tommy", | ||
email: "[email protected]", | ||
password: "password" | ||
}; | ||
createUser(user).catch(() => { | ||
getUsers().then(res => { | ||
t.equal(res[res.length - 1].username, "Roger", "Database has not changed"); | ||
// t.equal(res.length, 5); | ||
t.end(); | ||
}); | ||
}); | ||
}); | ||
}); |