feat: Add getOS()

This commit is contained in:
peaceiris 2019-09-18 09:59:07 +09:00
parent 4b6109cfb2
commit 86eb62d73e
5 changed files with 35 additions and 26 deletions

17
__tests__/get-os.test.js Normal file
View file

@ -0,0 +1,17 @@
const getOS = require("../lib/get-os");
describe("getOS", () => {
test("test", () => {
expect(getOS("linux")).toBe("Linux");
expect(getOS("darwin")).toBe("macOS");
});
test("test exception", () => {
expect(() => {
getOS("win32");
}).toThrowError("Windows is not supported");
expect(() => {
getOS("centos");
}).toThrowError("centos is not supported");
});
});

View file

@ -1,23 +0,0 @@
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('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());
})