dwf/rva: minor Jasmine cleanup

This commit is contained in:
pivotal
2008-12-03 16:23:17 -08:00
parent 10b613c97d
commit 0f3685aca3
10 changed files with 397 additions and 404 deletions

View File

@@ -18,6 +18,45 @@ if (typeof Function.method !== 'function') {
}
}
/*
* object for holding results; allows for the results array to hold another nestedResults()
*
*/
var nestedResults = function() {
var that = {
totalCount: 0,
passedCount: 0,
failedCount: 0,
results: [],
rollupCounts: function (result) {
that.totalCount += result.totalCount;
that.passedCount += result.passedCount;
that.failedCount += result.failedCount;
},
push: function (result) {
if (result.results) {
that.rollupCounts(result);
} else {
that.totalCount++;
result.passed ? that.passedCount++ : that.failedCount++;
}
that.results.push(result);
}
}
return that;
}
/*
* base for Runner & Suite: allows for a queue of functions to get executed, allowing for
* any one action to complete, including asynchronous calls, before going to the next
* action.
*
**/
var actionCollection = function () {
var that = {
actions: [],
@@ -82,6 +121,7 @@ var actionCollection = function () {
/*
* Matchers methods; add your own with Matchers.method()
*/
Matchers = function (actual, results) {
this.actual = actual;
this.passing_message = 'Passed.'
@@ -101,7 +141,6 @@ Matchers.method('report', function (result, failing_message) {
Matchers.method('should_equal', function (expected) {
return this.report((this.actual === expected),
'Expected ' + expected + ' but got ' + this.actual + '.');
});
Matchers.method('should_not_equal', function (expected) {
@@ -134,34 +173,6 @@ var queuedFunction = function(func, timeout, spec) {
return that;
}
var nestedResults = function() {
var that = {
totalCount: 0,
passedCount: 0,
failedCount: 0,
results: [],
push: function(result) {
if (result.results) {
that.totalCount += result.totalCount;
that.passedCount += result.passedCount;
that.failedCount += result.failedCount;
} else {
that.totalCount++;
if (result.passed) {
that.passedCount++;
} else {
that.failedCount++;
}
}
that.results.push(result);
}
}
return that;
}
var it = function (description, func) {
var that = {
description: description,
@@ -211,7 +222,6 @@ var it = function (description, func) {
}
that.runs = addToQueue;
that.then = addToQueue;
currentSuite.specs.push(that);
currentSpec = that;
@@ -228,8 +238,6 @@ var runs = function (func) {
currentSpec.runs(func);
}
var then = runs;
var waits = function (timeout) {
currentSpec.waits(timeout);
}
@@ -249,7 +257,7 @@ var describe = function (description, spec_definitions) {
that.specs = that.actions;
currentSuite = that;
currentRunner.suites.push(that);
Jasmine.suites.push(that);
spec_definitions();
@@ -258,19 +266,18 @@ var describe = function (description, spec_definitions) {
return that;
}
var Jasmine = function () {
var Runner = function () {
var that = actionCollection();
that.suites = that.actions;
that.results.description = 'All Jasmine Suites';
currentRunner = that;
Jasmine = that;
return that;
}
var currentRunner = Jasmine();
var Jasmine = Runner();
var currentSuite = describe('default current suite', function() {});
var currentSpec;
/*