users.test.js 365 B

123456789101112131415161718192021
  1. var db = require('../db.js');
  2. var users = require('./users.js');
  3. let u = {
  4. username: "nikatlas",
  5. password: "mafalda",
  6. email: "[email protected]"
  7. }
  8. users.register(u).then(console.log).
  9. catch((e) => {
  10. if(e.name === "UsernameExists"){
  11. console.log("Username exists register is bypassed!");
  12. }
  13. });
  14. users.login(u).then(console.log).
  15. catch((e) => {
  16. console.log(e);
  17. });