Skip to content

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cruikshanks committed Jan 9, 2023
1 parent 0eb660f commit 9e2306b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ describe('Create Billing Batch Event presenter', () => {
expect(result.batch.isSummer).to.equal(billingBatch.isSummer)
expect(result.batch.netTotal).to.equal(billingBatch.netTotal)

expect(result.batch.dateCreated).to.equal(billingBatch.createdAt)
expect(result.batch.dateUpdated).to.equal(billingBatch.updatedAt)
expect(result.batch.dateCreated).to.equal(billingBatch.dateCreated)
expect(result.batch.dateUpdated).to.equal(billingBatch.dateUpdated)
expect(result.batch.invoiceCount).to.equal(billingBatch.invoiceCount)
expect(result.batch.invoiceValue).to.equal(billingBatch.invoiceValue)
expect(result.batch.creditNoteCount).to.equal(billingBatch.creditNoteCount)
Expand Down
12 changes: 10 additions & 2 deletions test/support/helpers/water/billing-charge-category.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const BillingChargeCategoryModel = require('../../../../app/models/water/billing
* - `modelTier` - tier 1
* - `isRestrictedSource` - true
* - `minVolume` - 0
* - `maxVolume` - 5000
* - `maxVolume` - 5000,
* - `dateCreated` - Date.now()
*
* @param {Object} [data] Any data you want to use instead of the defaults used here or in the database
*
Expand Down Expand Up @@ -53,7 +54,14 @@ function defaults (data = {}) {
modelTier: 'tier 1',
isRestrictedSource: true,
minVolume: 0,
maxVolume: 5000
maxVolume: 5000,
// INFO: The billing_charge_categories table does not have a default for the date_created column. But it is set as
// 'not nullable'! So, we need to ensure we set it when creating a new record, something we'll never actually need
// to do because it's a static table. Also, we can't use Date.now() because Javascript returns the time since the
// epoch in milliseconds, whereas a PostgreSQL timestamp field can only hold the seconds since the epoch. Pass it
// an ISO string though ('2023-01-05T08:37:05.575Z') and PostgreSQL can do the conversion
// https://stackoverflow.com/a/61912776/6117745
dateCreated: new Date().toISOString()
}

return {
Expand Down

0 comments on commit 9e2306b

Please sign in to comment.