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

Removing DatabaseSupport.clean() #1207

Merged
merged 8 commits into from
Jul 25, 2024
8 changes: 3 additions & 5 deletions test/models/address.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const BillingAccountAddressHelper = require('../support/helpers/billing-account-
const BillingAccountAddressModel = require('../../app/models/billing-account-address.model.js')
const CompanyAddressHelper = require('../support/helpers/company-address.helper.js')
const CompanyAddressModel = require('../../app/models/company-address.model.js')
const DatabaseSupport = require('../support/database.js')
const LicenceDocumentRoleHelper = require('../support/helpers/licence-document-role.helper.js')
const LicenceDocumentRoleModel = require('../../app/models/licence-document-role.model.js')

Expand All @@ -23,10 +22,6 @@ const AddressModel = require('../../app/models/address.model.js')
describe('Address model', () => {
let testRecord

beforeEach(async () => {
await DatabaseSupport.clean()
})

describe('Basic query', () => {
beforeEach(async () => {
testRecord = await AddressHelper.add()
Expand Down Expand Up @@ -54,6 +49,7 @@ describe('Address model', () => {
// billingAccountId and start date
const startDate = i === 0 ? new Date(2023, 8, 4) : new Date(2023, 8, 3)
const billingAccountAddress = await BillingAccountAddressHelper.add({ startDate, addressId })

testBillingAccountAddresses.push(billingAccountAddress)
}
})
Expand Down Expand Up @@ -91,6 +87,7 @@ describe('Address model', () => {
testCompanyAddresses = []
for (let i = 0; i < 2; i++) {
const companyAddress = await CompanyAddressHelper.add({ addressId })

testCompanyAddresses.push(companyAddress)
}
})
Expand Down Expand Up @@ -128,6 +125,7 @@ describe('Address model', () => {
testLicenceDocumentRoles = []
for (let i = 0; i < 2; i++) {
const licenceDocumentRole = await LicenceDocumentRoleHelper.add({ addressId })

testLicenceDocumentRoles.push(licenceDocumentRole)
}
})
Expand Down
6 changes: 3 additions & 3 deletions test/models/bill-licence.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const { expect } = Code
const BillHelper = require('../support/helpers/bill.helper.js')
const BillModel = require('../../app/models/bill.model.js')
const BillLicenceHelper = require('../support/helpers/bill-licence.helper.js')
const DatabaseSupport = require('../support/database.js')
const LicenceHelper = require('../support/helpers/licence.helper.js')
const LicenceModel = require('../../app/models/licence.model.js')
const TransactionHelper = require('../support/helpers/transaction.helper.js')
Expand All @@ -24,8 +23,6 @@ describe('Bill Licence model', () => {
let testRecord

beforeEach(async () => {
await DatabaseSupport.clean()

testRecord = await BillLicenceHelper.add()
})

Expand All @@ -46,6 +43,7 @@ describe('Bill Licence model', () => {
testBill = await BillHelper.add()

const { id: billId } = testBill

testRecord = await BillLicenceHelper.add({ billId })
})

Expand Down Expand Up @@ -79,6 +77,7 @@ describe('Bill Licence model', () => {
testTransactions = []
for (let i = 0; i < 2; i++) {
const transaction = await TransactionHelper.add({ billLicenceId: id })

testTransactions.push(transaction)
}
})
Expand Down Expand Up @@ -112,6 +111,7 @@ describe('Bill Licence model', () => {
testLicence = await LicenceHelper.add()

const { id: licenceId } = testLicence

testRecord = await BillLicenceHelper.add({ licenceId })
})

Expand Down
7 changes: 2 additions & 5 deletions test/models/bill-run-charge-version-year.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@ const BillRunModel = require('../../app/models/bill-run.model.js')
const BillRunChargeVersionYearHelper = require('../support/helpers/bill-run-charge-version-year.helper.js')
const ChargeVersionHelper = require('../support/helpers/charge-version.helper.js')
const ChargeVersionModel = require('../../app/models/charge-version.model.js')
const DatabaseSupport = require('../support/database.js')

// Thing under test
const BillRunChargeVersionYearModel = require('../../app/models/bill-run-charge-version-year.model.js')

describe('Bill Run Charge Version Year model', () => {
let testRecord

beforeEach(async () => {
await DatabaseSupport.clean()
})

describe('Basic query', () => {
beforeEach(async () => {
testRecord = await BillRunChargeVersionYearHelper.add()
Expand All @@ -46,6 +41,7 @@ describe('Bill Run Charge Version Year model', () => {
testBillRun = await BillRunHelper.add()

const { id: billRunId } = testBillRun

testRecord = await BillRunChargeVersionYearHelper.add({ billRunId })
})

Expand Down Expand Up @@ -76,6 +72,7 @@ describe('Bill Run Charge Version Year model', () => {
testChargeVersion = await ChargeVersionHelper.add()

const { id: chargeVersionId } = testChargeVersion

testRecord = await BillRunChargeVersionYearHelper.add({ chargeVersionId })
})

Expand Down
7 changes: 2 additions & 5 deletions test/models/bill-run-volume.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@ const BillRunModel = require('../../app/models/bill-run.model.js')
const BillRunVolumeHelper = require('../support/helpers/bill-run-volume.helper.js')
const ChargeReferenceHelper = require('../support/helpers/charge-reference.helper.js')
const ChargeReferenceModel = require('../../app/models/charge-reference.model.js')
const DatabaseSupport = require('../support/database.js')

// Thing under test
const BillRunVolumeModel = require('../../app/models/bill-run-volume.model.js')

describe('Bill Run Volume model', () => {
let testRecord

beforeEach(async () => {
await DatabaseSupport.clean()
})

describe('Basic query', () => {
beforeEach(async () => {
testRecord = await BillRunVolumeHelper.add()
Expand All @@ -46,6 +41,7 @@ describe('Bill Run Volume model', () => {
testBillRun = await BillRunHelper.add()

const { id: billRunId } = testBillRun

testRecord = await BillRunVolumeHelper.add({ billRunId })
})

Expand Down Expand Up @@ -76,6 +72,7 @@ describe('Bill Run Volume model', () => {
testChargeReference = await ChargeReferenceHelper.add()

const { id: chargeReferenceId } = testChargeReference

testRecord = await BillRunVolumeHelper.add({ chargeReferenceId })
})

Expand Down
8 changes: 3 additions & 5 deletions test/models/bill-run.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const BillModel = require('../../app/models/bill.model.js')
const BillRunHelper = require('../support/helpers/bill-run.helper.js')
const BillRunVolumeHelper = require('../support/helpers/bill-run-volume.helper.js')
const BillRunVolumeModel = require('../../app/models/bill-run-volume.model.js')
const DatabaseSupport = require('../support/database.js')
const RegionHelper = require('../support/helpers/region.helper.js')
const RegionModel = require('../../app/models/region.model.js')
const ReviewLicenceHelper = require('../support/helpers/review-licence.helper.js')
Expand All @@ -25,10 +24,6 @@ const BillRunModel = require('../../app/models/bill-run.model.js')
describe('Bill Run model', () => {
let testRecord

beforeEach(async () => {
await DatabaseSupport.clean()
})

describe('Basic query', () => {
beforeEach(async () => {
testRecord = await BillRunHelper.add()
Expand Down Expand Up @@ -81,6 +76,7 @@ describe('Bill Run model', () => {
testBills = []
for (let i = 0; i < 2; i++) {
const bill = await BillHelper.add({ financialYearEnding: 2023, billRunId: id })

testBills.push(bill)
}
})
Expand Down Expand Up @@ -117,6 +113,7 @@ describe('Bill Run model', () => {
testBillRunVolumes = []
for (let i = 0; i < 2; i++) {
const billRunVolume = await BillRunVolumeHelper.add({ billRunId: id })

testBillRunVolumes.push(billRunVolume)
}
})
Expand Down Expand Up @@ -153,6 +150,7 @@ describe('Bill Run model', () => {
testReviewLicences = []
for (let i = 0; i < 2; i++) {
const reviewLicence = await ReviewLicenceHelper.add({ billRunId: id })

testReviewLicences.push(reviewLicence)
}
})
Expand Down
7 changes: 2 additions & 5 deletions test/models/bill.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@ const BillRunModel = require('../../app/models/bill-run.model.js')
const BillLicenceHelper = require('../support/helpers/bill-licence.helper.js')
const BillLicenceModel = require('../../app/models/bill-licence.model.js')
const BillRunHelper = require('../support/helpers/bill-run.helper.js')
const DatabaseSupport = require('../support/database.js')

// Thing under test
const BillModel = require('../../app/models/bill.model.js')

describe('Bill model', () => {
let testRecord

beforeEach(async () => {
await DatabaseSupport.clean()
})

describe('Basic query', () => {
beforeEach(async () => {
testRecord = await BillHelper.add()
Expand All @@ -48,6 +43,7 @@ describe('Bill model', () => {
testBillingAccount = await BillingAccountHelper.add()

const { id: billingAccountId } = testBillingAccount

testRecord = await BillHelper.add({ billingAccountId })
})

Expand Down Expand Up @@ -109,6 +105,7 @@ describe('Bill model', () => {
testBillLicences = []
for (let i = 0; i < 2; i++) {
const billLicence = await BillLicenceHelper.add({ billId: id })

testBillLicences.push(billLicence)
}
})
Expand Down
5 changes: 0 additions & 5 deletions test/models/billing-account-address.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@ const CompanyHelper = require('../support/helpers/company.helper.js')
const CompanyModel = require('../../app/models/company.model.js')
const ContactHelper = require('../support/helpers/contact.helper.js')
const ContactModel = require('../../app/models/contact.model.js')
const DatabaseSupport = require('../support/database.js')

// Thing under test
const BillingAccountAddressModel = require('../../app/models/billing-account-address.model.js')

describe('Billing Account Address model', () => {
let testRecord

beforeEach(async () => {
await DatabaseSupport.clean()
})

describe('Basic query', () => {
beforeEach(async () => {
testRecord = await BillingAccountAddressHelper.add()
Expand Down
8 changes: 3 additions & 5 deletions test/models/billing-account.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@ const ChargeVersionHelper = require('../support/helpers/charge-version.helper.js
const ChargeVersionModel = require('../../app/models/charge-version.model.js')
const CompanyHelper = require('../support/helpers/company.helper.js')
const CompanyModel = require('../../app/models/company.model.js')
const DatabaseSupport = require('../support/database.js')

// Thing under test
const BillingAccountModel = require('../../app/models/billing-account.model.js')

describe('Billing Account model', () => {
let testRecord

beforeEach(async () => {
await DatabaseSupport.clean()
})

describe('Basic query', () => {
beforeEach(async () => {
testRecord = await BillingAccountHelper.add()
Expand Down Expand Up @@ -56,6 +51,7 @@ describe('Billing Account model', () => {
// billingAccountId and start date
const startDate = i === 0 ? new Date(2023, 8, 4) : new Date(2023, 8, 3)
const billingAccountAddress = await BillingAccountAddressHelper.add({ startDate, billingAccountId })

testBillingAccountAddresses.push(billingAccountAddress)
}
})
Expand Down Expand Up @@ -92,6 +88,7 @@ describe('Billing Account model', () => {
testBills = []
for (let i = 0; i < 2; i++) {
const bill = await BillHelper.add({ billingAccountId })

testBills.push(bill)
}
})
Expand Down Expand Up @@ -128,6 +125,7 @@ describe('Billing Account model', () => {
testChargeVersions = []
for (let i = 0; i < 2; i++) {
const chargeVersion = await ChargeVersionHelper.add({ billingAccountId })

testChargeVersions.push(chargeVersion)
}
})
Expand Down
4 changes: 1 addition & 3 deletions test/models/change-reason.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const { expect } = Code
const ChangeReasonHelper = require('../support/helpers/change-reason.helper.js')
const ChargeVersionHelper = require('../support/helpers/charge-version.helper.js')
const ChargeVersionModel = require('../../app/models/charge-version.model.js')
const DatabaseSupport = require('../support/database.js')

// Thing under test
const ChangeReasonModel = require('../../app/models/change-reason.model.js')
Expand All @@ -20,8 +19,6 @@ describe('Change Reason model', () => {
let testRecord

beforeEach(async () => {
await DatabaseSupport.clean()

testRecord = await ChangeReasonHelper.add()
})

Expand All @@ -44,6 +41,7 @@ describe('Change Reason model', () => {
testChargeVersions = []
for (let i = 0; i < 2; i++) {
const chargeVersion = await ChargeVersionHelper.add({ changeReasonId: id })

testChargeVersions.push(chargeVersion)
}
})
Expand Down
4 changes: 1 addition & 3 deletions test/models/charge-category.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const { expect } = Code
const ChargeCategoryHelper = require('../support/helpers/charge-category.helper.js')
const ChargeReferenceHelper = require('../support/helpers/charge-reference.helper.js')
const ChargeReferenceModel = require('../../app/models/charge-reference.model.js')
const DatabaseSupport = require('../support/database.js')

// Thing under test
const ChargeCategoryModel = require('../../app/models/charge-category.model.js')
Expand All @@ -20,8 +19,6 @@ describe('Charge Category model', () => {
let testRecord

beforeEach(async () => {
await DatabaseSupport.clean()

testRecord = await ChargeCategoryHelper.add()
})

Expand All @@ -44,6 +41,7 @@ describe('Charge Category model', () => {
testChargeReferences = []
for (let i = 0; i < 2; i++) {
const chargeReference = await ChargeReferenceHelper.add({ description: `CE ${i}`, chargeCategoryId: id })

testChargeReferences.push(chargeReference)
}
})
Expand Down
5 changes: 0 additions & 5 deletions test/models/charge-element.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const { expect } = Code
const ChargeElementHelper = require('../support/helpers/charge-element.helper.js')
const ChargeReferenceHelper = require('../support/helpers/charge-reference.helper.js')
const ChargeReferenceModel = require('../../app/models/charge-reference.model.js')
const DatabaseSupport = require('../support/database.js')
const PurposeModel = require('../../app/models/purpose.model.js')
const PurposesSeeder = require('../support/seeders/purposes.seeder.js')
const ReviewChargeElementHelper = require('../support/helpers/review-charge-element.helper.js')
Expand All @@ -23,10 +22,6 @@ const ChargeElementModel = require('../../app/models/charge-element.model.js')
describe('Charge Element model', () => {
let testRecord

beforeEach(async () => {
await DatabaseSupport.clean()
})

describe('Basic query', () => {
beforeEach(async () => {
testRecord = await ChargeElementHelper.add()
Expand Down
5 changes: 0 additions & 5 deletions test/models/charge-reference.model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const ChargeElementModel = require('../../app/models/charge-element.model.js')
const ChargeReferenceHelper = require('../support/helpers/charge-reference.helper.js')
const ChargeVersionHelper = require('../support/helpers/charge-version.helper.js')
const ChargeVersionModel = require('../../app/models/charge-version.model.js')
const DatabaseSupport = require('../support/database.js')
const PurposeModel = require('../../app/models/purpose.model.js')
const PurposesSeeder = require('../support/seeders/purposes.seeder.js')
const ReviewChargeReferenceHelper = require('../support/helpers/review-charge-reference.helper.js')
Expand All @@ -31,10 +30,6 @@ const ChargeReferenceModel = require('../../app/models/charge-reference.model.js
describe('Charge Reference model', () => {
let testRecord

beforeEach(async () => {
await DatabaseSupport.clean()
})

describe('Basic query', () => {
beforeEach(async () => {
testRecord = await ChargeReferenceHelper.add()
Expand Down
Loading
Loading