From ddcdc259118c52f60cbdf1c6777d241448c4eaca Mon Sep 17 00:00:00 2001 From: ehmicky Date: Fri, 17 May 2019 10:00:00 +0200 Subject: [PATCH] Refactor tests --- test/exec.js | 3 ++- test/helpers/methods.js | 16 ++++++++++++---- test/task.js | 3 ++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/test/exec.js b/test/exec.js index 5bb1a36..ea01d30 100644 --- a/test/exec.js +++ b/test/exec.js @@ -2,7 +2,8 @@ import test from 'ava' import { testEach } from './helpers/test_each/main.js' import { snapshotTest } from './helpers/snapshot.js' +import { EXEC_METHODS } from './helpers/methods.js' -testEach([{}], (suffix, data) => +testEach(EXEC_METHODS, [{}], (suffix, data) => test(`exec() ${suffix}`, t => snapshotTest({ t, data })), ) diff --git a/test/helpers/methods.js b/test/helpers/methods.js index 62db166..cee9856 100644 --- a/test/helpers/methods.js +++ b/test/helpers/methods.js @@ -1,4 +1,14 @@ // We repeat most tests for each API method +export const EXEC_METHODS = [ + // `exec(...)` + { suffix: 'exec', method: 'exec' }, +] + +export const TASK_METHODS = [ + // `task(...)` + { suffix: 'task', method: 'task' }, +] + export const STREAM_METHODS = [ // `gulp.src(...).pipe(stream(..., { result: 'replace' }))` { suffix: 'stream-buffer', method: 'stream' }, @@ -9,9 +19,7 @@ export const STREAM_METHODS = [ ] export const METHODS = [ - // `exec(...)` - { suffix: 'exec', method: 'exec' }, - // `task(...)` - { suffix: 'task', method: 'task' }, + ...EXEC_METHODS, + ...TASK_METHODS, ...STREAM_METHODS, ] diff --git a/test/task.js b/test/task.js index 0fd3965..e415a5a 100644 --- a/test/task.js +++ b/test/task.js @@ -2,8 +2,9 @@ import test from 'ava' import { testEach } from './helpers/test_each/main.js' import { snapshotTest } from './helpers/snapshot.js' +import { TASK_METHODS } from './helpers/methods.js' -testEach([{}, { task: 'nested' }], (suffix, data) => +testEach(TASK_METHODS, [{}, { task: 'nested' }], (suffix, data) => test(`task() ${suffix}`, t => snapshotTest({ t, methodProps: { method: 'task' }, data })), )