forked from ajnart/homarr
-
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
17 changed files
with
1,414 additions
and
60 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
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 was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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,27 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { percentage } from './percentage.tool'; | ||
|
||
describe('percentage', () => { | ||
it.concurrent('be fixed value', () => { | ||
// arrange | ||
const value = 62; | ||
|
||
// act | ||
const fixedPercentage = percentage(value, 100); | ||
|
||
// assert | ||
expect(fixedPercentage).toBe('62.0'); | ||
}); | ||
|
||
it.concurrent('be fixed value when decimal places', () => { | ||
// arrange | ||
const value = 42.69696969; | ||
|
||
// act | ||
const fixedPercentage = percentage(value, 100); | ||
|
||
// assert | ||
expect(fixedPercentage).toBe('42.7'); | ||
}); | ||
}); |
File renamed without changes.
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,47 @@ | ||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
||
import { isToday } from './date.tool'; | ||
|
||
describe('isToday', () => { | ||
beforeEach(() => { | ||
vi.useFakeTimers(); | ||
}); | ||
|
||
afterEach(() => { | ||
vi.useRealTimers(); | ||
}); | ||
|
||
it.concurrent('should return true if date is today', () => { | ||
// arrange | ||
const date = new Date(2022, 3, 17); | ||
vi.setSystemTime(date); | ||
|
||
// act | ||
const today = isToday(date); | ||
|
||
// assert | ||
expect(today).toBe(true); | ||
}); | ||
|
||
it.concurrent("should return true if date is today and time doesn't match", () => { | ||
// arrange | ||
vi.setSystemTime(new Date(2022, 3, 17, 16, 25, 11)); | ||
|
||
// act | ||
const today = isToday(new Date(2022, 3, 17)); | ||
|
||
// assert | ||
expect(today).toBe(true); | ||
}); | ||
|
||
it.concurrent("should be false if date doesn't match", () => { | ||
// arrange | ||
vi.setSystemTime(new Date(2022, 3, 17, 16)); | ||
|
||
// act | ||
const today = isToday(new Date(2022, 3, 15)); | ||
|
||
// assert | ||
expect(today).toBe(false); | ||
}); | ||
}); |
File renamed without changes.
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,26 @@ | ||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
||
import { Stopwatch } from './stopwatch.tool'; | ||
|
||
describe('stopwatch', () => { | ||
beforeEach(() => { | ||
vi.useFakeTimers(); | ||
}); | ||
|
||
afterEach(() => { | ||
vi.useRealTimers(); | ||
}); | ||
|
||
it.concurrent('should be elapsed time between start and current', () => { | ||
// arrange | ||
vi.setSystemTime(new Date(2023, 2, 26, 0, 0, 0)); | ||
const stopwatch = new Stopwatch(); | ||
|
||
// act | ||
vi.setSystemTime(new Date(2023, 2, 26, 0, 0, 2)); | ||
const milliseconds = stopwatch.getEllapsedMilliseconds(); | ||
|
||
// assert | ||
expect(milliseconds).toBe(2000); | ||
}); | ||
}); |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import react from '@vitejs/plugin-react'; | ||
|
||
import { defineConfig } from 'vitest/config'; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
test: { | ||
environment: 'jsdom', | ||
}, | ||
}); |
Oops, something went wrong.