|
'use strict'; |
|
|
|
var Test = require('../test'); |
|
var EVENT_FILE_PRE_REQUIRE = require('../suite').constants |
|
.EVENT_FILE_PRE_REQUIRE; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function qUnitInterface(suite) { |
|
var suites = [suite]; |
|
|
|
suite.on(EVENT_FILE_PRE_REQUIRE, function(context, file, mocha) { |
|
var common = require('./common')(suites, context, mocha); |
|
|
|
context.before = common.before; |
|
context.after = common.after; |
|
context.beforeEach = common.beforeEach; |
|
context.afterEach = common.afterEach; |
|
context.run = mocha.options.delay && common.runWithSuite(suite); |
|
|
|
|
|
|
|
|
|
context.suite = function(title) { |
|
if (suites.length > 1) { |
|
suites.shift(); |
|
} |
|
return common.suite.create({ |
|
title: title, |
|
file: file, |
|
fn: false |
|
}); |
|
}; |
|
|
|
|
|
|
|
|
|
|
|
context.suite.only = function(title) { |
|
if (suites.length > 1) { |
|
suites.shift(); |
|
} |
|
return common.suite.only({ |
|
title: title, |
|
file: file, |
|
fn: false |
|
}); |
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context.test = function(title, fn) { |
|
var test = new Test(title, fn); |
|
test.file = file; |
|
suites[0].addTest(test); |
|
return test; |
|
}; |
|
|
|
|
|
|
|
|
|
|
|
context.test.only = function(title, fn) { |
|
return common.test.only(mocha, context.test(title, fn)); |
|
}; |
|
|
|
context.test.skip = common.test.skip; |
|
}); |
|
}; |
|
|
|
module.exports.description = 'QUnit style'; |
|
|