Skip to content

Commit

Permalink
For Before and After functions the first argument is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
dex4er committed Sep 29, 2017
1 parent ad0bbbd commit 2c90cf9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -86,6 +86,8 @@ context for its steps then real `function () {}` might be used instead arrow
`Before`, `beforeEach`, `After` and `afterEach` functions are also provided
and are optional.

For `Before` and `After` functions the first argument is optional.

All functions except `BeforeEach` and `AfterEach` add some prefix to the
description of the step.

Expand Down
14 changes: 12 additions & 2 deletions lib/tap-given.js
Expand Up @@ -26,10 +26,20 @@ function tapGiven (t) {
}

global.Before = (what, how) => {
return t.mocha.before('Before ' + what, how)
if (typeof what === 'string') {
return t.mocha.before('Before ' + what, how)
} else {
how = what
return t.mocha.before('Before', how)
}
}
global.After = (what, how) => {
return t.mocha.after('After ' + what, how)
if (typeof what === 'string') {
return t.mocha.before('After ' + what, how)
} else {
how = what
return t.mocha.before('After', how)
}
}

global.BeforeEach = t.mocha.beforeEach
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "tap-given",
"version": "0.5.2",
"version": "0.6.0",
"description": "Given-When-Then BDD for TAP",
"main": "lib/tap-given.js",
"typings": "lib/tap-given.d.ts",
Expand Down

0 comments on commit 2c90cf9

Please sign in to comment.