Skip to content

Commit

Permalink
fix: failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alaa-yahia committed Aug 27, 2024
1 parent 2ac85b8 commit 1b9a1ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/utils/validate-date-string.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('validateDateString (gregory)', () => {

it('should return an error message for a date with mixed delimiters', () => {
expect(validateDateString('2024/02.02').errorMessage).toBe(
'Date string is invalid, received "2024/02.02"'
'Date string is invalid, received "2024/02.02"'
)
})

Expand Down Expand Up @@ -225,28 +225,28 @@ describe('validateDateString (ethiopic)', () => {
expect(
validateDateString('2015.13/06', { calendar: 'ethiopic' })
.errorMessage
).toBe('Date string is invalid, received "2015.13/06"')
).toBe('Date string is invalid, received "2015.13/06"')
})

it('should return an error message for a date missing year digits', () => {
expect(
validateDateString('201.13/06', { calendar: 'ethiopic' })
.errorMessage
).toBe('Date string is invalid, received "201.13/06"')
).toBe('Date string is invalid, received "201.13/06"')
})

it('should return an error message for a date missing month digits', () => {
expect(
validateDateString('201.1/06', { calendar: 'ethiopic' })
.errorMessage
).toBe('Date string is invalid, received "201.1/06"')
).toBe('Date string is invalid, received "201.1/06"')
})

it('should return an error message for a date missing day digits', () => {
expect(
validateDateString('2015.13/6', { calendar: 'ethiopic' })
.errorMessage
).toBe('Date string is invalid, received "2015.13/6"')
).toBe('Date string is invalid, received "2015.13/6"')
})

it('should return an error message when the value is out of range', () => {
Expand Down Expand Up @@ -280,7 +280,7 @@ describe('validateDateString (nepali)', () => {
expect(
validateDateString('2080.10/29', { calendar: 'nepali' })
.errorMessage
).toBe('Date string is invalid, received "2080.10/29"')
).toBe('Date string is invalid, received "2080.10/29"')
})

it('should return an error message for a date missing year digits', () => {
Expand All @@ -305,14 +305,14 @@ describe('validateDateString (nepali)', () => {
expect(
validateDateString('2080.04.33', { calendar: 'nepali' })
.errorMessage
).toBe('Day 33 is out of range: 1 <= 33 <= 32.')
).toBe('Day 33 is out of range | 1 <= 33 <= 32.')
})

it('should return an error message when month is out of range', () => {
expect(
validateDateString('2080.13.33', { calendar: 'nepali' })
.errorMessage
).toBe('Month 13 is out of range: 1 <= 13 <= 12.')
).toBe('Month 13 is out of range | 1 <= 13 <= 12.')
})

it('should return an error message when year is out of supported range', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/validate-date-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function validateNepaliDate(year: number, month: number, day: number) {
isValid: false,
errorMessage: i18n.t(
`Day {{day}} is out of range | 1 <= {{day}} <= {{daysInMonth}}.`,
{ day }
{ day, daysInMonth }
),
}
}
Expand Down

0 comments on commit 1b9a1ad

Please sign in to comment.