Skip to content

Commit

Permalink
Add test for task name
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 17, 2019
1 parent b2df067 commit 01fcfc4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/helpers/gulpfiles/task.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { parallel } from 'gulp'

import { task } from '../../../src/main.js'

import { getInput } from './input.js'

const { command, opts } = getInput()

export const main = task(command, opts)

export const nested = parallel(main)
18 changes: 17 additions & 1 deletion test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,30 @@ METHODS.forEach(methodProps => {
})
})

test('should use the command as task name', async t => {
const { exitCode, stdout, stderr } = await fireTask({
method: 'task',
task: 'nested',
command: 'echo test'
})
// eslint-disable-next-line no-restricted-globals, no-console
console.log(exitCode)
// eslint-disable-next-line no-restricted-globals, no-console
console.log(stdout)
// eslint-disable-next-line no-restricted-globals, no-console
console.log(stderr)
t.pass()
})

const fireTask = async function({
method,
task = 'main',
execaOpts: { env, ...execaOpts } = {},
...input
}) {
const inputA = JSON.stringify(input)
const { exitCode, stdout, stderr } = await execa(
`gulp --gulpfile ${GULPFILES_DIR}/${method}.js main`,
`gulp --gulpfile ${GULPFILES_DIR}/${method}.js ${task}`,
{ reject: false, env: { INPUT: inputA, CI: '', ...env }, ...execaOpts },
)
const stdoutA = normalizeMessage(stdout)
Expand Down

0 comments on commit 01fcfc4

Please sign in to comment.