mirror of
https://github.com/actions/javascript-action.git
synced 2025-12-11 05:07:02 +00:00
Restructure source and tests
This commit is contained in:
24
__tests__/wait.test.js
Normal file
24
__tests__/wait.test.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Unit tests for src/wait.ts
|
||||
*/
|
||||
const { wait } = require('../src/wait')
|
||||
const { expect } = require('@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)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user