mirror of
https://github.com/rharkor/caching-for-turbo.git
synced 2025-06-11 18:20:24 +09:00
first commit
This commit is contained in:
commit
aa211c7f9d
35 changed files with 35469 additions and 0 deletions
25
__tests__/wait.test.ts
Normal file
25
__tests__/wait.test.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* Unit tests for src/wait.ts
|
||||
*/
|
||||
|
||||
import { wait } from '../src/wait'
|
||||
import { expect } from '@jest/globals'
|
||||
|
||||
describe('wait.ts', () => {
|
||||
it('throws an invalid number', async () => {
|
||||
const input = parseInt('foo', 10)
|
||||
expect(isNaN(input)).toBe(true)
|
||||
|
||||
await expect(wait(input)).rejects.toThrow('milliseconds not a number')
|
||||
})
|
||||
|
||||
it('waits with a valid number', async () => {
|
||||
const start = new Date()
|
||||
await wait(500)
|
||||
const end = new Date()
|
||||
|
||||
const delta = Math.abs(end.getTime() - start.getTime())
|
||||
|
||||
expect(delta).toBeGreaterThan(450)
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue