Skip to content

Commit

Permalink
Update readingTime.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
trueberryless authored Nov 11, 2024
1 parent cac051c commit f79c049
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/starlight-blog/tests/unit/basics/readingTime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,21 @@ describe('getReadingTime', () => {
test('show reading time, set by frontmatter', () => {
expect(getReadingTime(postWithTime)).toBe({ showReadingTime: true, readingTime: 12 })
})
})

describe('formatReadingTime', () => {
test('get minutes', () => {
expect(formatReadingTime(0).toBe("0 min")
expect(formatReadingTime(1).toBe("1 min")
})

test('get hours', () => {
expect(formatReadingTime(60).toBe("1 h")
expect(formatReadingTime(120).toBe("2 h")
})

test('get minutes and hours', () => {
expect(formatReadingTime(61).toBe("1h 1min")
expect(formatReadingTime(231).toBe("3h 51min")
})
})

0 comments on commit f79c049

Please sign in to comment.