generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.ts
39 lines (32 loc) · 913 Bytes
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import type { Express } from 'express'
import request from 'supertest'
import { appWithAllRoutes, user } from './testutils/appSetup'
import AuditService, { Page } from '../services/auditService'
jest.mock('../services/auditService')
const auditService = new AuditService(null) as jest.Mocked<AuditService>
let app: Express
beforeEach(() => {
app = appWithAllRoutes({
services: {
auditService,
},
userSupplier: () => user,
})
})
afterEach(() => {
jest.resetAllMocks()
})
describe('GET /', () => {
it('should render index page', () => {
auditService.logPageView.mockResolvedValue(null)
return request(app)
.get('/')
.expect('Content-Type', /html/)
.expect(res => {
expect(auditService.logPageView).toHaveBeenCalledWith(Page.APPLICATIONS_PAGE, {
who: user.username,
correlationId: expect.any(String),
})
})
})
})