@ministryofjustice/hmpps-digital-prison-reporting-frontend
Version:
The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.
65 lines (56 loc) • 1.6 kB
text/typescript
import { Response } from 'express'
import CatalogueUtils from './utils'
import CatalogueListUtils from '../catalogue-list/utils'
import { Services } from '../../../types/Services'
describe('CatalogueUtils', () => {
jest.spyOn(CatalogueListUtils, 'getReportsList').mockResolvedValue({
head: [],
rows: [],
})
describe('init', () => {
let services: Services
let res: Response
beforeEach(() => {
res = {
locals: {
user: {
token: 'T0k3n',
},
},
} as unknown as Response
services = {} as unknown as Services
})
it('should init the catalogue with defaults', async () => {
const result = await CatalogueUtils.init({ features: {}, res, services })
expect(result).toEqual({
data: { head: [], rows: [] },
features: {
bookmarkingEnabled: undefined,
filteringEnabled: true,
howToUseEnabled: true,
unauthorisedToggleEnabled: true,
},
})
})
it('should init the catalogue with configured features', async () => {
const result = await CatalogueUtils.init({
features: {
filteringEnabled: false,
unauthorisedToggleEnabled: false,
bookmarkingEnabled: false,
},
res,
services,
})
expect(result).toEqual({
data: { head: [], rows: [] },
features: {
bookmarkingEnabled: false,
filteringEnabled: false,
howToUseEnabled: true,
unauthorisedToggleEnabled: false,
},
})
})
})
})