AdminEmailTests.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const { expect } = require('chai')
  2. const async = require('async')
  3. const User = require('./helpers/User')
  4. describe('AdminEmails', function () {
  5. beforeEach(function (done) {
  6. this.timeout(5000)
  7. done()
  8. })
  9. describe('an admin with an invalid email address', function () {
  10. before(function (done) {
  11. this.badUser = new User({ email: 'alice@evil.com' })
  12. async.series(
  13. [
  14. cb => this.badUser.ensureUserExists(cb),
  15. cb => this.badUser.ensureAdmin(cb),
  16. ],
  17. done
  18. )
  19. })
  20. it('should block the user', function (done) {
  21. this.badUser.login(err => {
  22. expect(err).to.not.exist
  23. this.badUser.getProjectListPage((err, statusCode) => {
  24. expect(err).to.exist
  25. done()
  26. })
  27. })
  28. })
  29. })
  30. describe('an admin with a valid email address', function () {
  31. before(function (done) {
  32. this.goodUser = new User({ email: 'alice@example.com' })
  33. async.series(
  34. [
  35. cb => this.goodUser.ensureUserExists(cb),
  36. cb => this.goodUser.ensureAdmin(cb),
  37. ],
  38. done
  39. )
  40. })
  41. it('should not block the user', function (done) {
  42. this.goodUser.login(err => {
  43. expect(err).to.not.exist
  44. this.goodUser.getProjectListPage((err, statusCode) => {
  45. expect(err).to.not.exist
  46. expect(statusCode).to.equal(200)
  47. done()
  48. })
  49. })
  50. })
  51. })
  52. })