mirror of
https://github.com/actions/typescript-action.git
synced 2026-01-18 16:01:24 +08:00
update with tests
This commit is contained in:
@@ -1,3 +1,23 @@
|
||||
describe('TODO - Add a test suite', () => {
|
||||
it('TODO - Add a test', async () => {});
|
||||
import {wait} from '../src/wait'
|
||||
import * as process from 'process'
|
||||
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');
|
||||
});
|
||||
|
||||
test('wait 500 ms', async() => {
|
||||
const start = new Date();
|
||||
await wait(500);
|
||||
const end = new Date();
|
||||
var delta = Math.abs(end.getTime() - start.getTime());
|
||||
expect(delta).toBeGreaterThan(450);
|
||||
});
|
||||
|
||||
// shows how the runner will run a javascript action with env / stdout protocol
|
||||
test('test runs', () => {
|
||||
process.env['INPUT_MILLISECONDS'] = '500';
|
||||
const ip = path.join(__dirname, '..', 'lib', 'main.js');
|
||||
console.log(cp.execSync(`node ${ip}`).toString());
|
||||
})
|
||||
Reference in New Issue
Block a user