diff options
| author | HumairAK <humair88@hotmail.com> | 2016-07-26 07:43:04 +0000 |
|---|---|---|
| committer | HumairAK <humair88@hotmail.com> | 2016-07-26 07:43:04 +0000 |
| commit | f016bdbc35b7efa44bd63413bde09433ea916c59 (patch) | |
| tree | 238a4ffbd447907876b2f1624cdb6f4abc3009eb /node_modules/mocha/lib/interfaces/common.js | |
| parent | 10f1c442e27d82d1fc2c94d1bc0a2ad27917b287 (diff) | |
added some unit testing, need a lot more
Diffstat (limited to 'node_modules/mocha/lib/interfaces/common.js')
| -rw-r--r-- | node_modules/mocha/lib/interfaces/common.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/node_modules/mocha/lib/interfaces/common.js b/node_modules/mocha/lib/interfaces/common.js new file mode 100644 index 0000000..db93908 --- /dev/null +++ b/node_modules/mocha/lib/interfaces/common.js @@ -0,0 +1,85 @@ +'use strict'; + +/** + * Functions common to more than one interface. + * + * @param {Suite[]} suites + * @param {Context} context + * @return {Object} An object containing common functions. + */ +module.exports = function(suites, context) { + return { + /** + * This is only present if flag --delay is passed into Mocha. It triggers + * root suite execution. + * + * @param {Suite} suite The root wuite. + * @return {Function} A function which runs the root suite + */ + runWithSuite: function runWithSuite(suite) { + return function run() { + suite.run(); + }; + }, + + /** + * Execute before running tests. + * + * @param {string} name + * @param {Function} fn + */ + before: function(name, fn) { + suites[0].beforeAll(name, fn); + }, + + /** + * Execute after running tests. + * + * @param {string} name + * @param {Function} fn + */ + after: function(name, fn) { + suites[0].afterAll(name, fn); + }, + + /** + * Execute before each test case. + * + * @param {string} name + * @param {Function} fn + */ + beforeEach: function(name, fn) { + suites[0].beforeEach(name, fn); + }, + + /** + * Execute after each test case. + * + * @param {string} name + * @param {Function} fn + */ + afterEach: function(name, fn) { + suites[0].afterEach(name, fn); + }, + + test: { + /** + * Pending test case. + * + * @param {string} title + */ + skip: function(title) { + context.test(title); + }, + + /** + * Number of retry attempts + * + * @param {number} n + */ + retries: function(n) { + context.retries(n); + } + } + }; +}; |
