Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing unit tests #1445

Merged
merged 6 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/presenters/bills/remove-bill.presenter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script()
const { expect } = Code

// Test helpers
const BillingAccountHelper = require('../../../app/models/billing-account.model.js')
const BillingAccountModel = require('../../../app/models/billing-account.model.js')

// Thing under test
const RemoveBillPresenter = require('../../../app/presenters/bills/remove-bill.presenter.js')
Expand Down Expand Up @@ -151,7 +151,7 @@ describe('Remove Bill presenter', () => {
})

function _billSummary () {
const billingAccount = BillingAccountHelper.fromJson({
const billingAccount = BillingAccountModel.fromJson({
id: 'e2b35a4a-7368-425f-9990-faa23efc0a25',
accountNumber: 'T65757520A',
company: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const Sinon = require('sinon')
const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script()
const { expect } = Code

// Test helpers
const BillingAccountModel = require('../../../../app/models/billing-account.model.js')

// Things we need to stub
const FetchReviewLicenceResultsService = require('../../../../app/services/bill-runs/two-part-tariff/fetch-review-licence-results.service.js')

Expand Down Expand Up @@ -51,6 +54,40 @@ describe('Review Licence Service', () => {
})

function _fetchReviewLicenceResults () {
const billingAccountDetails = BillingAccountModel.fromJson({
id: 'a17ae69b-8074-4d27-80bf-074f4c79a05a',
accountNumber: 'E88896464A',
company: {
id: 'e44491db-2b33-4473-9c3a-b57aceabb6e8',
name: 'Furland Farm',
type: 'organisation'
},
billingAccountAddresses: [
{
id: 'eb5cb54a-0b51-4e4a-8472-dab993eb6157',
billingAccountId: 'a17ae69b-8074-4d27-80bf-074f4c79a05a',
addressId: 'cc32fefd-7f3e-4581-b437-78a3fae66d4b',
startDate: new Date('2016-05-20'),
endDate: null,
companyId: null,
contactId: null,
company: null,
contact: null,
address: {
id: 'cc32fefd-7f3e-4581-b437-78a3fae66d4b',
address1: 'Furland Farm',
address2: 'Furland',
address3: null,
address4: null,
address5: 'Crewkerne',
address6: 'Somerset',
postcode: 'TA18 7TT',
country: 'England'
}
}
]
})

return {
billRun: {
id: '6620135b-0ecf-4fd4-924e-371f950c0526',
Expand Down Expand Up @@ -204,39 +241,7 @@ function _fetchReviewLicenceResults () {
chargeVersion: {
billingAccountId: '67d7cacb-5d10-4a08-b7f8-e6ce98cbf4c8'
},
billingAccountDetails: {
id: 'a17ae69b-8074-4d27-80bf-074f4c79a05a',
accountNumber: 'E88896464A',
company: {
id: 'e44491db-2b33-4473-9c3a-b57aceabb6e8',
name: 'Furland Farm',
type: 'organisation'
},
billingAccountAddresses: [
{
id: 'eb5cb54a-0b51-4e4a-8472-dab993eb6157',
billingAccountId: 'a17ae69b-8074-4d27-80bf-074f4c79a05a',
addressId: 'cc32fefd-7f3e-4581-b437-78a3fae66d4b',
startDate: new Date('2016-05-20'),
endDate: null,
companyId: null,
contactId: null,
company: null,
contact: null,
address: {
id: 'cc32fefd-7f3e-4581-b437-78a3fae66d4b',
address1: 'Furland Farm',
address2: 'Furland',
address3: null,
address4: null,
address5: 'Crewkerne',
address6: 'Somerset',
postcode: 'TA18 7TT',
country: 'England'
}
}
]
}
billingAccountDetails
}]
}]
}
Expand Down
55 changes: 30 additions & 25 deletions test/services/bills/remove-bill.service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const Sinon = require('sinon')
const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script()
const { expect } = Code

// Test helpers
const BillingAccountModel = require('../../../app/models/billing-account.model.js')

// Things we need to stub
const FetchBillSummaryService = require('../../../app/services/bills/fetch-bill-summary.service.js')

Expand Down Expand Up @@ -51,34 +54,36 @@ describe('Remove Bill service', () => {
})

function _billSummary () {
const billingAccount = BillingAccountModel.fromJson({
id: 'e2b35a4a-7368-425f-9990-faa23efc0a25',
accountNumber: 'T65757520A',
company: {
id: '3b60ddd0-654f-4012-a349-000aab3e49c3',
name: 'Example Trading Ltd',
type: 'organisation'
},
billingAccountAddresses: [{
id: '1d440029-745a-47ec-a43e-9f4a36014126',
company: null,
contact: {
id: '95ba53be-543f-415b-90b1-08f58f63ff74',
contactType: 'person',
dataSource: 'wrls',
department: null,
firstName: 'Amara',
initials: null,
lastName: 'Gupta',
middleInitials: null,
salutation: null,
suffix: null
}
}]
})

return {
id: '71d03336-f683-42fe-b67c-c861f25f1fbd',
netAmount: 1045,
billingAccount: {
id: 'e2b35a4a-7368-425f-9990-faa23efc0a25',
accountNumber: 'T65757520A',
company: {
id: '3b60ddd0-654f-4012-a349-000aab3e49c3',
name: 'Example Trading Ltd',
type: 'organisation'
},
billingAccountAddresses: [{
id: '1d440029-745a-47ec-a43e-9f4a36014126',
company: null,
contact: {
id: '95ba53be-543f-415b-90b1-08f58f63ff74',
contactType: 'person',
dataSource: 'wrls',
department: null,
firstName: 'Amara',
initials: null,
lastName: 'Gupta',
middleInitials: null,
salutation: null,
suffix: null
}
}]
},
billingAccount,
billLicences: [
{
id: '9304f6b8-0664-4fec-98e1-8fd16144315c',
Expand Down
2 changes: 1 addition & 1 deletion test/support/helpers/return-cycle.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function defaults (data = {}) {
* @returns {object} The selected reference entry or one picked at random
*/
async function select (index = -1, summer = false) {
const returnCycles = await ReturnCycleModel.query().where('summer', summer)
const returnCycles = await ReturnCycleModel.query().where('summer', summer).orderBy('startDate', 'DESC')

if (index > -1) {
return returnCycles[index]
Expand Down
Loading