From aa2092c0eb57a691502b278cdaa2d6428f8d6acf Mon Sep 17 00:00:00 2001 From: Jonathan Goulding <58443816+jonathangoulding@users.noreply.github.com> Date: Fri, 3 May 2024 17:12:07 +0100 Subject: [PATCH] fix: pr alpha sort white spaces content --- app/controllers/licences.controller.js | 4 ++-- app/presenters/licences/view-licence-returns.presenter.js | 5 +++-- app/routes/licence.routes.js | 4 ++-- app/services/licences/view-licence-returns.service.js | 1 + test/services/licences/fetch-licence-returns.service.test.js | 2 +- test/services/licences/view-licence-returns.service.test.js | 2 ++ 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/controllers/licences.controller.js b/app/controllers/licences.controller.js index 23f2582a34..cfa334c03e 100644 --- a/app/controllers/licences.controller.js +++ b/app/controllers/licences.controller.js @@ -49,6 +49,6 @@ async function viewReturns (request, h) { module.exports = { noReturnsRequired, returnsRequired, - viewSummary, - viewReturns + viewReturns, + viewSummary } diff --git a/app/presenters/licences/view-licence-returns.presenter.js b/app/presenters/licences/view-licence-returns.presenter.js index 3683f08e05..6f021260bc 100644 --- a/app/presenters/licences/view-licence-returns.presenter.js +++ b/app/presenters/licences/view-licence-returns.presenter.js @@ -1,7 +1,7 @@ 'use strict' /** - * Formats data for common licence data `/licences/{id}` page's + * Formats common data for the `/licences/{id}/*` view licence pages * @module ViewLicenceReturnsPresenter */ @@ -24,6 +24,7 @@ function go (returnsData) { function _formatPurpose (purpose) { const [firstPurpose] = purpose + return firstPurpose.alias ? firstPurpose.alias : firstPurpose.tertiary.description } @@ -34,7 +35,7 @@ function _formatStatus (status) { } function _formatReturnToTableRow (returns) { - return returns.map(r => { + return returns.map((r) => { return { id: r.id, reference: r.returnReference, diff --git a/app/routes/licence.routes.js b/app/routes/licence.routes.js index 1b9ae4f438..c71d066d8c 100644 --- a/app/routes/licence.routes.js +++ b/app/routes/licence.routes.js @@ -8,7 +8,7 @@ const routes = [ path: '/licences/{id}/summary', handler: LicencesController.viewSummary, options: { - description: 'View a summary licence page' + description: 'View a licence summary page' } }, { @@ -16,7 +16,7 @@ const routes = [ path: '/licences/{id}/returns', handler: LicencesController.viewReturns, options: { - description: 'View a returns licence page' + description: 'View a licence returns page' } }, { diff --git a/app/services/licences/view-licence-returns.service.js b/app/services/licences/view-licence-returns.service.js index 707cebbc45..fca6cc8e0f 100644 --- a/app/services/licences/view-licence-returns.service.js +++ b/app/services/licences/view-licence-returns.service.js @@ -9,6 +9,7 @@ const FetchLicenceReturnsService = require('./fetch-licence-returns.service') const ViewLicenceService = require('./view-licence.service') const ViewLicenceReturnsPresenter = require('../../presenters/licences/view-licence-returns.presenter') const PaginatorPresenter = require('../../presenters/paginator.presenter') + /** * Orchestrates fetching and presenting the data needed for the licence summary page * diff --git a/test/services/licences/fetch-licence-returns.service.test.js b/test/services/licences/fetch-licence-returns.service.test.js index cf7d44cb4e..a34b8eecf8 100644 --- a/test/services/licences/fetch-licence-returns.service.test.js +++ b/test/services/licences/fetch-licence-returns.service.test.js @@ -22,7 +22,7 @@ describe('Fetch licence returns service', () => { await DatabaseSupport.clean() }) - describe('when there is no optional data in the model', () => { + describe('when the licence has return logs', () => { let firstReturn let latestReturn const dueDate = new Date('2020-04-01') diff --git a/test/services/licences/view-licence-returns.service.test.js b/test/services/licences/view-licence-returns.service.test.js index 2c24c241df..6153035381 100644 --- a/test/services/licences/view-licence-returns.service.test.js +++ b/test/services/licences/view-licence-returns.service.test.js @@ -13,6 +13,7 @@ const ViewLicenceService = require('../../../app/services/licences/view-licence. const PaginatorPresenter = require('../../../app/presenters/paginator.presenter') const ViewLicenceReturnsPresenter = require('../../../app/presenters/licences/view-licence-returns.presenter') const FetchLicenceReturnsService = require('../../../app/services/licences/fetch-licence-returns.service') + // Thing under test const ViewLicenceReturnsService = require('../../../app/services/licences/view-licence-returns.service') @@ -21,6 +22,7 @@ describe('View Licence service returns', () => { const page = 1 const auth = {} const pagination = { page } + beforeEach(() => { Sinon.stub(FetchLicenceReturnsService, 'go').resolves(_returnsFetch()) Sinon.stub(PaginatorPresenter, 'go').returns(pagination)