mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-01-24 20:12:15 +01:00
Refactor: directory structure (#31)
* config: update version * refactor: move source codes to lib directory, Close #30 * refactor: move test code
This commit is contained in:
23
__tests__/index.test.js
Normal file
23
__tests__/index.test.js
Normal file
@@ -0,0 +1,23 @@
|
||||
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());
|
||||
})
|
||||
Reference in New Issue
Block a user