users.test.js 369 B

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