generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.test.js
21 lines (19 loc) · 894 Bytes
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const cp = require('node:child_process')
const path = require('node:path')
const process = require('node:process')
const test = require('ava')
test('test runs without default value', (t) => {
process.env.INPUT_ALLOWED = 'hello,world'
process.env.GITHUB_EVENT_PATH = path.join(__dirname, '.tests/context.json')
const ip = path.join(__dirname, 'index.js')
const output = cp.execSync(`node ${ip}`, {env: process.env, encoding: 'utf8'})
t.is(output, '\n::set-output name=match::hello\n')
})
test('test runs with default value', (t) => {
process.env.INPUT_ALLOWED = 'goodbye'
process.env.INPUT_DEFAULT_MATCH = 'default'
process.env.GITHUB_EVENT_PATH = path.join(__dirname, '.tests/context.json')
const ip = path.join(__dirname, 'index.js')
const output = cp.execSync(`node ${ip}`, {env: process.env, encoding: 'utf8'})
t.is(output, '\n::set-output name=match::default\n')
})