Skip to content

Commit

Permalink
Updates unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gudjong committed Sep 5, 2024
1 parent 6ae26de commit de6a968
Showing 1 changed file with 28 additions and 30 deletions.
58 changes: 28 additions & 30 deletions libs/judicial-system/types/src/lib/indictmentCase.spec.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
import { getIndictmentVerdictAppealDeadline } from './indictmentCase'
import { getIndictmentVerdictAppealDeadlineStatus } from './indictmentCase'

describe('getIndictmentVerdictAppealDeadline', () => {
it('should return undefined if no dates are provided', () => {
const result = getIndictmentVerdictAppealDeadline([])
expect(result).toBeUndefined()
describe('getIndictmentVerdictAppealDeadlineStatus', () => {
it('should return [true, true] if no dates are provided', () => {
const result = getIndictmentVerdictAppealDeadlineStatus([])
expect(result).toEqual([true, true])
})

it('should return undefined if any dates are undefined', () => {
const result1 = getIndictmentVerdictAppealDeadline([
undefined,
new Date('2024-06-10T00:00:00Z'),
it('should return [false, false] if any dates are undefined', () => {
const result1 = getIndictmentVerdictAppealDeadlineStatus([
[true, undefined],
[true, new Date('2024-06-10T00:00:00Z')],
])
const result2 = getIndictmentVerdictAppealDeadline([
new Date('2024-06-10T00:00:00Z'),
undefined,
const result2 = getIndictmentVerdictAppealDeadlineStatus([
[true, new Date('2024-06-10T00:00:00Z')],
[true, undefined],
])
expect(result1).toBeUndefined()
expect(result2).toBeUndefined()
expect(result1).toEqual([false, false])
expect(result2).toEqual([false, false])
})

it('should return the correct deadline', () => {
const dates = [
new Date('2024-06-01T00:00:00Z'),
new Date('2024-06-01T00:00:00Z'),
new Date('2024-06-01T00:00:00Z'),
]
const result = getIndictmentVerdictAppealDeadline(dates)
const expectedDeadline = new Date('2024-06-29T00:00:00Z')

expect(result).toStrictEqual(expectedDeadline)
it('should return [true, false] if some deadline is not passed', () => {
const result = getIndictmentVerdictAppealDeadlineStatus([
[true, new Date('2024-06-01T00:00:00Z')],
[true, new Date()],
[true, new Date('2024-06-01T00:00:00Z')],
])
expect(result).toStrictEqual([true, false])
})

it('should handle a single valid date', () => {
const dates = [new Date('2024-07-15T00:00:00Z')]
const result = getIndictmentVerdictAppealDeadline(dates)
const expectedDeadline = new Date('2024-08-12T00:00:00Z')

expect(result).toStrictEqual(expectedDeadline)
it('should return [true, true] if all deadlines have passed', () => {
const result = getIndictmentVerdictAppealDeadlineStatus([
[true, new Date('2024-06-01T00:00:00Z')],
[true, new Date('2024-06-01T00:00:00Z')],
[true, new Date('2024-06-01T00:00:00Z')],
])
expect(result).toStrictEqual([true, true])
})
})

0 comments on commit de6a968

Please sign in to comment.