From f4020cd081dffe75d2ceffc6b48db123cf5dc257 Mon Sep 17 00:00:00 2001 From: unakb Date: Thu, 24 Oct 2024 15:22:12 +0000 Subject: [PATCH] Update case.transformer.spec.ts --- .../interceptors/case.transformer.spec.ts | 93 +++++-------------- 1 file changed, 21 insertions(+), 72 deletions(-) diff --git a/apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts b/apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts index 9e5b7a5c9507..8395519df77c 100644 --- a/apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts +++ b/apps/judicial-system/api/src/app/modules/case/interceptors/case.transformer.spec.ts @@ -540,107 +540,56 @@ describe('getAppealInfo', () => { expect(appealInfo).toEqual({}) }) - it('should return correct appeal info when ruling date is provided', () => { + it('should return not return appealedDate if case has not been appealed', () => { const rulingDate = new Date().toISOString() const theCase = { type: CaseType.CUSTODY, rulingDate, - appealState: CaseAppealState.APPEALED, - accusedAppealDecision: CaseAppealDecision.APPEAL, - prosecutorAppealDecision: CaseAppealDecision.NOT_APPLICABLE, + appealState: undefined, + accusedAppealDecision: CaseAppealDecision.POSTPONE, + prosecutorAppealDecision: CaseAppealDecision.POSTPONE, accusedPostponedAppealDate: '2022-06-15T19:50:08.033Z', - appealReceivedByCourtDate: '2021-06-15T19:50:08.033Z', + prosecutorPostponedAppealDate: '2022-06-15T19:50:08.033Z', } as Case const appealInfo = getAppealInfo(theCase) expect(appealInfo).toEqual({ - canBeAppealed: false, - hasBeenAppealed: true, - appealedByRole: UserRole.DEFENDER, - appealedDate: '2022-06-15T19:50:08.033Z', + canBeAppealed: true, + hasBeenAppealed: false, appealDeadline: new Date( new Date(rulingDate).setDate(new Date(rulingDate).getDate() + 3), ).toISOString(), - statementDeadline: '2021-06-16T19:50:08.033Z', - canDefenderAppeal: false, - canProsecutorAppeal: false, - }) - }) - - const rulingDate = new Date().toISOString() - - Object.values(CaseAppealDecision).forEach((decision) => { - const expected = - decision === CaseAppealDecision.POSTPONE || - decision === CaseAppealDecision.NOT_APPLICABLE - - test(`canProsecutorAppeal for appeal decision ${decision} should return ${expected}`, () => { - const theCase = { - type: CaseType.CUSTODY, - rulingDate, - prosecutorAppealDecision: decision, - } as Case - - const appealInfo = getAppealInfo(theCase) - - expect(appealInfo).toHaveProperty('canProsecutorAppeal', expected) - }) - }) - - Object.values(CaseAppealDecision).forEach((decision) => { - const expected = - decision === CaseAppealDecision.POSTPONE || - decision === CaseAppealDecision.NOT_APPLICABLE - - test(`canDefenderAppeal for appeal decision ${decision} should return ${expected}`, () => { - const theCase = { - type: CaseType.CUSTODY, - rulingDate, - accusedAppealDecision: decision, - } as Case - - const appealInfo = getAppealInfo(theCase) - - expect(appealInfo).toHaveProperty('canDefenderAppeal', expected) + canDefenderAppeal: true, + canProsecutorAppeal: true, }) }) -}) - -describe('getAppealInfo', () => { - it('should return empty appeal info when ruling date is not provided', () => { - // Arrange - const theCase = { type: CaseType.CUSTODY } as Case - - // Act - const appealInfo = getAppealInfo(theCase) - - // Assert - expect(appealInfo).toEqual({}) - }) - it('should return not return appealedDate if case has not been appealed', () => { + it('should return correct appeal info when ruling date is provided', () => { const rulingDate = new Date().toISOString() const theCase = { type: CaseType.CUSTODY, rulingDate, - appealState: undefined, - accusedAppealDecision: CaseAppealDecision.POSTPONE, - prosecutorAppealDecision: CaseAppealDecision.POSTPONE, + appealState: CaseAppealState.APPEALED, + accusedAppealDecision: CaseAppealDecision.APPEAL, + prosecutorAppealDecision: CaseAppealDecision.NOT_APPLICABLE, accusedPostponedAppealDate: '2022-06-15T19:50:08.033Z', - prosecutorPostponedAppealDate: '2022-06-15T19:50:08.033Z', + appealReceivedByCourtDate: '2021-06-15T19:50:08.033Z', } as Case const appealInfo = getAppealInfo(theCase) expect(appealInfo).toEqual({ - canBeAppealed: true, - hasBeenAppealed: false, + canBeAppealed: false, + hasBeenAppealed: true, + appealedByRole: UserRole.DEFENDER, + appealedDate: '2022-06-15T19:50:08.033Z', appealDeadline: new Date( new Date(rulingDate).setDate(new Date(rulingDate).getDate() + 3), ).toISOString(), - canDefenderAppeal: true, - canProsecutorAppeal: true, + statementDeadline: '2021-06-16T19:50:08.033Z', + canDefenderAppeal: false, + canProsecutorAppeal: false, }) })