Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 17, 2019
1 parent cf7d078 commit ddcdc25
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion test/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })),
)
16 changes: 12 additions & 4 deletions test/helpers/methods.js
Original file line number Diff line number Diff line change
@@ -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' },
Expand All @@ -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,
]
3 changes: 2 additions & 1 deletion test/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })),
)

0 comments on commit ddcdc25

Please sign in to comment.