+ it('Should be able to change the user email', async function () {
+ let updateVerificationString: string
+
+ {
+ await updateMyUser({
+ url: server.url,
+ accessToken: userAccessToken,
+ email: 'updated@example.com',
+ currentPassword: user1.password
+ })
+
+ await waitJobs(server)
+ expectedEmailsLength++
+ expect(emails).to.have.lengthOf(expectedEmailsLength)
+
+ const email = emails[expectedEmailsLength - 1]
+
+ const verificationStringMatches = /verificationString=([a-z0-9]+)/.exec(email['text'])
+ updateVerificationString = verificationStringMatches[1]
+ }
+
+ {
+ const res = await getMyUserInformation(server.url, userAccessToken)
+ const me: User = res.body
+
+ expect(me.email).to.equal('user_1@example.com')
+ expect(me.pendingEmail).to.equal('updated@example.com')
+ }
+
+ {
+ await verifyEmail(server.url, userId, updateVerificationString, true)
+
+ const res = await getMyUserInformation(server.url, userAccessToken)
+ const me: User = res.body
+
+ expect(me.email).to.equal('updated@example.com')
+ expect(me.pendingEmail).to.be.null
+ }
+ })
+