Skip to content

Commit

Permalink
Updates unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gudjong committed Jun 4, 2024
1 parent f8339e7 commit 6df8e20
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import {
restrictionCases,
} from '@island.is/judicial-system/types'

import { CaseTypeGuard, CaseWriteGuard } from '../../../case'
import {
CaseCompletedGuard,
CaseTypeGuard,
CaseWriteGuard,
} from '../../../case'
import { LimitedAccessWriteCaseFileGuard } from '../../guards/limitedAccessWriteCaseFile.guard'
import { LimitedAccessFileController } from '../../limitedAccessFile.controller'

Expand All @@ -19,12 +23,13 @@ describe('LimitedAccessFileController - Create case file guards', () => {
})

it('should have the right guard configuration', () => {
expect(guards).toHaveLength(3)
expect(guards).toHaveLength(4)
expect(guards[0]).toBeInstanceOf(CaseTypeGuard)
expect(guards[0]).toEqual({
allowedCaseTypes: [...restrictionCases, ...investigationCases],
})
expect(new guards[1]()).toBeInstanceOf(CaseWriteGuard)
expect(new guards[2]()).toBeInstanceOf(LimitedAccessWriteCaseFileGuard)
expect(new guards[2]()).toBeInstanceOf(CaseCompletedGuard)
expect(new guards[3]()).toBeInstanceOf(LimitedAccessWriteCaseFileGuard)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import {
restrictionCases,
} from '@island.is/judicial-system/types'

import { CaseTypeGuard, CaseWriteGuard } from '../../../case'
import {
CaseCompletedGuard,
CaseTypeGuard,
CaseWriteGuard,
} from '../../../case'
import { LimitedAccessFileController } from '../../limitedAccessFile.controller'

describe('LimitedAccessFileController - Create presigned post guards', () => {
Expand All @@ -18,11 +22,12 @@ describe('LimitedAccessFileController - Create presigned post guards', () => {
})

it('should have the right guard configuration', () => {
expect(guards).toHaveLength(2)
expect(guards).toHaveLength(3)
expect(guards[0]).toBeInstanceOf(CaseTypeGuard)
expect(guards[0]).toEqual({
allowedCaseTypes: [...restrictionCases, ...investigationCases],
})
expect(new guards[1]()).toBeInstanceOf(CaseWriteGuard)
expect(new guards[2]()).toBeInstanceOf(CaseCompletedGuard)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import {
restrictionCases,
} from '@island.is/judicial-system/types'

import { CaseTypeGuard, CaseWriteGuard } from '../../../case'
import {
CaseCompletedGuard,
CaseTypeGuard,
CaseWriteGuard,
} from '../../../case'
import { CaseFileExistsGuard } from '../../guards/caseFileExists.guard'
import { LimitedAccessWriteCaseFileGuard } from '../../guards/limitedAccessWriteCaseFile.guard'
import { LimitedAccessFileController } from '../../limitedAccessFile.controller'
Expand All @@ -20,13 +24,14 @@ describe('LimitedAccessFileController - Delete case file guards', () => {
})

it('should have the right guard configuration', () => {
expect(guards).toHaveLength(4)
expect(guards).toHaveLength(5)
expect(guards[0]).toBeInstanceOf(CaseTypeGuard)
expect(guards[0]).toEqual({
allowedCaseTypes: [...restrictionCases, ...investigationCases],
})
expect(new guards[1]()).toBeInstanceOf(CaseWriteGuard)
expect(new guards[2]()).toBeInstanceOf(CaseFileExistsGuard)
expect(new guards[3]()).toBeInstanceOf(LimitedAccessWriteCaseFileGuard)
expect(new guards[2]()).toBeInstanceOf(CaseCompletedGuard)
expect(new guards[3]()).toBeInstanceOf(CaseFileExistsGuard)
expect(new guards[4]()).toBeInstanceOf(LimitedAccessWriteCaseFileGuard)
})
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { JwtAuthGuard, RolesGuard } from '@island.is/judicial-system/auth'

import { CaseCompletedGuard, LimitedAccessCaseExistsGuard } from '../../../case'
import { LimitedAccessCaseExistsGuard } from '../../../case'
import { LimitedAccessFileController } from '../../limitedAccessFile.controller'

describe('LimitedAccessFileController - guards', () => {
Expand All @@ -12,10 +12,9 @@ describe('LimitedAccessFileController - guards', () => {
})

it('should have the right guard configuration', () => {
expect(guards).toHaveLength(4)
expect(guards).toHaveLength(3)
expect(new guards[0]()).toBeInstanceOf(JwtAuthGuard)
expect(new guards[1]()).toBeInstanceOf(RolesGuard)
expect(new guards[2]()).toBeInstanceOf(LimitedAccessCaseExistsGuard)
expect(new guards[3]()).toBeInstanceOf(CaseCompletedGuard)
})
})

0 comments on commit 6df8e20

Please sign in to comment.