test context

This commit is contained in:
Michael Shick 2019-11-22 18:31:48 -05:00
parent 3d8df2a501
commit 39f095d176
No known key found for this signature in database
GPG key ID: ADF5BC9704BB4A61
7 changed files with 270 additions and 80 deletions

View file

@ -1,23 +1,23 @@
const wait = require('./wait');
const process = require('process');
const cp = require('child_process');
const path = require('path');
// const wait = require("./wait");
const process = require("process");
const cp = require("child_process");
const path = require("path");
test('throws invalid number', async() => {
await expect(wait('foo')).rejects.toThrow('milleseconds not a number');
});
// 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 - start);
expect(delta).toBeGreaterThan(450);
});
// test("wait 500 ms", async () => {
// const start = new Date();
// await wait(500);
// const end = new Date();
// var delta = Math.abs(end - start);
// 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, 'index.js');
console.log(cp.execSync(`node ${ip}`).toString());
})
test("test runs", () => {
const env = { INPUT_MSG: "Hello world!", INPUT_GITHUB_TOKEN: "abc123" };
const ip = path.join(__dirname, "index.js");
console.log(cp.execSync(`node ${ip}`, { env }).toString());
});