From 355ccc53164f3a9a1c137a2c0971353fc13858cc Mon Sep 17 00:00:00 2001 From: Scott Dormand Date: Fri, 6 Dec 2024 08:57:15 +0000 Subject: [PATCH] remove commented code --- .../routes/__tests__/authenticate.spec.js | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/packages/sales-api-service/src/server/routes/__tests__/authenticate.spec.js b/packages/sales-api-service/src/server/routes/__tests__/authenticate.spec.js index f326296f1..5366dfad8 100644 --- a/packages/sales-api-service/src/server/routes/__tests__/authenticate.spec.js +++ b/packages/sales-api-service/src/server/routes/__tests__/authenticate.spec.js @@ -166,6 +166,20 @@ describe('authenticate handler', () => { }) }) + it('throws 401 errors if no contact to be authenticated', async () => { + executeQuery.mockResolvedValueOnce([]) + const result = await server.inject({ + method: 'GET', + url: '/authenticate/renewal/CD379B?licenseeBirthDate=2000-01-01&licenseePostcode=AB12 3CD' + }) + expect(result.statusCode).toBe(401) + expect(JSON.parse(result.payload)).toMatchObject({ + error: 'Unauthorized', + message: 'The licensee could not be authenticated', + statusCode: 401 + }) + }) + it('throws 400 errors if the required parameters are not supplied', async () => { const result = await server.inject({ method: 'GET', url: '/authenticate/renewal/CD379B?' }) expect(result.statusCode).toBe(400) @@ -175,27 +189,5 @@ describe('authenticate handler', () => { statusCode: 400 }) }) - - // it('throws 500 errors if more than one result was found for the query', async () => { - // executeQuery.mockResolvedValueOnce([ - // { - // entity: MOCK_EXISTING_CONTACT_ENTITY, - // expanded: {} - // } - // ]) - // executeQuery.mockResolvedValueOnce([{ entity: { referenceNumber: 'CD379B' } }, { entity: { referenceNumber: 'CD379B' } }]) - // const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(jest.fn()) - // const result = await server.inject({ - // method: 'GET', - // url: '/authenticate/renewal/CD379B?licenseeBirthDate=2000-01-01&licenseePostcode=AB12 3CD' - // }) - // expect(result.statusCode).toBe(500) - // expect(JSON.parse(result.payload)).toMatchObject({ - // error: 'Internal Server Error', - // message: 'Unable to authenticate, non-unique results for query', - // statusCode: 500 - // }) - // expect(consoleErrorSpy).toHaveBeenCalled() - // }) }) })