Skip to content

Commit

Permalink
refactor(util): get/setters cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Apr 1, 2017
1 parent f24d2d7 commit 93dc84e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 20 deletions.
49 changes: 34 additions & 15 deletions lib/util.js
Expand Up @@ -9,31 +9,50 @@
* file that was distributed with this source code.
*/

const util = exports = module.exports = {}

let DEFAULT_TIMEOUT = 2000
let BAIL_TESTS = false

util.verb = function (count) {
return count === 1 ? '' : 's'
}
const util = exports = module.exports = {
get timeout () {
return DEFAULT_TIMEOUT
},

util.setTimeout = function (timeout) {
DEFAULT_TIMEOUT = timeout
}
set timeout (timeout) {
DEFAULT_TIMEOUT = timeout
},

util.getTimeout = function () {
return DEFAULT_TIMEOUT
}
get bail () {
return BAIL_TESTS
},

util.setBail = function (state) {
BAIL_TESTS = !!state
set bail (state) {
BAIL_TESTS = !!state
}
}

util.getBail = function () {
return BAIL_TESTS
/**
* The `s` verb to be used by checking the
* count. The simplest way to append `s`
* to statement to make it plural only
* when count is not = 1.
*
* @method verb
*
* @param {Number} count
*
* @return {String}
*/
util.verb = function (count) {
return count === 1 ? '' : 's'
}

/**
* List of events emitted by Japa
*
* @method getEventsList
*
* @return {Object}
*/
util.getEventsList = function () {
return {
GROUP_START: 'group:start',
Expand Down
2 changes: 1 addition & 1 deletion src/Hook.js
Expand Up @@ -19,7 +19,7 @@ class Hook {
this._title = groupTitle
this._hookFor = hookFor
this._callback = callback
this._timeout = $.getTimeout()
this._timeout = $.timeout
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware.js
Expand Up @@ -15,7 +15,7 @@ class Middleware {

constructor (context, fnWrapper) {
this._context = context
this._bail = $.getBail()
this._bail = $.bail
this._fnWrapper = fnWrapper
this._stack = []
this.errorsStack = []
Expand Down
4 changes: 2 additions & 2 deletions src/Runner.js
Expand Up @@ -250,7 +250,7 @@ class Runner {
* @param {Boolean} state
*/
bail (state) {
$.setBail(state)
$.bail = state
}

/**
Expand All @@ -259,7 +259,7 @@ class Runner {
* @param {Number} time
*/
timeout (time) {
$.setTimeout(time)
$.timeout = time
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Test.js
Expand Up @@ -23,7 +23,7 @@ class Test {
this._title = title
this._skip = !!skip
this._todo = typeof (callback) !== 'function'
this._timeout = $.getTimeout()
this._timeout = $.timeout
this._callback = callback
this._regression = !!expectedToFail
this._regressionMessage = null
Expand Down

0 comments on commit 93dc84e

Please sign in to comment.