Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeGoodall committed Aug 1, 2024
1 parent ae7c01b commit 0cf60a3
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions test/unit/organisationsController.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('OrganisationsController.js', () => {
const req = { params: { lpa: 'test-lpa' } }
const res = { render: vi.fn() }
const next = vi.fn()

const expectedResponse = {
name: 'Test LPA',
datasets: {
Expand All @@ -28,11 +28,11 @@ describe('OrganisationsController.js', () => {
dataset3: { endpoint: 'https://example.com', issue: false, error: true }
}
}

performanceDbApi.getLpaOverview = vi.fn().mockResolvedValue(expectedResponse)

await LpaOverviewController.getOverview(req, res, next)

expect(res.render).toHaveBeenCalledTimes(1)
expect(res.render).toHaveBeenCalledWith('organisations/overview.html', expect.objectContaining({
organisation: { name: 'Test LPA' },
Expand All @@ -47,18 +47,18 @@ describe('OrganisationsController.js', () => {
datasetsWithErrors: 1
}))
})

it('should catch and pass errors to the next function', async () => {
const req = { params: { lpa: 'test-lpa' } }
const res = { }
const next = vi.fn()

const error = new Error('Test error')

vi.mocked(performanceDbApi.getLpaOverview).mockRejectedValue(error)

await LpaOverviewController.getOverview(req, res, next)

expect(next).toHaveBeenCalledTimes(1)
expect(next).toHaveBeenCalledWith(error)
})
Expand All @@ -71,5 +71,4 @@ describe('OrganisationsController.js', () => {

it.todo('should catch errors and pass them onto the next function')
})

})

0 comments on commit 0cf60a3

Please sign in to comment.