From fb4d4f7781f2e0830897e1599535c83526b4c286 Mon Sep 17 00:00:00 2001 From: MCMXC <16797721+mcmxcdev@users.noreply.github.com> Date: Sat, 10 Feb 2024 18:37:40 -0700 Subject: updates --- tests/functional/dashboard/forgot-password.spec.ts | 64 ++++++++++++---------- 1 file changed, 34 insertions(+), 30 deletions(-) (limited to 'tests/functional/dashboard/forgot-password.spec.ts') diff --git a/tests/functional/dashboard/forgot-password.spec.ts b/tests/functional/dashboard/forgot-password.spec.ts index 7c356c8..82004ac 100644 --- a/tests/functional/dashboard/forgot-password.spec.ts +++ b/tests/functional/dashboard/forgot-password.spec.ts @@ -1,66 +1,70 @@ -import { test } from '@japa/runner' -import emitter from '@adonisjs/core/services/emitter' -import UserFactory from '#database/factories/UserFactory' +import { test } from '@japa/runner'; +import emitter from '@adonisjs/core/services/emitter'; +import UserFactory from '#database/factories/UserFactory'; test.group('Dashboard / Forgot password page', () => { - test('returns a 200 opening the forgot password route', async ({ client }) => { - const response = await client.get('/user/forgot') + test('returns a 200 opening the forgot password route', async ({ + client, + }) => { + const response = await client.get('/user/forgot'); - response.assertStatus(200) - response.assertTextIncludes('Forgot Password?') - }) + response.assertStatus(200); + response.assertTextIncludes('Forgot Password?'); + }); test('returns `Please enter a valid email address` when providing invalid email', async ({ client, }) => { const response = await client.post('/user/forgot').fields({ mail: 'invalid', - }) + }); - response.assertStatus(200) - response.assertTextIncludes('Please enter a valid email address') - }) + response.assertStatus(200); + response.assertTextIncludes('Please enter a valid email address'); + }); test('returns `email send when exists` without forgot:password event', async ({ client, assert, }) => { - const emitterService = emitter.fake() + const emitterService = emitter.fake(); const response = await client.post('/user/forgot').fields({ mail: 'test@ferdium.org', - }) + }); - response.assertStatus(200) + response.assertStatus(200); response.assertTextIncludes( - 'If your provided E-Mail address is linked to an account, we have just sent an E-Mail to that address.' - ) + 'If your provided E-Mail address is linked to an account, we have just sent an E-Mail to that address.', + ); - assert.isFalse(emitterService.exists('forgot:password')) - }) + assert.isFalse(emitterService.exists('forgot:password')); + }); test('returns `email send when exists` and trigger forgot:password event', async ({ client, assert, }) => { - const emitterService = emitter.fake() + const emitterService = emitter.fake(); const user = await UserFactory.merge({ email: 'test+forgot_password@ferdium.org', - }).create() + }).create(); const response = await client.post('/user/forgot').fields({ mail: 'test+forgot_password@ferdium.org', - }) + }); - response.assertStatus(200) + response.assertStatus(200); response.assertTextIncludes( - 'If your provided E-Mail address is linked to an account, we have just sent an E-Mail to that address.' - ) + 'If your provided E-Mail address is linked to an account, we have just sent an E-Mail to that address.', + ); assert.isTrue( emitterService.exists( - (event) => event.name === 'forgot:password' && event.data.user.email === user.email - ) - ) - }) -}) + event => + event.name === 'forgot:password' && + event.data.user.email === user.email, + ), + ); + }); +}); -- cgit v1.2.3-70-g09d2