From ddce996d780dc7cd2e36a8ee558cfdc8e4675314 Mon Sep 17 00:00:00 2001 From: Andrew Rumble Date: Wed, 17 Sep 2025 09:05:59 +0100 Subject: [PATCH] Update test to reflect new behaviour The affected values shouldn't ever have got past the validation in the router (so the old behaviour should be unused) GitOrigin-RevId: 3afbd09bd12279125b65fb0d3ec1242f0b456d6f --- .../PasswordResetController.test.mjs | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/services/web/test/unit/src/PasswordReset/PasswordResetController.test.mjs b/services/web/test/unit/src/PasswordReset/PasswordResetController.test.mjs index d3dc937e3f..cbc587b570 100644 --- a/services/web/test/unit/src/PasswordReset/PasswordResetController.test.mjs +++ b/services/web/test/unit/src/PasswordReset/PasswordResetController.test.mjs @@ -1,11 +1,9 @@ -import { expect, vi } from 'vitest' +import { beforeEach, describe, expect, it, vi } from 'vitest' import sinon from 'sinon' import MockResponse from '../helpers/MockResponse.js' -const MODULE_PATH = new URL( - '../../../../app/src/Features/PasswordReset/PasswordResetController.mjs', - import.meta.url -).pathname +const MODULE_PATH = + '../../../../app/src/Features/PasswordReset/PasswordResetController.mjs' describe('PasswordResetController', function () { beforeEach(async function (ctx) { @@ -501,15 +499,18 @@ describe('PasswordResetController', function () { ctx.req.query.email = { foo: 'bar' } }) - it('should set session.resetToken and redirect without email', async function (ctx) { + it('should call next with an error', async function (ctx) { await new Promise(resolve => { ctx.req.session.should.not.have.property('resetToken') - ctx.res.redirect = path => { - path.should.equal('/user/password/set') - ctx.req.session.resetToken.should.equal(ctx.token) + const next = error => { + expect(error).to.exist resolve() } - ctx.PasswordResetController.renderSetPasswordForm(ctx.req, ctx.res) + ctx.PasswordResetController.renderSetPasswordForm( + ctx.req, + ctx.res, + next + ) }) }) })