Skip to content

Commit

Permalink
Adds unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gudjong committed Nov 22, 2024
1 parent c7d1d98 commit b815229
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { indictmentCases } from '@island.is/judicial-system/types'

import { DefendantNationalIdExistsGuard } from '../../../defendant'
import { CaseExistsGuard } from '../../guards/caseExists.guard'
import { CaseTypeGuard } from '../../guards/caseType.guard'
import { InternalCaseController } from '../../internalCase.controller'

describe('InternalCaseController - Get indictment case by id', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let guards: any[]

beforeEach(() => {
guards = Reflect.getMetadata(
'__guards__',
InternalCaseController.prototype.getIndictmentCaseById,
)
})

it('should have the right guard configuration', () => {
expect(guards).toHaveLength(3)
expect(new guards[0]()).toBeInstanceOf(CaseExistsGuard)
expect(guards[1]).toBeInstanceOf(CaseTypeGuard)
expect(guards[1]).toEqual({
allowedCaseTypes: indictmentCases,
})
expect(new guards[2]()).toBeInstanceOf(DefendantNationalIdExistsGuard)
})
})

0 comments on commit b815229

Please sign in to comment.