SettingsTests.mjs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* eslint-disable
  2. n/handle-callback-err,
  3. */
  4. // TODO: This file was created by bulk-decaffeinate.
  5. // Fix any style issues and re-enable lint.
  6. /*
  7. * decaffeinate suggestions:
  8. * DS102: Remove unnecessary code created because of implicit returns
  9. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  10. */
  11. import { expect } from 'chai'
  12. import async from 'async'
  13. import User from './helpers/User.mjs'
  14. import Features from '../../../app/src/infrastructure/Features.js'
  15. describe('SettingsPage', function () {
  16. beforeEach(function (done) {
  17. this.user = new User()
  18. return async.series(
  19. [
  20. this.user.ensureUserExists.bind(this.user),
  21. this.user.login.bind(this.user),
  22. ],
  23. done
  24. )
  25. })
  26. it('load settings page', function (done) {
  27. return this.user.getUserSettingsPage((err, statusCode) => {
  28. statusCode.should.equal(200)
  29. return done()
  30. })
  31. })
  32. it('update main email address', function (done) {
  33. if (Features.externalAuthenticationSystemUsed()) {
  34. this.skip()
  35. return
  36. }
  37. const newEmail = 'foo@bar.com'
  38. return this.user.updateSettings({ email: newEmail }, error => {
  39. expect(error).not.to.exist
  40. return this.user.get((error, user) => {
  41. user.email.should.equal(newEmail)
  42. user.emails.length.should.equal(1)
  43. user.emails[0].email.should.equal(newEmail)
  44. return done()
  45. })
  46. })
  47. })
  48. it('prevents first name from being updated to a string longer than 255 characters', function (done) {
  49. const newFirstName = 'a'.repeat(256)
  50. return this.user.updateSettings({ first_name: newFirstName }, error => {
  51. expect(error).to.exist
  52. expect(error.message).to.contain('update settings failed: status=400')
  53. return done()
  54. })
  55. })
  56. })