From f076daa76a32074cba162459e38fa8c130ad42d0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 30 Jan 2018 15:16:24 +0100 Subject: Add tests for emails --- server/tests/api/check-params/users.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'server/tests/api/check-params/users.ts') diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 28fefe79f..0fbc414c9 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -541,6 +541,28 @@ describe('Test users API validators', function () { }) }) + describe('When asking a password reset', function () { + const path = '/api/v1/users/ask-reset-password' + + it('Should fail with a missing email', async function () { + const fields = {} + + await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) + }) + + it('Should fail with an invalid email', async function () { + const fields = { email: 'hello' } + + await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) + }) + + it('Should success with the correct params', async function () { + const fields = { email: 'admin@example.com' } + + await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 204 }) + }) + }) + after(async function () { killallServers([ server, serverWithRegistrationDisabled ]) -- cgit v1.2.3