-
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.
- Loading branch information
Showing
7 changed files
with
5,389 additions
and
6,316 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
import { expectInteger } from './expectInteger'; | ||
|
||
describe('expectInteger', () => { | ||
test('should return the number if it is an integer', () => { | ||
const input = 42; | ||
const result = expectInteger(input, ''); | ||
expect(result).toBe(input); | ||
}); | ||
|
||
test('should throw an error if the number is not an integer', () => { | ||
const input = 3.14; | ||
const errorMessage = 'Input must be an integer'; | ||
expect(() => expectInteger(input, errorMessage)).toThrow(errorMessage); | ||
}); | ||
|
||
test('should use the default error message if no error message is provided', () => { | ||
const input = 2.5; | ||
expect(() => expectInteger(input)).toThrow('Not an integer'); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
import { renderDuration } from './renderDuration'; | ||
|
||
describe('renderDuration', () => { | ||
test('should return the duration in milliseconds for values less than 1000', () => { | ||
expect(renderDuration(500)).toBe('500ms'); | ||
expect(renderDuration(0)).toBe('0ms'); | ||
}); | ||
|
||
test('should return the duration in seconds for values between 1000 and 60000', () => { | ||
expect(renderDuration(1000)).toBe('1s'); | ||
expect(renderDuration(30000)).toBe('30s'); | ||
expect(renderDuration(59000)).toBe('59s'); | ||
}); | ||
|
||
test('should return the duration in minutes for values between 60000 and 3600000', () => { | ||
expect(renderDuration(60000)).toBe('1m'); | ||
expect(renderDuration(80000)).toBe('1m'); | ||
expect(renderDuration(120000)).toBe('2m'); | ||
expect(renderDuration(3540000)).toBe('59m'); | ||
}); | ||
|
||
test('should return the duration in hours and minutes for values greater than 3600000', () => { | ||
expect(renderDuration(3600000)).toBe('1h:00m'); | ||
expect(renderDuration(7200000)).toBe('2h:00m'); | ||
expect(renderDuration(10800000)).toBe('3h:00m'); | ||
expect(renderDuration(86400000)).toBe('24h:00m'); | ||
}); | ||
|
||
test('should handle negative values by prefixing with a minus sign', () => { | ||
expect(renderDuration(-500)).toBe('-500ms'); | ||
expect(renderDuration(-60000)).toBe('-1m'); | ||
expect(renderDuration(-3600000)).toBe('-1h:00m'); | ||
}); | ||
}); |
File renamed without changes.
Oops, something went wrong.