Skip to content

Commit

Permalink
fix discontinued state
Browse files Browse the repository at this point in the history
  • Loading branch information
andrej-dyck committed May 5, 2024
1 parent 3018c8f commit feb4a22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/endoflife.date.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,10 @@ describe('cycle-state', () => {
cycle: { cycle: '4', eol: futureDate, discontinued: earlierDate },
expectedState: { state: 'discontinued', onDate: earlierDate, supportEndDate: futureDate } satisfies CycleState,
},
{
cycle: { cycle: '4', eol: futureDate, discontinued: now },
expectedState: { state: 'discontinued', onDate: now, supportEndDate: futureDate } satisfies CycleState,
},
])('discontinued; %j', ({ cycle, expectedState }) => {
expect(cycleState(cycle)(now)).toEqual(expectedState)
})
Expand Down
2 changes: 1 addition & 1 deletion src/endoflife.date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const cycleState = (cycle: Cycle) => (now: Date): CycleState => {
isDate(support) ? support : undefined

const isDiscontinued = (discontinued: Cycle['discontinued']) =>
discontinued === true || (isDate(discontinued) && discontinued < now)
discontinued === true || (isDate(discontinued) && discontinued <= now)

const discontinuedDate = ({ discontinued }: Pick<Cycle, 'discontinued'>) =>
isDate(discontinued) ? discontinued : undefined
Expand Down

0 comments on commit feb4a22

Please sign in to comment.