Move most jasmine global usage into boot.
- thor build scripts broken for now.
This commit is contained in:
158
src/core/base.js
158
src/core/base.js
@@ -1,4 +1,3 @@
|
||||
var isCommonJS = typeof window == "undefined" && typeof exports == "object";
|
||||
|
||||
/**
|
||||
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
|
||||
@@ -6,7 +5,7 @@ var isCommonJS = typeof window == "undefined" && typeof exports == "object";
|
||||
* @namespace
|
||||
*/
|
||||
var jasmine = {};
|
||||
if (isCommonJS) exports.jasmine = jasmine;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
@@ -128,6 +127,7 @@ jasmine.ExpectationResult.prototype.passed = function () {
|
||||
*/
|
||||
jasmine.getEnv = function() {
|
||||
var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
|
||||
//jasmine. singletons in here (setTimeout blah blah).
|
||||
return env;
|
||||
};
|
||||
|
||||
@@ -462,160 +462,6 @@ jasmine.log = function() {
|
||||
spec.log.apply(spec, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function that installs a spy on an existing object's method name. Used within a Spec to create a spy.
|
||||
*
|
||||
* @example
|
||||
* // spy example
|
||||
* var foo = {
|
||||
* not: function(bool) { return !bool; }
|
||||
* }
|
||||
* spyOn(foo, 'not'); // actual foo.not will not be called, execution stops
|
||||
*
|
||||
* @see jasmine.createSpy
|
||||
* @param obj
|
||||
* @param methodName
|
||||
* @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods
|
||||
*/
|
||||
var spyOn = function(obj, methodName) {
|
||||
return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
|
||||
};
|
||||
if (isCommonJS) exports.spyOn = spyOn;
|
||||
|
||||
/**
|
||||
* Creates a Jasmine spec that will be added to the current suite.
|
||||
*
|
||||
* // TODO: pending tests
|
||||
*
|
||||
* @example
|
||||
* it('should be true', function() {
|
||||
* expect(true).toEqual(true);
|
||||
* });
|
||||
*
|
||||
* @param {String} desc description of this specification
|
||||
* @param {Function} func defines the preconditions and expectations of the spec
|
||||
*/
|
||||
var it = function(desc, func) {
|
||||
return jasmine.getEnv().it(desc, func);
|
||||
};
|
||||
if (isCommonJS) exports.it = it;
|
||||
|
||||
/**
|
||||
* Creates a <em>disabled</em> Jasmine spec.
|
||||
*
|
||||
* A convenience method that allows existing specs to be disabled temporarily during development.
|
||||
*
|
||||
* @param {String} desc description of this specification
|
||||
* @param {Function} func defines the preconditions and expectations of the spec
|
||||
*/
|
||||
var xit = function(desc, func) {
|
||||
return jasmine.getEnv().xit(desc, func);
|
||||
};
|
||||
if (isCommonJS) exports.xit = xit;
|
||||
|
||||
/**
|
||||
* Starts a chain for a Jasmine expectation.
|
||||
*
|
||||
* It is passed an Object that is the actual value and should chain to one of the many
|
||||
* jasmine.Matchers functions.
|
||||
*
|
||||
* @param {Object} actual Actual value to test against and expected value
|
||||
* @return {jasmine.Matchers}
|
||||
*/
|
||||
var expect = function(actual) {
|
||||
return jasmine.getEnv().currentSpec.expect(actual);
|
||||
};
|
||||
if (isCommonJS) exports.expect = expect;
|
||||
|
||||
/**
|
||||
* Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
|
||||
*
|
||||
* @param {Function} func Function that defines part of a jasmine spec.
|
||||
*/
|
||||
var runs = function(func) {
|
||||
jasmine.getEnv().currentSpec.runs(func);
|
||||
};
|
||||
if (isCommonJS) exports.runs = runs;
|
||||
|
||||
/**
|
||||
* Waits a fixed time period before moving to the next block.
|
||||
*
|
||||
* @deprecated Use waitsFor() instead
|
||||
* @param {Number} timeout milliseconds to wait
|
||||
*/
|
||||
var waits = function(timeout) {
|
||||
jasmine.getEnv().currentSpec.waits(timeout);
|
||||
};
|
||||
if (isCommonJS) exports.waits = waits;
|
||||
|
||||
/**
|
||||
* Waits for the latchFunction to return true before proceeding to the next block.
|
||||
*
|
||||
* @param {Function} latchFunction
|
||||
* @param {String} optional_timeoutMessage
|
||||
* @param {Number} optional_timeout
|
||||
*/
|
||||
var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
|
||||
jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
|
||||
};
|
||||
if (isCommonJS) exports.waitsFor = waitsFor;
|
||||
|
||||
/**
|
||||
* A function that is called before each spec in a suite.
|
||||
*
|
||||
* Used for spec setup, including validating assumptions.
|
||||
*
|
||||
* @param {Function} beforeEachFunction
|
||||
*/
|
||||
var beforeEach = function(beforeEachFunction) {
|
||||
jasmine.getEnv().beforeEach(beforeEachFunction);
|
||||
};
|
||||
if (isCommonJS) exports.beforeEach = beforeEach;
|
||||
|
||||
/**
|
||||
* A function that is called after each spec in a suite.
|
||||
*
|
||||
* Used for restoring any state that is hijacked during spec execution.
|
||||
*
|
||||
* @param {Function} afterEachFunction
|
||||
*/
|
||||
var afterEach = function(afterEachFunction) {
|
||||
jasmine.getEnv().afterEach(afterEachFunction);
|
||||
};
|
||||
if (isCommonJS) exports.afterEach = afterEach;
|
||||
|
||||
/**
|
||||
* Defines a suite of specifications.
|
||||
*
|
||||
* Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared
|
||||
* are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization
|
||||
* of setup in some tests.
|
||||
*
|
||||
* @example
|
||||
* // TODO: a simple suite
|
||||
*
|
||||
* // TODO: a simple suite with a nested describe block
|
||||
*
|
||||
* @param {String} description A string, usually the class under test.
|
||||
* @param {Function} specDefinitions function that defines several specs.
|
||||
*/
|
||||
var describe = function(description, specDefinitions) {
|
||||
return jasmine.getEnv().describe(description, specDefinitions);
|
||||
};
|
||||
if (isCommonJS) exports.describe = describe;
|
||||
|
||||
/**
|
||||
* Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
|
||||
*
|
||||
* @param {String} description A string, usually the class under test.
|
||||
* @param {Function} specDefinitions function that defines several specs.
|
||||
*/
|
||||
var xdescribe = function(description, specDefinitions) {
|
||||
return jasmine.getEnv().xdescribe(description, specDefinitions);
|
||||
};
|
||||
if (isCommonJS) exports.xdescribe = xdescribe;
|
||||
|
||||
|
||||
// Provide the XMLHttpRequest class for IE 5.x-6.x:
|
||||
jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
|
||||
function tryIt(f) {
|
||||
|
||||
Reference in New Issue
Block a user