mirror of
https://github.com/auchenberg/volkswagen
synced 2025-04-30 15:07:57 +02:00
70 lines
1.3 KiB
JavaScript
70 lines
1.3 KiB
JavaScript
'use strict'
|
|
|
|
var isCI = require('is-ci')
|
|
var noop = function () {}
|
|
|
|
if (isCI) defeat()
|
|
|
|
function defeat () {
|
|
assert()
|
|
try {
|
|
tap(require('tap/lib/test'))
|
|
} catch (e) {}
|
|
try {
|
|
tape(require('tape/lib/test'))
|
|
} catch (e) {}
|
|
}
|
|
|
|
function assert () {
|
|
var ok = function () {}
|
|
ok.ok = noop
|
|
ok.fail = noop
|
|
ok.equal = noop
|
|
ok.notEqual = noop
|
|
ok.deepEqual = noop
|
|
ok.notDeepEqual = noop
|
|
ok.strictEqual = noop
|
|
ok.notStrictEqual = noop
|
|
ok.deepStrictEqual = noop
|
|
ok.notDeepStrictEqual = noop
|
|
ok.ifError = noop
|
|
ok.throws = function (block, error) {
|
|
try {
|
|
block()
|
|
} catch (e) {
|
|
if (typeof error === 'function') error()
|
|
}
|
|
}
|
|
ok.doesNotThrow = function (block) {
|
|
try {
|
|
block()
|
|
} catch (e) {}
|
|
}
|
|
|
|
var mockery = require('mockery')
|
|
mockery.enable({
|
|
warnOnReplace: false,
|
|
warnOnUnregistered: false
|
|
})
|
|
mockery.registerMock('assert', ok)
|
|
}
|
|
|
|
function tap (Test) {
|
|
Test.prototype.fail = Test.prototype.pass
|
|
}
|
|
|
|
function tape (Test) {
|
|
var wrapEmitter = require('emitter-listener')
|
|
|
|
wrapEmitter(
|
|
Test.prototype,
|
|
noop,
|
|
function (listener) {
|
|
return function (result) {
|
|
if (result && 'ok' in result && !result.ok) result.ok = true
|
|
listener.apply(Test.prototype, arguments)
|
|
}
|
|
}
|
|
)
|
|
}
|