mirror of
https://github.com/gundb/panic-server.git
synced 2026-04-15 03:00:16 -04:00
Each test now has a unique ID to reference by. This will be useful for reporters and tracking of "done" events. Also, each test now saves the name it's been given.
35 lines
535 B
JavaScript
35 lines
535 B
JavaScript
/*jslint node: true*/
|
|
'use strict';
|
|
|
|
var Context = require('./Context');
|
|
var bump = require('../../server/bump');
|
|
var stack = [];
|
|
|
|
function done() {
|
|
stack.pop();
|
|
var next = stack.slice(-1)[0];
|
|
if (next) {
|
|
bump(next, done);
|
|
}
|
|
}
|
|
|
|
function Test(name, cb, time) {
|
|
if (!(this instanceof Test)) {
|
|
return new Test(name, cb);
|
|
}
|
|
if (!cb) {
|
|
cb = name;
|
|
}
|
|
|
|
if (typeof name === 'string') {
|
|
this.description = name;
|
|
}
|
|
|
|
var ctx = new Context(this);
|
|
stack.push(ctx);
|
|
cb.call(ctx, ctx);
|
|
bump(ctx, done);
|
|
}
|
|
|
|
module.exports = Test;
|