-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
97 revised plan year end date display (#98)
* working on end dates for prior years * update coverage end date showing for previous year policies * Remove unused pipe * Update operator to be less than current year * update template to use new pipe for policyEndDate check and format * add unit test for policy-end-date format * update pipe with performance improvement
- Loading branch information
Showing
5 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
libs/carrier-portal/ui/src/lib/pipes/policy-end-date.pipe.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { PolicyEndDatePipe } from './policy-end-date.pipe'; | ||
|
||
describe('PolicyEndDatePipe', () => { | ||
let pipe: PolicyEndDatePipe; | ||
const currentYear = new Date(); | ||
const thisYear = currentYear.toString(); | ||
const futureYear = (currentYear.getFullYear() + 1).toString(); | ||
const previousYear = (currentYear.getFullYear() - 1).toString(); | ||
|
||
beforeEach(() => { | ||
pipe = new PolicyEndDatePipe(); | ||
}); | ||
|
||
it('returns an empty string if the current year is equal to the given year', () => { | ||
const policyStartDate = thisYear; | ||
expect(pipe.transform(policyStartDate)).toBe(''); | ||
}); | ||
|
||
it('returns an empty string if the current year is greater than the given year', () => { | ||
const policyStartDate = futureYear; | ||
expect(pipe.transform(policyStartDate)).toBe(''); | ||
}); | ||
|
||
it('returns the last day of the year for the given date if the given year is less than the current year', () => { | ||
// const policyStartDate = '2021-03-01'; | ||
const policyStartDate = previousYear; | ||
expect(pipe.transform(policyStartDate)).toBe( | ||
`12/31/${previousYear.substring(2, 4)}` | ||
); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
libs/carrier-portal/ui/src/lib/pipes/policy-end-date.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
|
||
type DateString = string; | ||
|
||
@Pipe({ | ||
name: 'policyEndDate', | ||
standalone: true, | ||
}) | ||
export class PolicyEndDatePipe implements PipeTransform { | ||
currentYear = new Date().getFullYear().toString().substring(2, 4); | ||
transform(value: DateString) { | ||
const policyStartYear = value.substring(2, 4); | ||
|
||
return policyStartYear < this.currentYear ? `12/31/${policyStartYear}` : ''; | ||
} | ||
} |