Move to grunt for building all distribution files.
* canonical version number of jasmine-core is now is package.json * `grunt buildDistribution` builds jasmine.js, jasmine-html.js, jasmine.css and outputs them to the dist dir * `grunt buildStandaloneDist` builds the example spec runner files and compresses them to dist/jasmine-VERSION.zip * `grunt compass` compiles jasmine.css * jasmine.Env handling of version is backwards compatible, but uses the version string directly (and nicely deprecated) * Ruby/thor tasks that did the above deleted
This commit is contained in:
@@ -16,7 +16,7 @@ jasmine.HtmlReporter = function(options) {
|
||||
htmlReporterMain = createDom("div", {className: "html-reporter"},
|
||||
createDom("div", {className: "banner"},
|
||||
createDom("span", {className: "title"}, "Jasmine"),
|
||||
createDom("span", {className: "version"}, env.versionString())
|
||||
createDom("span", {className: "version"}, jasmine.version)
|
||||
),
|
||||
createDom("ul", {className: "symbol-summary"}),
|
||||
createDom("div", {className: "alert"}),
|
||||
@@ -239,13 +239,15 @@ jasmine.HtmlReporter = function(options) {
|
||||
function setMenuModeTo(mode) {
|
||||
htmlReporterMain.setAttribute("class", "html-reporter " + mode);
|
||||
}
|
||||
};jasmine.HtmlSpecFilter = function(options) {
|
||||
};
|
||||
jasmine.HtmlSpecFilter = function(options) {
|
||||
var filterPattern = new RegExp(options && options.filterString());
|
||||
|
||||
this.matches = function(specName) {
|
||||
return filterPattern.test(specName);
|
||||
};
|
||||
};jasmine.ResultsNode = function(result, type, parent) {
|
||||
};
|
||||
jasmine.ResultsNode = function(result, type, parent) {
|
||||
this.result = result;
|
||||
this.type = type;
|
||||
this.parent = parent;
|
||||
@@ -259,7 +261,8 @@ jasmine.HtmlReporter = function(options) {
|
||||
this.last = function() {
|
||||
return this.children[this.children.length-1];
|
||||
};
|
||||
};jasmine.QueryString = function(options) {
|
||||
};
|
||||
jasmine.QueryString = function(options) {
|
||||
|
||||
this.setParam = function(key, value) {
|
||||
var paramMap = queryStringToParamMap();
|
||||
|
||||
@@ -371,6 +371,7 @@ jasmine.createSpyObj = function(baseName, methodNames) {
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
/**
|
||||
* @namespace
|
||||
*/
|
||||
@@ -436,67 +437,125 @@ jasmine.util.argsToArray = function(args) {
|
||||
jasmine.util.isUndefined = function(obj) {
|
||||
return obj === void 0;
|
||||
};
|
||||
jasmine.ExceptionFormatter = function() {
|
||||
this.message = function(error) {
|
||||
var message = error.name +
|
||||
': ' +
|
||||
error.message;
|
||||
|
||||
if (error.fileName || error.sourceURL) {
|
||||
message += " in " + (error.fileName || error.sourceURL);
|
||||
}
|
||||
jasmine.Spec = function(attrs) {
|
||||
this.encounteredExpectations = false;
|
||||
this.expectationFactory = attrs.expectationFactory;
|
||||
this.resultCallback = attrs.resultCallback || function() {};
|
||||
this.id = attrs.id;
|
||||
this.description = attrs.description || '';
|
||||
this.fn = attrs.fn;
|
||||
this.beforeFns = attrs.beforeFns || function() {};
|
||||
this.afterFns = attrs.afterFns || function() {};
|
||||
this.catchingExceptions = attrs.catchingExceptions;
|
||||
this.onStart = attrs.onStart || function() {};
|
||||
this.exceptionFormatter = attrs.exceptionFormatter || function() {};
|
||||
this.getSpecName = attrs.getSpecName || function() { return ''; };
|
||||
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
|
||||
this.queueRunner = attrs.queueRunner || function() {};
|
||||
this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
|
||||
|
||||
if (error.line || error.lineNumber) {
|
||||
message += " (line " + (error.line || error.lineNumber) + ")";
|
||||
}
|
||||
|
||||
return message;
|
||||
};
|
||||
|
||||
this.stack = function(error) {
|
||||
return error ? error.stack : null;
|
||||
};
|
||||
};//TODO: expectation result may make more sense as a presentation of an expectation.
|
||||
jasmine.buildExpectationResult = function(options) {
|
||||
var messageFormatter = options.messageFormatter || function() {},
|
||||
stackFormatter = options.stackFormatter || function() {};
|
||||
|
||||
return {
|
||||
matcherName: options.matcherName,
|
||||
expected: options.expected,
|
||||
actual: options.actual,
|
||||
message: message(),
|
||||
stack: stack(),
|
||||
passed: options.passed
|
||||
};
|
||||
|
||||
function message() {
|
||||
if (options.passed) {
|
||||
return "Passed.";
|
||||
} else if (options.message) {
|
||||
return options.message;
|
||||
} else if (options.error) {
|
||||
return messageFormatter(options.error);
|
||||
}
|
||||
return "";
|
||||
if (!this.fn) {
|
||||
this.pend();
|
||||
}
|
||||
|
||||
function stack() {
|
||||
if (options.passed) {
|
||||
return "";
|
||||
}
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
status: this.status(),
|
||||
failedExpectations: []
|
||||
};
|
||||
};
|
||||
|
||||
var error = options.error;
|
||||
if (!error) {
|
||||
try {
|
||||
throw new Error(message());
|
||||
} catch (e) {
|
||||
error = e;
|
||||
jasmine.Spec.prototype.addExpectationResult = function(passed, data) {
|
||||
this.encounteredExpectations = true;
|
||||
if (passed) {
|
||||
return;
|
||||
}
|
||||
this.result.failedExpectations.push(this.expectationResultFactory(data));
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.expect = function(actual) {
|
||||
return this.expectationFactory(actual, this);
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.execute = function(onComplete) {
|
||||
var self = this;
|
||||
|
||||
this.onStart(this);
|
||||
|
||||
if (this.markedPending || this.disabled) {
|
||||
complete();
|
||||
return;
|
||||
}
|
||||
|
||||
var befores = this.beforeFns() || [],
|
||||
afters = this.afterFns() || [];
|
||||
var allFns = befores.concat(this.fn).concat(afters);
|
||||
|
||||
this.queueRunner({
|
||||
fns: allFns,
|
||||
onException: function(e) {
|
||||
if (jasmine.Spec.isPendingSpecException(e)) {
|
||||
self.pend();
|
||||
return;
|
||||
}
|
||||
|
||||
self.addExpectationResult(false, {
|
||||
matcherName: "",
|
||||
passed: false,
|
||||
expected: "",
|
||||
actual: "",
|
||||
error: e
|
||||
});
|
||||
},
|
||||
onComplete: complete
|
||||
});
|
||||
|
||||
function complete() {
|
||||
self.result.status = self.status();
|
||||
self.resultCallback(self.result);
|
||||
|
||||
if (onComplete) {
|
||||
onComplete();
|
||||
}
|
||||
return stackFormatter(error);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.disable = function() {
|
||||
this.disabled = true;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.pend = function() {
|
||||
this.markedPending = true;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.status = function() {
|
||||
if (this.disabled) {
|
||||
return 'disabled';
|
||||
}
|
||||
|
||||
if (this.markedPending || !this.encounteredExpectations) {
|
||||
return 'pending';
|
||||
}
|
||||
|
||||
if (this.result.failedExpectations.length > 0) {
|
||||
return 'failed';
|
||||
} else {
|
||||
return 'passed';
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.getFullName = function() {
|
||||
return this.getSpecName(this);
|
||||
};
|
||||
|
||||
jasmine.Spec.pendingSpecExceptionMessage = "=> marked Pending";
|
||||
|
||||
jasmine.Spec.isPendingSpecException = function(e) {
|
||||
return e.toString().indexOf(jasmine.Spec.pendingSpecExceptionMessage) !== -1;
|
||||
};
|
||||
(function() {
|
||||
jasmine.Env = function(options) {
|
||||
options = options || {};
|
||||
@@ -703,11 +762,7 @@ jasmine.buildExpectationResult = function(options) {
|
||||
};
|
||||
|
||||
jasmine.Env.prototype.version = function() {
|
||||
if (this.jasmine.version_) {
|
||||
return this.jasmine.version_;
|
||||
} else {
|
||||
throw new Error('Version not set');
|
||||
}
|
||||
return jasmine.version;
|
||||
};
|
||||
|
||||
jasmine.Env.prototype.expect = function(actual) {
|
||||
@@ -751,17 +806,8 @@ jasmine.buildExpectationResult = function(options) {
|
||||
|
||||
// TODO: move this to closure
|
||||
jasmine.Env.prototype.versionString = function() {
|
||||
if (!this.jasmine.version_) {
|
||||
return "version unknown";
|
||||
}
|
||||
|
||||
var version = this.version();
|
||||
var versionString = version.major + "." + version.minor + "." + version.build;
|
||||
if (version.release_candidate) {
|
||||
versionString += ".rc" + version.release_candidate;
|
||||
}
|
||||
versionString += " revision " + version.revision;
|
||||
return versionString;
|
||||
console.log("DEPRECATED == use jasmine.version");
|
||||
return jasmine.version;
|
||||
};
|
||||
|
||||
// TODO: move this to closure
|
||||
@@ -979,6 +1025,7 @@ jasmine.buildExpectationResult = function(options) {
|
||||
this.equalityTesters_.push(equalityTester);
|
||||
};
|
||||
}());
|
||||
|
||||
jasmine.JsApiReporter = function(jasmine) {
|
||||
this.jasmine = jasmine || {};
|
||||
this.started = false;
|
||||
@@ -1033,7 +1080,268 @@ jasmine.JsApiReporter = function(jasmine) {
|
||||
return specs;
|
||||
};
|
||||
|
||||
};/**
|
||||
};
|
||||
jasmine.Clock = function(global, delayedFunctionScheduler) {
|
||||
var self = this,
|
||||
realTimingFunctions = {
|
||||
setTimeout: global.setTimeout,
|
||||
clearTimeout: global.clearTimeout,
|
||||
setInterval: global.setInterval,
|
||||
clearInterval: global.clearInterval
|
||||
},
|
||||
fakeTimingFunctions = {
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
setInterval: setInterval,
|
||||
clearInterval: clearInterval
|
||||
},
|
||||
timer = realTimingFunctions,
|
||||
installed = false;
|
||||
|
||||
self.install = function() {
|
||||
installed = true;
|
||||
timer = fakeTimingFunctions;
|
||||
};
|
||||
|
||||
self.uninstall = function() {
|
||||
delayedFunctionScheduler.reset();
|
||||
installed = false;
|
||||
timer = realTimingFunctions;
|
||||
};
|
||||
|
||||
self.setTimeout = function(fn, delay, params) {
|
||||
if (legacyIE()) {
|
||||
if (arguments.length > 2) {
|
||||
throw new Error("IE < 9 cannot support extra params to setTimeout without a polyfill");
|
||||
}
|
||||
return timer.setTimeout(fn, delay);
|
||||
}
|
||||
return timer.setTimeout.apply(null, arguments);
|
||||
};
|
||||
|
||||
self.setInterval = function(fn, delay, params) {
|
||||
if (legacyIE()) {
|
||||
if (arguments.length > 2) {
|
||||
throw new Error("IE < 9 cannot support extra params to setInterval without a polyfill");
|
||||
}
|
||||
return timer.setInterval(fn, delay);
|
||||
}
|
||||
return timer.setInterval.apply(null, arguments);
|
||||
};
|
||||
|
||||
self.clearTimeout = function(id) {
|
||||
return timer.clearTimeout(id);
|
||||
};
|
||||
|
||||
self.clearInterval = function(id) {
|
||||
return timer.clearInterval(id);
|
||||
};
|
||||
|
||||
self.tick = function(millis) {
|
||||
if (installed) {
|
||||
delayedFunctionScheduler.tick(millis);
|
||||
} else {
|
||||
throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
|
||||
}
|
||||
};
|
||||
|
||||
return self;
|
||||
|
||||
function legacyIE() {
|
||||
//if these methods are polyfilled, apply will be present
|
||||
//TODO: it may be difficult to load the polyfill before jasmine loads
|
||||
//(env should be new-ed inside of onload)
|
||||
return !(global.setTimeout || global.setInterval).apply;
|
||||
}
|
||||
|
||||
function setTimeout(fn, delay) {
|
||||
return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2));
|
||||
}
|
||||
|
||||
function clearTimeout(id) {
|
||||
return delayedFunctionScheduler.removeFunctionWithId(id);
|
||||
}
|
||||
|
||||
function setInterval(fn, interval) {
|
||||
return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true);
|
||||
}
|
||||
|
||||
function clearInterval(id) {
|
||||
return delayedFunctionScheduler.removeFunctionWithId(id);
|
||||
}
|
||||
|
||||
function argSlice(argsObj, n) {
|
||||
return Array.prototype.slice.call(argsObj, 2);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.DelayedFunctionScheduler = function() {
|
||||
var self = this;
|
||||
var scheduledFunctions = {};
|
||||
var currentTime = 0;
|
||||
var delayedFnCount = 0;
|
||||
|
||||
self.tick = function(millis) {
|
||||
runFunctionsWithinRange(currentTime, currentTime + millis);
|
||||
currentTime = currentTime + millis;
|
||||
};
|
||||
|
||||
self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
|
||||
timeoutKey = timeoutKey || ++delayedFnCount;
|
||||
runAtMillis = runAtMillis || (currentTime + millis);
|
||||
scheduledFunctions[timeoutKey] = {
|
||||
runAtMillis: runAtMillis,
|
||||
funcToCall: funcToCall,
|
||||
recurring: recurring,
|
||||
params: params,
|
||||
timeoutKey: timeoutKey,
|
||||
millis: millis
|
||||
};
|
||||
return timeoutKey;
|
||||
};
|
||||
|
||||
self.removeFunctionWithId = function(timeoutKey) {
|
||||
delete scheduledFunctions[timeoutKey];
|
||||
};
|
||||
|
||||
self.reset = function() {
|
||||
currentTime = 0;
|
||||
scheduledFunctions = {};
|
||||
delayedFnCount = 0;
|
||||
};
|
||||
|
||||
return self;
|
||||
|
||||
|
||||
//finds/dupes functions within range and removes them.
|
||||
function functionsWithinRange(startMillis, endMillis) {
|
||||
var fnsToRun = [];
|
||||
for (var timeoutKey in scheduledFunctions) {
|
||||
var scheduledFunc = scheduledFunctions[timeoutKey];
|
||||
if (scheduledFunc &&
|
||||
scheduledFunc.runAtMillis >= startMillis &&
|
||||
scheduledFunc.runAtMillis <= endMillis) {
|
||||
//remove fn -- we'll reschedule later if it is recurring.
|
||||
self.removeFunctionWithId(timeoutKey);
|
||||
if (!scheduledFunc.recurring) {
|
||||
fnsToRun.push(scheduledFunc); // schedules each function only once
|
||||
} else {
|
||||
fnsToRun.push(buildNthInstanceOf(scheduledFunc, 0));
|
||||
var additionalTimesFnRunsInRange =
|
||||
Math.floor((endMillis - scheduledFunc.runAtMillis) / scheduledFunc.millis);
|
||||
for (var i = 0; i < additionalTimesFnRunsInRange; i++) {
|
||||
fnsToRun.push(buildNthInstanceOf(scheduledFunc, i + 1));
|
||||
}
|
||||
reschedule(buildNthInstanceOf(scheduledFunc, additionalTimesFnRunsInRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fnsToRun;
|
||||
}
|
||||
|
||||
function buildNthInstanceOf(scheduledFunc, n) {
|
||||
return {
|
||||
runAtMillis: scheduledFunc.runAtMillis + (scheduledFunc.millis * n),
|
||||
funcToCall: scheduledFunc.funcToCall,
|
||||
params: scheduledFunc.params,
|
||||
millis: scheduledFunc.millis,
|
||||
recurring: scheduledFunc.recurring,
|
||||
timeoutKey: scheduledFunc.timeoutKey
|
||||
};
|
||||
}
|
||||
|
||||
function reschedule(scheduledFn) {
|
||||
self.scheduleFunction(scheduledFn.funcToCall,
|
||||
scheduledFn.millis,
|
||||
scheduledFn.params,
|
||||
true,
|
||||
scheduledFn.timeoutKey,
|
||||
scheduledFn.runAtMillis + scheduledFn.millis);
|
||||
}
|
||||
|
||||
|
||||
function runFunctionsWithinRange(startMillis, endMillis) {
|
||||
var funcsToRun = functionsWithinRange(startMillis, endMillis);
|
||||
if (funcsToRun.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
funcsToRun.sort(function(a, b) {
|
||||
return a.runAtMillis - b.runAtMillis;
|
||||
});
|
||||
|
||||
for (var i = 0; i < funcsToRun.length; ++i) {
|
||||
var funcToRun = funcsToRun[i];
|
||||
funcToRun.funcToCall.apply(null, funcToRun.params);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.ExceptionFormatter = function() {
|
||||
this.message = function(error) {
|
||||
var message = error.name +
|
||||
': ' +
|
||||
error.message;
|
||||
|
||||
if (error.fileName || error.sourceURL) {
|
||||
message += " in " + (error.fileName || error.sourceURL);
|
||||
}
|
||||
|
||||
if (error.line || error.lineNumber) {
|
||||
message += " (line " + (error.line || error.lineNumber) + ")";
|
||||
}
|
||||
|
||||
return message;
|
||||
};
|
||||
|
||||
this.stack = function(error) {
|
||||
return error ? error.stack : null;
|
||||
};
|
||||
};
|
||||
//TODO: expectation result may make more sense as a presentation of an expectation.
|
||||
jasmine.buildExpectationResult = function(options) {
|
||||
var messageFormatter = options.messageFormatter || function() {},
|
||||
stackFormatter = options.stackFormatter || function() {};
|
||||
|
||||
return {
|
||||
matcherName: options.matcherName,
|
||||
expected: options.expected,
|
||||
actual: options.actual,
|
||||
message: message(),
|
||||
stack: stack(),
|
||||
passed: options.passed
|
||||
};
|
||||
|
||||
function message() {
|
||||
if (options.passed) {
|
||||
return "Passed.";
|
||||
} else if (options.message) {
|
||||
return options.message;
|
||||
} else if (options.error) {
|
||||
return messageFormatter(options.error);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function stack() {
|
||||
if (options.passed) {
|
||||
return "";
|
||||
}
|
||||
|
||||
var error = options.error;
|
||||
if (!error) {
|
||||
try {
|
||||
throw new Error(message());
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
}
|
||||
return stackFormatter(error);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {jasmine.Env} env
|
||||
* @param actual
|
||||
@@ -1429,6 +1737,7 @@ jasmine.Matchers.ObjectContaining.prototype.jasmineMatches = function(other, mis
|
||||
jasmine.Matchers.ObjectContaining.prototype.jasmineToString = function() {
|
||||
return "<jasmine.objectContaining(" + jasmine.pp(this.sample) + ")>";
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for pretty printing for expectation results.
|
||||
*/
|
||||
@@ -1559,6 +1868,7 @@ jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
|
||||
jasmine.StringPrettyPrinter.prototype.append = function(value) {
|
||||
this.string += value;
|
||||
};
|
||||
|
||||
jasmine.QueueRunner = function(attrs) {
|
||||
this.fns = attrs.fns || [];
|
||||
this.onComplete = attrs.onComplete || function() {};
|
||||
@@ -1599,124 +1909,38 @@ jasmine.QueueRunner.prototype.run = function(fns, index) {
|
||||
}
|
||||
}
|
||||
};
|
||||
jasmine.Spec = function(attrs) {
|
||||
this.encounteredExpectations = false;
|
||||
this.expectationFactory = attrs.expectationFactory;
|
||||
this.resultCallback = attrs.resultCallback || function() {};
|
||||
this.id = attrs.id;
|
||||
this.description = attrs.description || '';
|
||||
this.fn = attrs.fn;
|
||||
this.beforeFns = attrs.beforeFns || function() {};
|
||||
this.afterFns = attrs.afterFns || function() {};
|
||||
this.catchingExceptions = attrs.catchingExceptions;
|
||||
this.onStart = attrs.onStart || function() {};
|
||||
this.exceptionFormatter = attrs.exceptionFormatter || function() {};
|
||||
this.getSpecName = attrs.getSpecName || function() { return ''; };
|
||||
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
|
||||
this.queueRunner = attrs.queueRunner || function() {};
|
||||
this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
|
||||
|
||||
if (!this.fn) {
|
||||
this.pend();
|
||||
jasmine.ReportDispatcher = function(methods) {
|
||||
|
||||
var dispatchedMethods = methods || [];
|
||||
|
||||
for (var i = 0; i < dispatchedMethods.length; i++) {
|
||||
var method = dispatchedMethods[i];
|
||||
this[method] = function(m) {
|
||||
return function() {
|
||||
dispatch(m, arguments);
|
||||
};
|
||||
}(method);
|
||||
}
|
||||
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
status: this.status(),
|
||||
failedExpectations: []
|
||||
var reporters = [];
|
||||
|
||||
this.addReporter = function(reporter) {
|
||||
reporters.push(reporter);
|
||||
};
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.addExpectationResult = function(passed, data) {
|
||||
this.encounteredExpectations = true;
|
||||
if (passed) {
|
||||
return;
|
||||
}
|
||||
this.result.failedExpectations.push(this.expectationResultFactory(data));
|
||||
};
|
||||
return this;
|
||||
|
||||
jasmine.Spec.prototype.expect = function(actual) {
|
||||
return this.expectationFactory(actual, this);
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.execute = function(onComplete) {
|
||||
var self = this;
|
||||
|
||||
this.onStart(this);
|
||||
|
||||
if (this.markedPending || this.disabled) {
|
||||
complete();
|
||||
return;
|
||||
}
|
||||
|
||||
var befores = this.beforeFns() || [],
|
||||
afters = this.afterFns() || [];
|
||||
var allFns = befores.concat(this.fn).concat(afters);
|
||||
|
||||
this.queueRunner({
|
||||
fns: allFns,
|
||||
onException: function(e) {
|
||||
if (jasmine.Spec.isPendingSpecException(e)) {
|
||||
self.pend();
|
||||
return;
|
||||
function dispatch(method, args) {
|
||||
for (var i = 0; i < reporters.length; i++) {
|
||||
var reporter = reporters[i];
|
||||
if (reporter[method]) {
|
||||
reporter[method].apply(reporter, args);
|
||||
}
|
||||
|
||||
self.addExpectationResult(false, {
|
||||
matcherName: "",
|
||||
passed: false,
|
||||
expected: "",
|
||||
actual: "",
|
||||
error: e
|
||||
});
|
||||
},
|
||||
onComplete: complete
|
||||
});
|
||||
|
||||
function complete() {
|
||||
self.result.status = self.status();
|
||||
self.resultCallback(self.result);
|
||||
|
||||
if (onComplete) {
|
||||
onComplete();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.disable = function() {
|
||||
this.disabled = true;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.pend = function() {
|
||||
this.markedPending = true;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.status = function() {
|
||||
if (this.disabled) {
|
||||
return 'disabled';
|
||||
}
|
||||
|
||||
if (this.markedPending || !this.encounteredExpectations) {
|
||||
return 'pending';
|
||||
}
|
||||
|
||||
if (this.result.failedExpectations.length > 0) {
|
||||
return 'failed';
|
||||
} else {
|
||||
return 'passed';
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.getFullName = function() {
|
||||
return this.getSpecName(this);
|
||||
};
|
||||
|
||||
jasmine.Spec.pendingSpecExceptionMessage = "=> marked Pending";
|
||||
|
||||
jasmine.Spec.isPendingSpecException = function(e) {
|
||||
return e.toString().indexOf(jasmine.Spec.pendingSpecExceptionMessage) !== -1;
|
||||
};jasmine.Suite = function(attrs) {
|
||||
jasmine.Suite = function(attrs) {
|
||||
this.env = attrs.env;
|
||||
this.id = attrs.id;
|
||||
this.parentSuite = attrs.parentSuite;
|
||||
@@ -1815,234 +2039,5 @@ jasmine.Suite.prototype.execute = function(onComplete) {
|
||||
};
|
||||
}
|
||||
};
|
||||
jasmine.Clock = function(global, delayedFunctionScheduler) {
|
||||
var self = this,
|
||||
realTimingFunctions = {
|
||||
setTimeout: global.setTimeout,
|
||||
clearTimeout: global.clearTimeout,
|
||||
setInterval: global.setInterval,
|
||||
clearInterval: global.clearInterval
|
||||
},
|
||||
fakeTimingFunctions = {
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
setInterval: setInterval,
|
||||
clearInterval: clearInterval
|
||||
},
|
||||
timer = realTimingFunctions,
|
||||
installed = false;
|
||||
|
||||
self.install = function() {
|
||||
installed = true;
|
||||
timer = fakeTimingFunctions;
|
||||
};
|
||||
|
||||
self.uninstall = function() {
|
||||
delayedFunctionScheduler.reset();
|
||||
installed = false;
|
||||
timer = realTimingFunctions;
|
||||
};
|
||||
|
||||
self.setTimeout = function(fn, delay, params) {
|
||||
if (legacyIE()) {
|
||||
if (arguments.length > 2) {
|
||||
throw new Error("IE < 9 cannot support extra params to setTimeout without a polyfill");
|
||||
}
|
||||
return timer.setTimeout(fn, delay);
|
||||
}
|
||||
return timer.setTimeout.apply(null, arguments);
|
||||
};
|
||||
|
||||
self.setInterval = function(fn, delay, params) {
|
||||
if (legacyIE()) {
|
||||
if (arguments.length > 2) {
|
||||
throw new Error("IE < 9 cannot support extra params to setInterval without a polyfill");
|
||||
}
|
||||
return timer.setInterval(fn, delay);
|
||||
}
|
||||
return timer.setInterval.apply(null, arguments);
|
||||
};
|
||||
|
||||
self.clearTimeout = function(id) {
|
||||
return timer.clearTimeout(id);
|
||||
};
|
||||
|
||||
self.clearInterval = function(id) {
|
||||
return timer.clearInterval(id);
|
||||
};
|
||||
|
||||
self.tick = function(millis) {
|
||||
if (installed) {
|
||||
delayedFunctionScheduler.tick(millis);
|
||||
} else {
|
||||
throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
|
||||
}
|
||||
};
|
||||
|
||||
return self;
|
||||
|
||||
function legacyIE() {
|
||||
//if these methods are polyfilled, apply will be present
|
||||
//TODO: it may be difficult to load the polyfill before jasmine loads
|
||||
//(env should be new-ed inside of onload)
|
||||
return !(global.setTimeout || global.setInterval).apply;
|
||||
}
|
||||
|
||||
function setTimeout(fn, delay) {
|
||||
return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2));
|
||||
}
|
||||
|
||||
function clearTimeout(id) {
|
||||
return delayedFunctionScheduler.removeFunctionWithId(id);
|
||||
}
|
||||
|
||||
function setInterval(fn, interval) {
|
||||
return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true);
|
||||
}
|
||||
|
||||
function clearInterval(id) {
|
||||
return delayedFunctionScheduler.removeFunctionWithId(id);
|
||||
}
|
||||
|
||||
function argSlice(argsObj, n) {
|
||||
return Array.prototype.slice.call(argsObj, 2);
|
||||
}
|
||||
};
|
||||
jasmine.DelayedFunctionScheduler = function() {
|
||||
var self = this;
|
||||
var scheduledFunctions = {};
|
||||
var currentTime = 0;
|
||||
var delayedFnCount = 0;
|
||||
|
||||
self.tick = function(millis) {
|
||||
runFunctionsWithinRange(currentTime, currentTime + millis);
|
||||
currentTime = currentTime + millis;
|
||||
};
|
||||
|
||||
self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
|
||||
timeoutKey = timeoutKey || ++delayedFnCount;
|
||||
runAtMillis = runAtMillis || (currentTime + millis);
|
||||
scheduledFunctions[timeoutKey] = {
|
||||
runAtMillis: runAtMillis,
|
||||
funcToCall: funcToCall,
|
||||
recurring: recurring,
|
||||
params: params,
|
||||
timeoutKey: timeoutKey,
|
||||
millis: millis
|
||||
};
|
||||
return timeoutKey;
|
||||
};
|
||||
|
||||
self.removeFunctionWithId = function(timeoutKey) {
|
||||
delete scheduledFunctions[timeoutKey];
|
||||
};
|
||||
|
||||
self.reset = function() {
|
||||
currentTime = 0;
|
||||
scheduledFunctions = {};
|
||||
delayedFnCount = 0;
|
||||
};
|
||||
|
||||
return self;
|
||||
|
||||
|
||||
//finds/dupes functions within range and removes them.
|
||||
function functionsWithinRange(startMillis, endMillis) {
|
||||
var fnsToRun = [];
|
||||
for (var timeoutKey in scheduledFunctions) {
|
||||
var scheduledFunc = scheduledFunctions[timeoutKey];
|
||||
if (scheduledFunc &&
|
||||
scheduledFunc.runAtMillis >= startMillis &&
|
||||
scheduledFunc.runAtMillis <= endMillis) {
|
||||
//remove fn -- we'll reschedule later if it is recurring.
|
||||
self.removeFunctionWithId(timeoutKey);
|
||||
if (!scheduledFunc.recurring) {
|
||||
fnsToRun.push(scheduledFunc); // schedules each function only once
|
||||
} else {
|
||||
fnsToRun.push(buildNthInstanceOf(scheduledFunc, 0));
|
||||
var additionalTimesFnRunsInRange =
|
||||
Math.floor((endMillis - scheduledFunc.runAtMillis) / scheduledFunc.millis);
|
||||
for (var i = 0; i < additionalTimesFnRunsInRange; i++) {
|
||||
fnsToRun.push(buildNthInstanceOf(scheduledFunc, i + 1));
|
||||
}
|
||||
reschedule(buildNthInstanceOf(scheduledFunc, additionalTimesFnRunsInRange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fnsToRun;
|
||||
}
|
||||
|
||||
function buildNthInstanceOf(scheduledFunc, n) {
|
||||
return {
|
||||
runAtMillis: scheduledFunc.runAtMillis + (scheduledFunc.millis * n),
|
||||
funcToCall: scheduledFunc.funcToCall,
|
||||
params: scheduledFunc.params,
|
||||
millis: scheduledFunc.millis,
|
||||
recurring: scheduledFunc.recurring,
|
||||
timeoutKey: scheduledFunc.timeoutKey
|
||||
};
|
||||
}
|
||||
|
||||
function reschedule(scheduledFn) {
|
||||
self.scheduleFunction(scheduledFn.funcToCall,
|
||||
scheduledFn.millis,
|
||||
scheduledFn.params,
|
||||
true,
|
||||
scheduledFn.timeoutKey,
|
||||
scheduledFn.runAtMillis + scheduledFn.millis);
|
||||
}
|
||||
|
||||
|
||||
function runFunctionsWithinRange(startMillis, endMillis) {
|
||||
var funcsToRun = functionsWithinRange(startMillis, endMillis);
|
||||
if (funcsToRun.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
funcsToRun.sort(function(a, b) {
|
||||
return a.runAtMillis - b.runAtMillis;
|
||||
});
|
||||
|
||||
for (var i = 0; i < funcsToRun.length; ++i) {
|
||||
var funcToRun = funcsToRun[i];
|
||||
funcToRun.funcToCall.apply(null, funcToRun.params);
|
||||
}
|
||||
}
|
||||
};
|
||||
jasmine.ReportDispatcher = function(methods) {
|
||||
|
||||
var dispatchedMethods = methods || [];
|
||||
|
||||
for (var i = 0; i < dispatchedMethods.length; i++) {
|
||||
var method = dispatchedMethods[i];
|
||||
this[method] = function(m) {
|
||||
return function() {
|
||||
dispatch(m, arguments);
|
||||
};
|
||||
}(method);
|
||||
}
|
||||
|
||||
var reporters = [];
|
||||
|
||||
this.addReporter = function(reporter) {
|
||||
reporters.push(reporter);
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function dispatch(method, args) {
|
||||
for (var i = 0; i < reporters.length; i++) {
|
||||
var reporter = reporters[i];
|
||||
if (reporter[method]) {
|
||||
reporter[method].apply(reporter, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
jasmine.version_= {
|
||||
"major": 1,
|
||||
"minor": 3,
|
||||
"build": 1,
|
||||
"revision": 1354556913
|
||||
};
|
||||
jasmine.version = "2.0.0-alpha";
|
||||
26
lib/templates/SpecRunner.html.jst
Normal file
26
lib/templates/SpecRunner.html.jst
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Spec Runner v<%= jasmineVersion %></title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="lib/jasmine-<%= jasmineVersion %>/jasmine_favicon.png">
|
||||
<link rel="stylesheet" type="text/css" href="lib/jasmine-<%= jasmineVersion %>/jasmine.css">
|
||||
|
||||
<script type="text/javascript" src="lib/jasmine-<%= jasmineVersion %>/jasmine.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-<%= jasmineVersion %>/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-<%= jasmineVersion %>/boot.js"></script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script type="text/javascript" src="src/Player.js"></script>
|
||||
<script type="text/javascript" src="src/Song.js"></script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script type="text/javascript" src="spec/SpecHelper.js"></script>
|
||||
<script type="text/javascript" src="spec/PlayerSpec.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user