From f0d98057107ecf390aa921433d3706cc4a909b2d Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Tue, 2 Jul 2024 23:11:03 +0100 Subject: [PATCH 01/11] Fix bill run type in view licence bills tab https://eaflood.atlassian.net/browse/WATER-4316 > Part of the work to replace the legacy view licence page Whilst working on [Switch to GOV.UK table component for licence bills](https://github.com/DEFRA/water-abstraction-system/pull/1158) we spotted that a Nunjucks filter was being used to title-case the bill run type. How the bill run type is displayed is not as simple as just title-casing what the DB returns. In fact, because there is some logic involved and we have had to use it in a number of places we've added it to the base presenter as a reusable formatter. This change corrects the view licence bills presenter to use the existing bill run type formatter. From f75eba87b9bba1699ad98e1395d9ec6e0638aa84 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Tue, 2 Jul 2024 23:16:15 +0100 Subject: [PATCH 02/11] Housekeeping - add missing extension --- app/presenters/licences/view-licence-bills.presenter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/presenters/licences/view-licence-bills.presenter.js b/app/presenters/licences/view-licence-bills.presenter.js index c983fad75d..9f7224350e 100644 --- a/app/presenters/licences/view-licence-bills.presenter.js +++ b/app/presenters/licences/view-licence-bills.presenter.js @@ -5,7 +5,7 @@ * @module ViewLicenceBillsPresenter */ -const { formatLongDate, formatMoney } = require('../base.presenter') +const { formatLongDate, formatMoney } = require('../base.presenter.js') /** * Formats data for the `/licences/{id}/bills` view licence bill page From ac366799ecf4c5b66bbedb3965eb1b20dc1f03d8 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Tue, 2 Jul 2024 23:19:32 +0100 Subject: [PATCH 03/11] Update FetchLicenceBillsService to include info We also need the scheme and whether the bill run was flagged as summer or not in order to correctly determine the bill run type. --- app/services/licences/fetch-licence-bills.service.js | 7 ++++++- test/services/licences/fetch-licence-bills.service.test.js | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/services/licences/fetch-licence-bills.service.js b/app/services/licences/fetch-licence-bills.service.js index f9d815a090..111114cbf5 100644 --- a/app/services/licences/fetch-licence-bills.service.js +++ b/app/services/licences/fetch-licence-bills.service.js @@ -42,7 +42,12 @@ async function _fetch (licenceId, page) { .where('billRuns.status', 'sent') .withGraphFetched('billRun') .modifyGraph('billRun', (builder) => { - builder.select(['batchType']) + builder.select([ + 'id', + 'batchType', + 'scheme', + 'summer' + ]) }) .orderBy([ { column: 'createdAt', order: 'desc' } diff --git a/test/services/licences/fetch-licence-bills.service.test.js b/test/services/licences/fetch-licence-bills.service.test.js index 075125d947..ef853e51fe 100644 --- a/test/services/licences/fetch-licence-bills.service.test.js +++ b/test/services/licences/fetch-licence-bills.service.test.js @@ -69,7 +69,10 @@ describe('Fetch Licence Bills service', () => { [{ accountNumber: 'T21404193A', billRun: { - batchType: 'supplementary' + id: billRunId, + batchType: 'supplementary', + scheme: 'sroc', + summer: false }, billingAccountId, createdAt: createdDate, From 243ff1dbdcb28232b27e068c91f48b5ace6b6733 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Tue, 2 Jul 2024 23:23:38 +0100 Subject: [PATCH 04/11] Housekeeping - fix incorrect test file names --- ...lls-presenter.test.js => view-licence-bills.presenter.test.js} | 0 ...w-licence-presenter.test.js => view-licence.presenter.test.js} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/presenters/licences/{view-licence-bills-presenter.test.js => view-licence-bills.presenter.test.js} (100%) rename test/presenters/licences/{view-licence-presenter.test.js => view-licence.presenter.test.js} (100%) diff --git a/test/presenters/licences/view-licence-bills-presenter.test.js b/test/presenters/licences/view-licence-bills.presenter.test.js similarity index 100% rename from test/presenters/licences/view-licence-bills-presenter.test.js rename to test/presenters/licences/view-licence-bills.presenter.test.js diff --git a/test/presenters/licences/view-licence-presenter.test.js b/test/presenters/licences/view-licence.presenter.test.js similarity index 100% rename from test/presenters/licences/view-licence-presenter.test.js rename to test/presenters/licences/view-licence.presenter.test.js From 486bc59fe649dacb9be4f3cba4f887cf991eb203 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Tue, 2 Jul 2024 23:24:23 +0100 Subject: [PATCH 05/11] Housekeeping - fix missing file extension --- test/presenters/licences/view-licence-bills.presenter.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/presenters/licences/view-licence-bills.presenter.test.js b/test/presenters/licences/view-licence-bills.presenter.test.js index b9e68a8cf1..31c531edc4 100644 --- a/test/presenters/licences/view-licence-bills.presenter.test.js +++ b/test/presenters/licences/view-licence-bills.presenter.test.js @@ -8,7 +8,7 @@ const { describe, it } = exports.lab = Lab.script() const { expect } = Code // Thing under test -const ViewLicenceBillsPresenter = require('../../../app/presenters/licences/view-licence-bills.presenter') +const ViewLicenceBillsPresenter = require('../../../app/presenters/licences/view-licence-bills.presenter.js') describe('View Licence Bills presenter', () => { describe('when provided with a bills data', () => { From 24d632de6c83cc27e401a230a1731d4c9634d42f Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Tue, 2 Jul 2024 23:57:18 +0100 Subject: [PATCH 06/11] Refactor presenter We started with the aim of just updating the presenter to use the existing bill run type formatter. But we then spotted that the unit tests didn't follow our standard pattern of setting up test conditions in the `beforeEach()` (it was doing it in the `it`) It was also testing things that are using existing formatters that have their own tests which means there is no need to repeat them here. Finally, we felt we could simplify things if we renamed things to just be as they are (which meant some tweaks to the view as well). We also dropped `legacyId` from the presenter result because nothing in the view is using it. --- .../licences/view-licence-bills.presenter.js | 55 ++++--- app/views/licences/tabs/bills.njk | 8 +- .../view-licence-bills.presenter.test.js | 145 +++++++++--------- 3 files changed, 110 insertions(+), 98 deletions(-) diff --git a/app/presenters/licences/view-licence-bills.presenter.js b/app/presenters/licences/view-licence-bills.presenter.js index 9f7224350e..40c8f21ef5 100644 --- a/app/presenters/licences/view-licence-bills.presenter.js +++ b/app/presenters/licences/view-licence-bills.presenter.js @@ -5,7 +5,7 @@ * @module ViewLicenceBillsPresenter */ -const { formatLongDate, formatMoney } = require('../base.presenter.js') +const { formatBillRunType, formatLongDate, formatMoney } = require('../base.presenter.js') /** * Formats data for the `/licences/{id}/bills` view licence bill page @@ -15,46 +15,55 @@ const { formatLongDate, formatMoney } = require('../base.presenter.js') function go (bills) { return { activeTab: 'bills', - bills: _formatBillsToTableRow(bills) + bills: _bills(bills) } } -function _formatBatchType (batchType) { - return batchType.replace(/_/g, ' ') +function _bills (bills) { + return bills.map((bill) => { + const { + accountNumber, + billingAccountId, + billRun, + createdAt, + credit, + financialYearEnding, + id: billId, + netAmount + } = bill + + return { + accountNumber, + billingAccountId, + billId, + billNumber: _formatBillNumber(bill), + billRunType: formatBillRunType(billRun.batchType, billRun.scheme, billRun.summer), + credit, + dateCreated: formatLongDate(createdAt), + financialYearEnding, + total: formatMoney(netAmount) + } + }) } -function _formatBillNumberLabel (bill) { +function _formatBillNumber (bill) { if (bill.invoiceNumber) { return bill.invoiceNumber } + if (bill.deminimis) { return 'De minimis bill' } + if (bill.legacyId) { return 'NALD revised bill' } + if (bill.netAmount === 0) { return 'Zero value bill' } - return null -} - -function _formatBillsToTableRow (bills) { - return bills.map((bill) => { - return { - billNumber: _formatBillNumberLabel(bill), - dateCreated: formatLongDate(new Date(bill.createdAt)), - account: bill.accountNumber, - runType: _formatBatchType(bill.billRun.batchType), - financialYear: bill.financialYearEnding, - total: formatMoney(bill.netAmount), - accountId: bill.billingAccountId, - id: bill.id, - legacyId: bill.legacyId, - credit: bill.credit - } - }) + return '' } module.exports = { diff --git a/app/views/licences/tabs/bills.njk b/app/views/licences/tabs/bills.njk index a56a9ca320..9dcefcd547 100644 --- a/app/views/licences/tabs/bills.njk +++ b/app/views/licences/tabs/bills.njk @@ -19,7 +19,7 @@ {% set row = [ { - html: '' + bill.billNumber + '', + html: '' + bill.billNumber + '', attributes: { 'data-test': 'bill-number-' + rowIndex } }, { @@ -27,15 +27,15 @@ attributes: { 'data-test': 'bill-created-' + rowIndex } }, { - html: '' + bill.account + '', + html: '' + bill.accountNumber + '', attributes: { 'data-test': 'bill-account-' + rowIndex } }, { - text: bill.runType, + text: bill.billRunType, attributes: { 'data-test': 'bill-type-' + rowIndex } }, { - text: bill.financialYear, + text: bill.financialYearEnding, attributes: { 'data-test': 'bill-year-' + rowIndex }, format: 'numeric' }, diff --git a/test/presenters/licences/view-licence-bills.presenter.test.js b/test/presenters/licences/view-licence-bills.presenter.test.js index 31c531edc4..7543408067 100644 --- a/test/presenters/licences/view-licence-bills.presenter.test.js +++ b/test/presenters/licences/view-licence-bills.presenter.test.js @@ -4,76 +4,99 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Thing under test const ViewLicenceBillsPresenter = require('../../../app/presenters/licences/view-licence-bills.presenter.js') describe('View Licence Bills presenter', () => { + let bill + describe('when provided with a bills data', () => { + beforeEach(() => { + bill = _bill() + }) + it('correctly presents the data', () => { - const result = ViewLicenceBillsPresenter.go(_bills()) + const result = ViewLicenceBillsPresenter.go([bill]) expect(result).to.equal({ activeTab: 'bills', bills: [{ - account: 'acc123', - accountId: 'bicc1233', - billNumber: 'inv123', + accountNumber: 'BA1234443S', + billingAccountId: '2563bda0-73d8-4055-b3e7-421cf188d4dc', + billId: 'dfed8cdd-05c0-4f03-9a95-a7bae74fe7be', + billNumber: 'WAC0003872T', + billRunType: 'Annual', credit: false, dateCreated: '1 January 2020', - financialYear: '2021', - id: 'id123', - legacyId: null, - runType: 'annual', + financialYearEnding: '2021', total: '£1,234,567.89' }] }) }) - it('correctly formats the created date to convention', () => { - const result = ViewLicenceBillsPresenter.go(_bills()) - expect(result.bills[0].dateCreated).to.equal('1 January 2020') - }) - it('correctly formats the currency to UK standard', () => { - const result = ViewLicenceBillsPresenter.go(_bills()) - expect(result.bills[0].total).to.equal('£1,234,567.89') - }) + describe('the "bills" property', () => { + describe('for each bill returned', () => { + describe('when the invoice number exists', () => { + it('correctly formats the "billNumber" to the invoice number', () => { + const result = ViewLicenceBillsPresenter.go([bill]) - it('correctly formats the two part tariff batch type', () => { - const result = ViewLicenceBillsPresenter.go(_billsTwoPartTariff()) - expect(result.bills[0].runType).to.equal('two part tariff') - }) + expect(result.bills[0].billNumber).to.equal('WAC0003872T') + }) + }) - describe('billNumber', () => { - it('correctly formats the "billNumber" to the invoice number', () => { - const result = ViewLicenceBillsPresenter.go(_bills()) - expect(result.bills[0].billNumber).to.equal('inv123') - }) + describe('when it is flagged as deminimis', () => { + beforeEach(() => { + bill.invoiceNumber = null + bill.deminimis = true + }) - it('correctly formats the "billNumber" to "De minimis bill"', () => { - const bill = _bill() - bill.invoiceNumber = null - bill.deminimis = true - const result = ViewLicenceBillsPresenter.go([bill]) - expect(result.bills[0].billNumber).to.equal('De minimis bill') - }) + it('correctly formats the "billNumber" to "De minimis bill"', () => { + const result = ViewLicenceBillsPresenter.go([bill]) - it('correctly formats the "billNumber" to "NALD revised bill"', () => { - const bill = _bill() - bill.invoiceNumber = null - bill.legacyId = 'lgcy' - const result = ViewLicenceBillsPresenter.go([bill]) - expect(result.bills[0].billNumber).to.equal('NALD revised bill') - }) + expect(result.bills[0].billNumber).to.equal('De minimis bill') + }) + }) + + describe('when it has a legacy ID', () => { + beforeEach(() => { + bill.invoiceNumber = null + bill.legacyId = '100456' + }) + + it('correctly formats the "billNumber" to "NALD revised bill"', () => { + const result = ViewLicenceBillsPresenter.go([bill]) + + expect(result.bills[0].billNumber).to.equal('NALD revised bill') + }) + }) + + describe('when it has a zero net amount', () => { + beforeEach(() => { + bill.invoiceNumber = null + bill.netAmount = 0 + }) + + it('correctly formats the "billNumber" to "Zero value bill"', () => { + const result = ViewLicenceBillsPresenter.go([bill]) - it('correctly formats the "billNumber" to "Zero value bill"', () => { - const bill = _bill() - bill.invoiceNumber = null - bill.netAmount = 0 - const result = ViewLicenceBillsPresenter.go([bill]) - expect(result.bills[0].billNumber).to.equal('Zero value bill') + expect(result.bills[0].billNumber).to.equal('Zero value bill') + }) + }) + + describe('when it has no invoice number, deminimis flag, legacy ID, and net amount is not zero', () => { + beforeEach(() => { + bill.invoiceNumber = null + }) + + it('returns an empty string', () => { + const result = ViewLicenceBillsPresenter.go([bill]) + + expect(result.bills[0].billNumber).to.equal('') + }) + }) }) }) }) @@ -81,36 +104,16 @@ describe('View Licence Bills presenter', () => { function _bill () { return { - accountNumber: 'acc123', - billRun: { batchType: 'annual' }, - billingAccountId: 'bicc1233', + accountNumber: 'BA1234443S', + billRun: { batchType: 'annual', scheme: 'sroc', summer: false }, + billingAccountId: '2563bda0-73d8-4055-b3e7-421cf188d4dc', createdAt: new Date('2020-01-01'), credit: false, deminimis: false, financialYearEnding: '2021', - id: 'id123', - invoiceNumber: 'inv123', + id: 'dfed8cdd-05c0-4f03-9a95-a7bae74fe7be', + invoiceNumber: 'WAC0003872T', legacyId: null, netAmount: 123456789 } } - -function _bills () { - return [_bill()] -} - -function _billsTwoPartTariff () { - return [{ - accountNumber: 'acc123', - billRun: { batchType: 'two_part_tariff' }, - billingAccountId: 'bicc1233', - createdAt: new Date('2020-01-01'), - credit: false, - deminimis: false, - financialYearEnding: '2021', - id: 'id123', - invoiceNumber: 'inv123', - legacyId: null, - netAmount: 123456789 - }] -} From 5fe59c005f0585103faa12d9e47ad347062b2d5f Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Wed, 3 Jul 2024 00:02:47 +0100 Subject: [PATCH 07/11] Housekeeping - fix missing file extensions --- app/services/licences/view-licence-bills.service.js | 8 ++++---- .../licences/view-licence-bills.service.test.js | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/services/licences/view-licence-bills.service.js b/app/services/licences/view-licence-bills.service.js index 67afe2ff90..34ce886c93 100644 --- a/app/services/licences/view-licence-bills.service.js +++ b/app/services/licences/view-licence-bills.service.js @@ -5,10 +5,10 @@ * @module ViewLicenceBillsService */ -const FetchLicenceBillsService = require('./fetch-licence-bills.service') -const ViewLicenceBillsPresenter = require('../../presenters/licences/view-licence-bills.presenter') -const ViewLicenceService = require('./view-licence.service') -const PaginatorPresenter = require('../../presenters/paginator.presenter') +const FetchLicenceBillsService = require('./fetch-licence-bills.service.js') +const ViewLicenceBillsPresenter = require('../../presenters/licences/view-licence-bills.presenter.js') +const ViewLicenceService = require('./view-licence.service.js') +const PaginatorPresenter = require('../../presenters/paginator.presenter.js') /** * Orchestrates fetching and presenting the data needed for the licence summary page diff --git a/test/services/licences/view-licence-bills.service.test.js b/test/services/licences/view-licence-bills.service.test.js index c0ecb9f93b..7b977bf8eb 100644 --- a/test/services/licences/view-licence-bills.service.test.js +++ b/test/services/licences/view-licence-bills.service.test.js @@ -9,13 +9,13 @@ const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() const { expect } = Code // Things we need to stub -const FetchLicenceBillsService = require('../../../app/services/licences/fetch-licence-bills.service') -const PaginatorPresenter = require('../../../app/presenters/paginator.presenter') -const ViewLicenceService = require('../../../app/services/licences/view-licence.service') -const ViewLicenceBillsPresenter = require('../../../app/presenters/licences/view-licence-bills.presenter') +const FetchLicenceBillsService = require('../../../app/services/licences/fetch-licence-bills.service.js') +const PaginatorPresenter = require('../../../app/presenters/paginator.presenter.js') +const ViewLicenceService = require('../../../app/services/licences/view-licence.service.js') +const ViewLicenceBillsPresenter = require('../../../app/presenters/licences/view-licence-bills.presenter.js') // Thing under test -const ViewLicenceBillsService = require('../../../app/services/licences/view-licence-bills.service') +const ViewLicenceBillsService = require('../../../app/services/licences/view-licence-bills.service.js') describe('View Licence service bills', () => { const auth = {} From a28349168169df1190b55ec700632e2ef623c78a Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Wed, 3 Jul 2024 00:05:09 +0100 Subject: [PATCH 08/11] Housekeeping - correct comments --- app/services/licences/view-licence-bills.service.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/services/licences/view-licence-bills.service.js b/app/services/licences/view-licence-bills.service.js index 34ce886c93..8863995ff3 100644 --- a/app/services/licences/view-licence-bills.service.js +++ b/app/services/licences/view-licence-bills.service.js @@ -1,7 +1,7 @@ 'use strict' /** - * Orchestrates fetching and presenting the data needed for the licence summary page + * Orchestrates fetching and presenting the data needed for the view licence bills tab * @module ViewLicenceBillsService */ @@ -11,11 +11,11 @@ const ViewLicenceService = require('./view-licence.service.js') const PaginatorPresenter = require('../../presenters/paginator.presenter.js') /** - * Orchestrates fetching and presenting the data needed for the licence summary page + * Orchestrates fetching and presenting the data needed for the view licence bills tab * * @param {string} licenceId - The UUID of the licence * - * @returns {Promise} an object representing the `pageData` needed by the licence summary template. + * @returns {Promise} an object representing the `pageData` needed by the licence bills template. */ async function go (licenceId, auth, page) { const commonData = await ViewLicenceService.go(licenceId, auth) From 56cb7b9c799a5ac734438ad35b8a3f7f2199f24e Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Wed, 3 Jul 2024 00:05:31 +0100 Subject: [PATCH 09/11] Housekeeping - correct import order --- app/services/licences/view-licence-bills.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/licences/view-licence-bills.service.js b/app/services/licences/view-licence-bills.service.js index 8863995ff3..99389b429d 100644 --- a/app/services/licences/view-licence-bills.service.js +++ b/app/services/licences/view-licence-bills.service.js @@ -6,9 +6,9 @@ */ const FetchLicenceBillsService = require('./fetch-licence-bills.service.js') +const PaginatorPresenter = require('../../presenters/paginator.presenter.js') const ViewLicenceBillsPresenter = require('../../presenters/licences/view-licence-bills.presenter.js') const ViewLicenceService = require('./view-licence.service.js') -const PaginatorPresenter = require('../../presenters/paginator.presenter.js') /** * Orchestrates fetching and presenting the data needed for the view licence bills tab From 86b28538547ced353e7ddf4dbffe90f9cddd563a Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Wed, 3 Jul 2024 00:08:17 +0100 Subject: [PATCH 10/11] Move activeTab property to service out of presenter This makes the implementation consistent with the other services --- app/presenters/licences/view-licence-bills.presenter.js | 1 - app/services/licences/view-licence-bills.service.js | 1 + test/presenters/licences/view-licence-bills.presenter.test.js | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/presenters/licences/view-licence-bills.presenter.js b/app/presenters/licences/view-licence-bills.presenter.js index 40c8f21ef5..9cf6cf171d 100644 --- a/app/presenters/licences/view-licence-bills.presenter.js +++ b/app/presenters/licences/view-licence-bills.presenter.js @@ -14,7 +14,6 @@ const { formatBillRunType, formatLongDate, formatMoney } = require('../base.pres */ function go (bills) { return { - activeTab: 'bills', bills: _bills(bills) } } diff --git a/app/services/licences/view-licence-bills.service.js b/app/services/licences/view-licence-bills.service.js index 99389b429d..fcd7f022fd 100644 --- a/app/services/licences/view-licence-bills.service.js +++ b/app/services/licences/view-licence-bills.service.js @@ -26,6 +26,7 @@ async function go (licenceId, auth, page) { const pagination = PaginatorPresenter.go(billsData.pagination.total, Number(page), `/system/licences/${licenceId}/bills`) return { + activeTab: 'bills', ...commonData, ...pageData, pagination diff --git a/test/presenters/licences/view-licence-bills.presenter.test.js b/test/presenters/licences/view-licence-bills.presenter.test.js index 7543408067..8c730ed928 100644 --- a/test/presenters/licences/view-licence-bills.presenter.test.js +++ b/test/presenters/licences/view-licence-bills.presenter.test.js @@ -22,7 +22,6 @@ describe('View Licence Bills presenter', () => { const result = ViewLicenceBillsPresenter.go([bill]) expect(result).to.equal({ - activeTab: 'bills', bills: [{ accountNumber: 'BA1234443S', billingAccountId: '2563bda0-73d8-4055-b3e7-421cf188d4dc', From 3952639c20a551e7c19856927f841132d2f0e330 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Wed, 3 Jul 2024 00:09:36 +0100 Subject: [PATCH 11/11] Housekeeping - fix issues & only stub essentials --- .../licences/view-licence-bills.service.test.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/test/services/licences/view-licence-bills.service.test.js b/test/services/licences/view-licence-bills.service.test.js index 7b977bf8eb..2d88a9a91f 100644 --- a/test/services/licences/view-licence-bills.service.test.js +++ b/test/services/licences/view-licence-bills.service.test.js @@ -10,23 +10,17 @@ const { expect } = Code // Things we need to stub const FetchLicenceBillsService = require('../../../app/services/licences/fetch-licence-bills.service.js') -const PaginatorPresenter = require('../../../app/presenters/paginator.presenter.js') const ViewLicenceService = require('../../../app/services/licences/view-licence.service.js') -const ViewLicenceBillsPresenter = require('../../../app/presenters/licences/view-licence-bills.presenter.js') // Thing under test const ViewLicenceBillsService = require('../../../app/services/licences/view-licence-bills.service.js') describe('View Licence service bills', () => { const auth = {} - const page = 1 - const pagination = { page } const testId = '2c80bd22-a005-4cf4-a2a2-73812a9861de' beforeEach(() => { Sinon.stub(FetchLicenceBillsService, 'go').returns(_billsFetchService()) - Sinon.stub(PaginatorPresenter, 'go').returns(pagination) - Sinon.stub(ViewLicenceBillsPresenter, 'go').returns(_billsPresenter()) Sinon.stub(ViewLicenceService, 'go').resolves(_licence()) }) @@ -43,7 +37,7 @@ describe('View Licence service bills', () => { activeTab: 'bills', bills: [], licenceName: 'fake licence', - pagination: { page: 1 } + pagination: { numberOfPages: 1 } }) }) }) @@ -54,13 +48,6 @@ function _licence () { return { licenceName: 'fake licence' } } -function _billsPresenter () { - return { - bills: [], - activeTab: 'bills' - } -} - function _billsFetchService () { return { bills: [],