Skip to content

Commit

Permalink
Merge branch 'main' into licence-ended-testing-end-point
Browse files Browse the repository at this point in the history
  • Loading branch information
Beckyrose200 authored Oct 21, 2024
2 parents cb1fb17 + 4c62291 commit b09ed6d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/services/bill-runs/fetch-bill-runs.service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { expect } = Code

// Test helpers
const BillRunHelper = require('../../support/helpers/bill-run.helper.js')
const BillRunModel = require('../../../app/models/bill-run.model.js')
const DatabaseConfig = require('../../../config/database.config.js')
const RegionHelper = require('../../support/helpers/region.helper.js')

Expand Down Expand Up @@ -103,6 +104,27 @@ describe('Fetch Bill Runs service', () => {
})
})
})

describe('when there are no bill runs', () => {
beforeEach(async () => {
// There will usually be bill runs in the database from other tests so we stub the query to simulate no bill runs
const queryStub = Sinon.stub(BillRunModel, 'query')

queryStub.returns({
select: Sinon.stub().returnsThis(),
innerJoinRelated: Sinon.stub().returnsThis(),
orderBy: Sinon.stub().returnsThis(),
page: Sinon.stub().resolves({ results: [], total: 0 })
})
})

it('returns a result with no "results" and 0 for "total"', async () => {
const result = await FetchBillRunsService.go()

expect(result.results).to.be.empty()
expect(result.total).to.equal(0)
})
})
})

function _addBillRun (billRunNumber, createdAt, netTotal, creditNoteCount, invoiceCount, regionId) {
Expand Down

0 comments on commit b09ed6d

Please sign in to comment.