Fix example tests (#32)
This commit is contained in:
parent
c125c0f784
commit
01408a6ef7
|
@ -4,7 +4,8 @@ import * as cp from 'child_process'
|
|||
import * as path from 'path'
|
||||
|
||||
test('throws invalid number', async() => {
|
||||
await expect(wait('foo')).rejects.toThrow('milleseconds not a number');
|
||||
const input = parseInt('foo', 10);
|
||||
await expect(wait(input)).rejects.toThrow('milleseconds not a number');
|
||||
});
|
||||
|
||||
test('wait 500 ms', async() => {
|
||||
|
@ -19,5 +20,8 @@ test('wait 500 ms', async() => {
|
|||
test('test runs', () => {
|
||||
process.env['INPUT_MILLISECONDS'] = '500';
|
||||
const ip = path.join(__dirname, '..', 'lib', 'main.js');
|
||||
console.log(cp.execSync(`node ${ip}`).toString());
|
||||
})
|
||||
const options: cp.ExecSyncOptions = {
|
||||
env: process.env
|
||||
};
|
||||
console.log(cp.execSync(`node ${ip}`, options).toString());
|
||||
});
|
|
@ -7,7 +7,7 @@ async function run() {
|
|||
console.log(`Waiting ${ms} milliseconds ...`)
|
||||
|
||||
core.debug((new Date()).toTimeString())
|
||||
await wait(parseInt(ms));
|
||||
await wait(parseInt(ms, 10));
|
||||
core.debug((new Date()).toTimeString())
|
||||
|
||||
core.setOutput('time', new Date().toTimeString());
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export function wait(milliseconds) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof(milliseconds) !== 'number') {
|
||||
throw new Error('milleseconds not a number');
|
||||
export function wait(milliseconds: number) {
|
||||
return new Promise((resolve) => {
|
||||
if (isNaN(milliseconds)) {
|
||||
throw new Error('milleseconds not a number');
|
||||
}
|
||||
|
||||
setTimeout(() => resolve("done!"), milliseconds)
|
||||
|
|
Loading…
Reference in New Issue