mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-13 17:23:11 +00:00
chore(libs): update libs (jasmine, jstd, jasmine-jstd adapter)
This commit is contained in:
parent
d83a92c121
commit
ab5df20dfa
12 changed files with 291 additions and 412 deletions
6
angularFiles.js
vendored
6
angularFiles.js
vendored
|
|
@ -57,7 +57,7 @@ angularFiles = {
|
||||||
],
|
],
|
||||||
|
|
||||||
'jstd': [
|
'jstd': [
|
||||||
'lib/jasmine-1.0.1/jasmine.js',
|
'lib/jasmine/jasmine.js',
|
||||||
'lib/jasmine-jstd-adapter/JasmineAdapter.js',
|
'lib/jasmine-jstd-adapter/JasmineAdapter.js',
|
||||||
'lib/jquery/jquery.js',
|
'lib/jquery/jquery.js',
|
||||||
'test/jquery_remove.js',
|
'test/jquery_remove.js',
|
||||||
|
|
@ -94,7 +94,7 @@ angularFiles = {
|
||||||
],
|
],
|
||||||
|
|
||||||
'jstdPerf': [
|
'jstdPerf': [
|
||||||
'lib/jasmine-1.0.1/jasmine.js',
|
'lib/jasmine/jasmine.js',
|
||||||
'lib/jasmine-jstd-adapter/JasmineAdapter.js',
|
'lib/jasmine-jstd-adapter/JasmineAdapter.js',
|
||||||
'angularSrc',
|
'angularSrc',
|
||||||
'src/angular-mocks.js',
|
'src/angular-mocks.js',
|
||||||
|
|
@ -110,7 +110,7 @@ angularFiles = {
|
||||||
],
|
],
|
||||||
|
|
||||||
'jstdJquery': [
|
'jstdJquery': [
|
||||||
'lib/jasmine-1.0.1/jasmine.js',
|
'lib/jasmine/jasmine.js',
|
||||||
'lib/jasmine-jstd-adapter/JasmineAdapter.js',
|
'lib/jasmine-jstd-adapter/JasmineAdapter.js',
|
||||||
'lib/jquery/jquery.js',
|
'lib/jquery/jquery.js',
|
||||||
'test/jquery_alias.js',
|
'test/jquery_alias.js',
|
||||||
|
|
|
||||||
|
|
@ -1,181 +0,0 @@
|
||||||
var fs = require('fs');
|
|
||||||
var sys = require('sys');
|
|
||||||
var path = require('path');
|
|
||||||
var vm = require('vm');
|
|
||||||
|
|
||||||
var filename = __dirname + '/jasmine.js';
|
|
||||||
global.window = {
|
|
||||||
setTimeout: setTimeout,
|
|
||||||
clearTimeout: clearTimeout,
|
|
||||||
setInterval: setInterval,
|
|
||||||
clearInterval: clearInterval
|
|
||||||
};
|
|
||||||
var src = fs.readFileSync(filename);
|
|
||||||
var jasmine = vm.runInThisContext(src + '\njasmine;', filename);
|
|
||||||
delete global.window;
|
|
||||||
|
|
||||||
function noop(){}
|
|
||||||
|
|
||||||
jasmine.executeSpecsInFolder = function(folder, done, isVerbose, showColors, matcher){
|
|
||||||
var log = [];
|
|
||||||
var columnCounter = 0;
|
|
||||||
var start = 0;
|
|
||||||
var elapsed = 0;
|
|
||||||
var verbose = isVerbose || false;
|
|
||||||
var fileMatcher = new RegExp(matcher || "\.js$");
|
|
||||||
var colors = showColors || false;
|
|
||||||
var specs = jasmine.getAllSpecFiles(folder, fileMatcher);
|
|
||||||
|
|
||||||
var ansi = {
|
|
||||||
green: '\033[32m',
|
|
||||||
red: '\033[31m',
|
|
||||||
yellow: '\033[33m',
|
|
||||||
none: '\033[0m'
|
|
||||||
};
|
|
||||||
|
|
||||||
for (var i = 0, len = specs.length; i < len; ++i){
|
|
||||||
var filename = specs[i];
|
|
||||||
require(filename.replace(/\.*$/, ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
var jasmineEnv = jasmine.getEnv();
|
|
||||||
jasmineEnv.reporter = {
|
|
||||||
log: function(str){
|
|
||||||
},
|
|
||||||
|
|
||||||
reportSpecStarting: function(runner) {
|
|
||||||
},
|
|
||||||
|
|
||||||
reportRunnerStarting: function(runner) {
|
|
||||||
sys.puts('Started');
|
|
||||||
start = Number(new Date);
|
|
||||||
},
|
|
||||||
|
|
||||||
reportSuiteResults: function(suite) {
|
|
||||||
var specResults = suite.results();
|
|
||||||
var path = [];
|
|
||||||
while(suite) {
|
|
||||||
path.unshift(suite.description);
|
|
||||||
suite = suite.parentSuite;
|
|
||||||
}
|
|
||||||
var description = path.join(' ');
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
log.push('Spec ' + description);
|
|
||||||
|
|
||||||
specResults.items_.forEach(function(spec){
|
|
||||||
if (spec.failedCount > 0 && spec.description) {
|
|
||||||
if (!verbose)
|
|
||||||
log.push(description);
|
|
||||||
log.push(' it ' + spec.description);
|
|
||||||
spec.items_.forEach(function(result){
|
|
||||||
log.push(' ' + result.trace.stack + '\n');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
reportSpecResults: function(spec) {
|
|
||||||
var result = spec.results();
|
|
||||||
var msg = '';
|
|
||||||
if (result.passed())
|
|
||||||
{
|
|
||||||
msg = (colors) ? (ansi.green + '.' + ansi.none) : '.';
|
|
||||||
// } else if (result.skipped) { TODO: Research why "result.skipped" returns false when "xit" is called on a spec?
|
|
||||||
// msg = (colors) ? (ansi.yellow + '*' + ansi.none) : '*';
|
|
||||||
} else {
|
|
||||||
msg = (colors) ? (ansi.red + 'F' + ansi.none) : 'F';
|
|
||||||
}
|
|
||||||
sys.print(msg);
|
|
||||||
if (columnCounter++ < 50) return;
|
|
||||||
columnCounter = 0;
|
|
||||||
sys.print('\n');
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
reportRunnerResults: function(runner) {
|
|
||||||
elapsed = (Number(new Date) - start) / 1000;
|
|
||||||
sys.puts('\n');
|
|
||||||
log.forEach(function(log){
|
|
||||||
sys.puts(log);
|
|
||||||
});
|
|
||||||
sys.puts('Finished in ' + elapsed + ' seconds');
|
|
||||||
|
|
||||||
var summary = jasmine.printRunnerResults(runner);
|
|
||||||
if(colors)
|
|
||||||
{
|
|
||||||
if(runner.results().failedCount === 0 )
|
|
||||||
sys.puts(ansi.green + summary + ansi.none);
|
|
||||||
else
|
|
||||||
sys.puts(ansi.red + summary + ansi.none);
|
|
||||||
} else {
|
|
||||||
sys.puts(summary);
|
|
||||||
}
|
|
||||||
(done||noop)(runner, log);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
jasmineEnv.execute();
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.getAllSpecFiles = function(dir, matcher){
|
|
||||||
var specs = [];
|
|
||||||
|
|
||||||
if (fs.statSync(dir).isFile() && dir.match(matcher)) {
|
|
||||||
specs.push(dir);
|
|
||||||
} else {
|
|
||||||
var files = fs.readdirSync(dir);
|
|
||||||
for (var i = 0, len = files.length; i < len; ++i){
|
|
||||||
var filename = dir + '/' + files[i];
|
|
||||||
if (fs.statSync(filename).isFile() && filename.match(matcher)){
|
|
||||||
specs.push(filename);
|
|
||||||
}else if (fs.statSync(filename).isDirectory()){
|
|
||||||
var subfiles = this.getAllSpecFiles(filename, matcher);
|
|
||||||
subfiles.forEach(function(result){
|
|
||||||
specs.push(result);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return specs;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.printRunnerResults = function(runner){
|
|
||||||
var results = runner.results();
|
|
||||||
var suites = runner.suites();
|
|
||||||
var msg = '';
|
|
||||||
msg += suites.length + ' test' + ((suites.length === 1) ? '' : 's') + ', ';
|
|
||||||
msg += results.totalCount + ' assertion' + ((results.totalCount === 1) ? '' : 's') + ', ';
|
|
||||||
msg += results.failedCount + ' failure' + ((results.failedCount === 1) ? '' : 's') + '\n';
|
|
||||||
return msg;
|
|
||||||
};
|
|
||||||
|
|
||||||
function now(){
|
|
||||||
return new Date().getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
jasmine.asyncSpecWait = function(){
|
|
||||||
var wait = jasmine.asyncSpecWait;
|
|
||||||
wait.start = now();
|
|
||||||
wait.done = false;
|
|
||||||
(function innerWait(){
|
|
||||||
waits(10);
|
|
||||||
runs(function() {
|
|
||||||
if (wait.start + wait.timeout < now()) {
|
|
||||||
expect('timeout waiting for spec').toBeNull();
|
|
||||||
} else if (wait.done) {
|
|
||||||
wait.done = false;
|
|
||||||
} else {
|
|
||||||
innerWait();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
};
|
|
||||||
jasmine.asyncSpecWait.timeout = 4 * 1000;
|
|
||||||
jasmine.asyncSpecDone = function(){
|
|
||||||
jasmine.asyncSpecWait.done = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
for ( var key in jasmine) {
|
|
||||||
exports[key] = jasmine[key];
|
|
||||||
}
|
|
||||||
|
|
@ -1,186 +1,189 @@
|
||||||
/**
|
/**
|
||||||
* @fileoverview Jasmine JsTestDriver Adapter.
|
* @fileoverview Jasmine JsTestDriver Adapter.
|
||||||
* @author misko@hevery.com (Misko Hevery)
|
* @author misko@hevery.com (Misko Hevery)
|
||||||
|
* @author olmo.maldonado@gmail.com (Olmo Maldonado)
|
||||||
*/
|
*/
|
||||||
(function(window) {
|
(function(){
|
||||||
var rootDescribes = new Describes(window);
|
|
||||||
var describePath = [];
|
|
||||||
rootDescribes.collectMode();
|
|
||||||
|
|
||||||
var jasmineTest = TestCase('Jasmine Adapter Tests', null, 'jasmine test case');
|
|
||||||
|
|
||||||
var jasminePlugin = {
|
|
||||||
name:'jasmine',
|
|
||||||
runTestConfiguration: function(testRunConfiguration, onTestDone, onTestRunConfigurationComplete){
|
|
||||||
if (testRunConfiguration.testCaseInfo_.template_ !== jasmineTest) return;
|
|
||||||
|
|
||||||
var jasmineEnv = jasmine.currentEnv_ = new jasmine.Env();
|
|
||||||
rootDescribes.playback();
|
|
||||||
var specLog = jstestdriver.console.log_ = [];
|
|
||||||
var start;
|
|
||||||
jasmineEnv.specFilter = function(spec) {
|
|
||||||
return rootDescribes.isExclusive(spec);
|
|
||||||
};
|
|
||||||
jasmineEnv.reporter = {
|
|
||||||
log: function(str){
|
|
||||||
specLog.push(str);
|
|
||||||
},
|
|
||||||
|
|
||||||
reportRunnerStarting: function(runner) { },
|
|
||||||
|
|
||||||
reportSpecStarting: function(spec) {
|
|
||||||
specLog = jstestdriver.console.log_ = [];
|
|
||||||
start = new Date().getTime();
|
|
||||||
},
|
|
||||||
|
|
||||||
reportSpecResults: function(spec) {
|
|
||||||
var suite = spec.suite;
|
|
||||||
var results = spec.results();
|
|
||||||
if (results.skipped) return;
|
|
||||||
var end = new Date().getTime();
|
|
||||||
var messages = [];
|
|
||||||
var resultItems = results.getItems();
|
|
||||||
var state = 'passed';
|
|
||||||
for ( var i = 0; i < resultItems.length; i++) {
|
|
||||||
if (!resultItems[i].passed()) {
|
|
||||||
state = resultItems[i].message.match(/AssertionError:/) ? 'error' : 'failed';
|
|
||||||
messages.push({
|
|
||||||
message: resultItems[i].toString(),
|
|
||||||
name: resultItems[i].trace.name,
|
|
||||||
stack: formatStack(resultItems[i].trace.stack)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onTestDone(
|
|
||||||
new jstestdriver.TestResult(
|
|
||||||
suite.getFullName(),
|
|
||||||
spec.description,
|
|
||||||
state,
|
|
||||||
jstestdriver.angular.toJson(messages),
|
|
||||||
specLog.join('\n'),
|
|
||||||
end - start));
|
|
||||||
},
|
|
||||||
|
|
||||||
reportSuiteResults: function(suite) {},
|
|
||||||
|
|
||||||
reportRunnerResults: function(runner) {
|
|
||||||
onTestRunConfigurationComplete();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
jasmineEnv.execute();
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
onTestsFinish: function(){
|
|
||||||
jasmine.currentEnv_ = null;
|
|
||||||
rootDescribes.collectMode();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
jstestdriver.pluginRegistrar.register(jasminePlugin);
|
|
||||||
|
|
||||||
function formatStack(stack) {
|
|
||||||
var lines = (stack||'').split(/\r?\n/);
|
|
||||||
var frames = [];
|
|
||||||
for (i = 0; i < lines.length; i++) {
|
|
||||||
if (!lines[i].match(/\/jasmine[\.-]/)) {
|
|
||||||
frames.push(lines[i].replace(/https?:\/\/\w+(:\d+)?\/test\//, '').replace(/^\s*/, ' '));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return frames.join('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop(){}
|
|
||||||
function Describes(window){
|
|
||||||
var describes = {};
|
|
||||||
var beforeEachs = {};
|
|
||||||
var afterEachs = {};
|
|
||||||
// Here we store:
|
|
||||||
// 0: everyone runs
|
|
||||||
// 1: run everything under ddescribe
|
|
||||||
// 2: run only iits (ignore ddescribe)
|
|
||||||
var exclusive = 0;
|
|
||||||
var collectMode = true;
|
|
||||||
intercept('describe', describes);
|
|
||||||
intercept('xdescribe', describes);
|
|
||||||
intercept('beforeEach', beforeEachs);
|
|
||||||
intercept('afterEach', afterEachs);
|
|
||||||
|
|
||||||
function intercept(functionName, collection){
|
|
||||||
window[functionName] = function(desc, fn){
|
|
||||||
if (collectMode) {
|
|
||||||
collection[desc] = function(){
|
|
||||||
jasmine.getEnv()[functionName](desc, fn);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
jasmine.getEnv()[functionName](desc, fn);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
window.ddescribe = function(name, fn){
|
|
||||||
if (exclusive < 1) {
|
|
||||||
exclusive = 1; // run ddescribe only
|
|
||||||
}
|
|
||||||
window.describe(name, function(){
|
|
||||||
var oldIt = window.it;
|
|
||||||
window.it = function(name, fn){
|
|
||||||
fn.exclusive = 1; // run anything under ddescribe
|
|
||||||
jasmine.getEnv().it(name, fn);
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
fn.call(this);
|
|
||||||
} finally {
|
|
||||||
window.it = oldIt;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
window.iit = function(name, fn){
|
|
||||||
exclusive = fn.exclusive = 2; // run only iits
|
|
||||||
jasmine.getEnv().it(name, fn);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
this.collectMode = function() {
|
var Env = function(onTestDone, onComplete){
|
||||||
collectMode = true;
|
jasmine.Env.call(this);
|
||||||
exclusive = 0; // run everything
|
|
||||||
};
|
|
||||||
this.playback = function(){
|
|
||||||
collectMode = false;
|
|
||||||
playback(beforeEachs);
|
|
||||||
playback(afterEachs);
|
|
||||||
playback(describes);
|
|
||||||
|
|
||||||
function playback(set) {
|
this.specFilter = function(spec){
|
||||||
for ( var name in set) {
|
if (!this.exclusive) return true;
|
||||||
set[name]();
|
var blocks = spec.queue.blocks, l = blocks.length;
|
||||||
}
|
for (var i = 0; i < l; i++) if (blocks[i].func.exclusive >= this.exclusive) return true;
|
||||||
}
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.isExclusive = function(spec) {
|
this.reporter = new Reporter(onTestDone, onComplete);
|
||||||
if (exclusive) {
|
};
|
||||||
var blocks = spec.queue.blocks;
|
jasmine.util.inherit(Env, jasmine.Env);
|
||||||
for ( var i = 0; i < blocks.length; i++) {
|
|
||||||
if (blocks[i].func.exclusive >= exclusive) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
})(window);
|
// Here we store:
|
||||||
|
// 0: everyone runs
|
||||||
|
// 1: run everything under ddescribe
|
||||||
|
// 2: run only iits (ignore ddescribe)
|
||||||
|
Env.prototype.exclusive = 0;
|
||||||
|
|
||||||
|
|
||||||
|
Env.prototype.execute = function(){
|
||||||
|
collectMode = false;
|
||||||
|
playback();
|
||||||
|
jasmine.Env.prototype.execute.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var Reporter = function(onTestDone, onComplete){
|
||||||
|
this.onTestDone = onTestDone;
|
||||||
|
this.onComplete = onComplete;
|
||||||
|
this.reset();
|
||||||
|
};
|
||||||
|
jasmine.util.inherit(Reporter, jasmine.Reporter);
|
||||||
|
|
||||||
|
|
||||||
|
Reporter.formatStack = function(stack) {
|
||||||
|
var line, lines = (stack || '').split(/\r?\n/), l = lines.length, frames = [];
|
||||||
|
for (var i = 0; i < l; i++){
|
||||||
|
line = lines[i];
|
||||||
|
if (line.match(/\/jasmine[\.-]/)) continue;
|
||||||
|
frames.push(line.replace(/https?:\/\/\w+(:\d+)?\/test\//, '').replace(/^\s*/, ' '));
|
||||||
|
}
|
||||||
|
return frames.join('\n');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reporter.prototype.reset = function(){
|
||||||
|
this.specLog = jstestdriver.console.log_ = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reporter.prototype.log = function(str){
|
||||||
|
this.specLog.push(str);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reporter.prototype.reportSpecStarting = function(){
|
||||||
|
this.reset();
|
||||||
|
this.start = +new Date();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reporter.prototype.reportSpecResults = function(spec){
|
||||||
|
var elapsed = +new Date() - this.start, results = spec.results();
|
||||||
|
|
||||||
|
if (results.skipped) return;
|
||||||
|
|
||||||
|
var item, state = 'passed', items = results.getItems(), l = items.length, messages = [];
|
||||||
|
for (var i = 0; i < l; i++){
|
||||||
|
item = items[i];
|
||||||
|
if (item.passed()) continue;
|
||||||
|
state = (item.message.indexOf('AssertionError:') != -1) ? 'error' : 'failed';
|
||||||
|
messages.push({
|
||||||
|
message: item + '',
|
||||||
|
name: item.trace.name,
|
||||||
|
stack: Reporter.formatStack(item.trace.stack)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.onTestDone(new jstestdriver.TestResult(
|
||||||
|
spec.suite.getFullName(),
|
||||||
|
spec.description,
|
||||||
|
state,
|
||||||
|
jstestdriver.angular.toJson(messages),
|
||||||
|
this.specLog.join('\n'),
|
||||||
|
elapsed
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reporter.prototype.reportRunnerResults = function(){
|
||||||
|
this.onComplete();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var collectMode = true, intercepted = {};
|
||||||
|
|
||||||
|
describe = intercept('describe');
|
||||||
|
beforeEach = intercept('beforeEach');
|
||||||
|
afterEach = intercept('afterEach');
|
||||||
|
|
||||||
|
var JASMINE_TYPE = 'jasmine test case';
|
||||||
|
TestCase('Jasmine Adapter Tests', null, JASMINE_TYPE);
|
||||||
|
|
||||||
|
jstestdriver.pluginRegistrar.register({
|
||||||
|
|
||||||
|
name: 'jasmine',
|
||||||
|
|
||||||
|
getTestRunsConfigurationFor: function(testCaseInfos, expressions, testRunsConfiguration) {
|
||||||
|
for (var i = 0; i < testCaseInfos.length; i++) {
|
||||||
|
if (testCaseInfos[i].getType() == JASMINE_TYPE) {
|
||||||
|
testRunsConfiguration.push(new jstestdriver.TestRunConfiguration(testCaseInfos[i], []));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false; // allow other TestCases to be collected.
|
||||||
|
},
|
||||||
|
|
||||||
|
runTestConfiguration: function(config, onTestDone, onComplete){
|
||||||
|
if (config.getTestCaseInfo().getType() != JASMINE_TYPE) return false;
|
||||||
|
(jasmine.currentEnv_ = new Env(onTestDone, onComplete)).execute();
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
onTestsFinish: function(){
|
||||||
|
jasmine.currentEnv_ = null;
|
||||||
|
collectMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function intercept(method){
|
||||||
|
var bucket = intercepted[method] = [], method = window[method];
|
||||||
|
return function(desc, fn){
|
||||||
|
if (collectMode) bucket.push(function(){ method(desc, fn); });
|
||||||
|
else method(desc, fn);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function playback(){
|
||||||
|
for (var method in intercepted){
|
||||||
|
var bucket = intercepted[method];
|
||||||
|
for (var i = 0, l = bucket.length; i < l; i++) bucket[i]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
var ddescribe = function(name, fn){
|
||||||
|
var env = jasmine.getEnv();
|
||||||
|
if (!env.exclusive) env.exclusive = 1; // run ddescribe only
|
||||||
|
describe(name, function(){
|
||||||
|
var oldIt = it;
|
||||||
|
it = function(name, fn){
|
||||||
|
fn.exclusive = 1; // run anything under ddescribe
|
||||||
|
env.it(name, fn);
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
fn.call(this);
|
||||||
|
} finally {
|
||||||
|
it = oldIt;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var iit = function(name, fn){
|
||||||
|
var env = jasmine.getEnv();
|
||||||
|
env.exclusive = fn.exclusive = 2; // run only iits
|
||||||
|
env.it(name, fn);
|
||||||
|
};
|
||||||
|
|
||||||
// Patch Jasmine for proper stack traces
|
// Patch Jasmine for proper stack traces
|
||||||
jasmine.Spec.prototype.fail = function (e) {
|
jasmine.Spec.prototype.fail = function (e) {
|
||||||
var expectationResult = new jasmine.ExpectationResult({
|
var result = new jasmine.ExpectationResult({
|
||||||
passed: false,
|
passed: false,
|
||||||
message: e ? jasmine.util.formatException(e) : 'Exception'
|
message: e ? jasmine.util.formatException(e) : 'Exception'
|
||||||
});
|
});
|
||||||
// PATCH
|
if(e) result.trace = e;
|
||||||
if (e) {
|
this.results_.addResult(result);
|
||||||
expectationResult.trace = e;
|
|
||||||
}
|
|
||||||
this.results_.addResult(expectationResult);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2008-2010 Pivotal Labs
|
Copyright (c) 2008-2011 Pivotal Labs
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
|
@ -34,7 +34,7 @@ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||||
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
||||||
this.createDom('div', { className: 'banner' },
|
this.createDom('div', { className: 'banner' },
|
||||||
this.createDom('div', { className: 'logo' },
|
this.createDom('div', { className: 'logo' },
|
||||||
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
|
this.createDom('span', { className: 'title' }, "Jasmine"),
|
||||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||||
this.createDom('div', { className: 'options' },
|
this.createDom('div', { className: 'options' },
|
||||||
"Show ",
|
"Show ",
|
||||||
|
|
@ -110,7 +110,7 @@ jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||||
var results = suite.results();
|
var results = suite.results();
|
||||||
var status = results.passed() ? 'passed' : 'failed';
|
var status = results.passed() ? 'passed' : 'failed';
|
||||||
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
||||||
status = 'skipped';
|
status = 'skipped';
|
||||||
}
|
}
|
||||||
this.suiteDivs[suite.id].className += " " + status;
|
this.suiteDivs[suite.id].className += " " + status;
|
||||||
|
|
@ -183,6 +183,8 @@ jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!paramMap["spec"]) return true;
|
if (!paramMap.spec) {
|
||||||
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
return true;
|
||||||
|
}
|
||||||
|
return spec.getFullName().indexOf(paramMap.spec) === 0;
|
||||||
};
|
};
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
|
var isCommonJS = typeof window == "undefined";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
|
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
|
||||||
*
|
*
|
||||||
* @namespace
|
* @namespace
|
||||||
*/
|
*/
|
||||||
var jasmine = {};
|
var jasmine = {};
|
||||||
|
if (isCommonJS) exports.jasmine = jasmine;
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
|
@ -20,6 +22,12 @@ jasmine.unimplementedMethod_ = function() {
|
||||||
*/
|
*/
|
||||||
jasmine.undefined = jasmine.___undefined___;
|
jasmine.undefined = jasmine.___undefined___;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show diagnostic messages in the console if set to true
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
jasmine.VERBOSE = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed.
|
* Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed.
|
||||||
*
|
*
|
||||||
|
|
@ -72,7 +80,7 @@ jasmine.MessageResult = function(values) {
|
||||||
|
|
||||||
jasmine.MessageResult.prototype.toString = function() {
|
jasmine.MessageResult.prototype.toString = function() {
|
||||||
var text = "";
|
var text = "";
|
||||||
for(var i = 0; i < this.values.length; i++) {
|
for (var i = 0; i < this.values.length; i++) {
|
||||||
if (i > 0) text += " ";
|
if (i > 0) text += " ";
|
||||||
if (jasmine.isString_(this.values[i])) {
|
if (jasmine.isString_(this.values[i])) {
|
||||||
text += this.values[i];
|
text += this.values[i];
|
||||||
|
|
@ -89,9 +97,10 @@ jasmine.ExpectationResult = function(params) {
|
||||||
this.passed_ = params.passed;
|
this.passed_ = params.passed;
|
||||||
this.expected = params.expected;
|
this.expected = params.expected;
|
||||||
this.actual = params.actual;
|
this.actual = params.actual;
|
||||||
|
|
||||||
this.message = this.passed_ ? 'Passed.' : params.message;
|
this.message = this.passed_ ? 'Passed.' : params.message;
|
||||||
this.trace = this.passed_ ? '' : new Error(this.message);
|
|
||||||
|
var trace = (params.trace || new Error(this.message));
|
||||||
|
this.trace = this.passed_ ? '' : trace;
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.ExpectationResult.prototype.toString = function () {
|
jasmine.ExpectationResult.prototype.toString = function () {
|
||||||
|
|
@ -106,7 +115,8 @@ jasmine.ExpectationResult.prototype.passed = function () {
|
||||||
* Getter for the Jasmine environment. Ensures one gets created
|
* Getter for the Jasmine environment. Ensures one gets created
|
||||||
*/
|
*/
|
||||||
jasmine.getEnv = function() {
|
jasmine.getEnv = function() {
|
||||||
return jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
|
var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
|
||||||
|
return env;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -116,7 +126,7 @@ jasmine.getEnv = function() {
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
jasmine.isArray_ = function(value) {
|
jasmine.isArray_ = function(value) {
|
||||||
return jasmine.isA_("Array", value);
|
return jasmine.isA_("Array", value);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -169,7 +179,7 @@ jasmine.pp = function(value) {
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
jasmine.isDomNode = function(obj) {
|
jasmine.isDomNode = function(obj) {
|
||||||
return obj['nodeType'] > 0;
|
return obj.nodeType > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -405,7 +415,7 @@ jasmine.isSpy = function(putativeSpy) {
|
||||||
* @param {Array} methodNames array of names of methods to make spies
|
* @param {Array} methodNames array of names of methods to make spies
|
||||||
*/
|
*/
|
||||||
jasmine.createSpyObj = function(baseName, methodNames) {
|
jasmine.createSpyObj = function(baseName, methodNames) {
|
||||||
if (!jasmine.isArray_(methodNames) || methodNames.length == 0) {
|
if (!jasmine.isArray_(methodNames) || methodNames.length === 0) {
|
||||||
throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
|
throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
|
||||||
}
|
}
|
||||||
var obj = {};
|
var obj = {};
|
||||||
|
|
@ -443,6 +453,7 @@ jasmine.log = function() {
|
||||||
var spyOn = function(obj, methodName) {
|
var spyOn = function(obj, methodName) {
|
||||||
return jasmine.getEnv().currentSpec.spyOn(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.
|
* Creates a Jasmine spec that will be added to the current suite.
|
||||||
|
|
@ -460,6 +471,7 @@ var spyOn = function(obj, methodName) {
|
||||||
var it = function(desc, func) {
|
var it = function(desc, func) {
|
||||||
return jasmine.getEnv().it(desc, func);
|
return jasmine.getEnv().it(desc, func);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.it = it;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a <em>disabled</em> Jasmine spec.
|
* Creates a <em>disabled</em> Jasmine spec.
|
||||||
|
|
@ -472,6 +484,7 @@ var it = function(desc, func) {
|
||||||
var xit = function(desc, func) {
|
var xit = function(desc, func) {
|
||||||
return jasmine.getEnv().xit(desc, func);
|
return jasmine.getEnv().xit(desc, func);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.xit = xit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a chain for a Jasmine expectation.
|
* Starts a chain for a Jasmine expectation.
|
||||||
|
|
@ -484,6 +497,7 @@ var xit = function(desc, func) {
|
||||||
var expect = function(actual) {
|
var expect = function(actual) {
|
||||||
return jasmine.getEnv().currentSpec.expect(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.
|
* Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
|
||||||
|
|
@ -493,6 +507,7 @@ var expect = function(actual) {
|
||||||
var runs = function(func) {
|
var runs = function(func) {
|
||||||
jasmine.getEnv().currentSpec.runs(func);
|
jasmine.getEnv().currentSpec.runs(func);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.runs = runs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits a fixed time period before moving to the next block.
|
* Waits a fixed time period before moving to the next block.
|
||||||
|
|
@ -503,6 +518,7 @@ var runs = function(func) {
|
||||||
var waits = function(timeout) {
|
var waits = function(timeout) {
|
||||||
jasmine.getEnv().currentSpec.waits(timeout);
|
jasmine.getEnv().currentSpec.waits(timeout);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.waits = waits;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits for the latchFunction to return true before proceeding to the next block.
|
* Waits for the latchFunction to return true before proceeding to the next block.
|
||||||
|
|
@ -514,6 +530,7 @@ var waits = function(timeout) {
|
||||||
var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
|
var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
|
||||||
jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
|
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.
|
* A function that is called before each spec in a suite.
|
||||||
|
|
@ -525,6 +542,7 @@ var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout
|
||||||
var beforeEach = function(beforeEachFunction) {
|
var beforeEach = function(beforeEachFunction) {
|
||||||
jasmine.getEnv().beforeEach(beforeEachFunction);
|
jasmine.getEnv().beforeEach(beforeEachFunction);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.beforeEach = beforeEach;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function that is called after each spec in a suite.
|
* A function that is called after each spec in a suite.
|
||||||
|
|
@ -536,6 +554,7 @@ var beforeEach = function(beforeEachFunction) {
|
||||||
var afterEach = function(afterEachFunction) {
|
var afterEach = function(afterEachFunction) {
|
||||||
jasmine.getEnv().afterEach(afterEachFunction);
|
jasmine.getEnv().afterEach(afterEachFunction);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.afterEach = afterEach;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a suite of specifications.
|
* Defines a suite of specifications.
|
||||||
|
|
@ -555,6 +574,7 @@ var afterEach = function(afterEachFunction) {
|
||||||
var describe = function(description, specDefinitions) {
|
var describe = function(description, specDefinitions) {
|
||||||
return jasmine.getEnv().describe(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.
|
* Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
|
||||||
|
|
@ -565,27 +585,35 @@ var describe = function(description, specDefinitions) {
|
||||||
var xdescribe = function(description, specDefinitions) {
|
var xdescribe = function(description, specDefinitions) {
|
||||||
return jasmine.getEnv().xdescribe(description, specDefinitions);
|
return jasmine.getEnv().xdescribe(description, specDefinitions);
|
||||||
};
|
};
|
||||||
|
if (isCommonJS) exports.xdescribe = xdescribe;
|
||||||
|
|
||||||
|
|
||||||
// Provide the XMLHttpRequest class for IE 5.x-6.x:
|
// Provide the XMLHttpRequest class for IE 5.x-6.x:
|
||||||
jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
|
jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
|
||||||
try {
|
function tryIt(f) {
|
||||||
|
try {
|
||||||
|
return f();
|
||||||
|
} catch(e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var xhr = tryIt(function() {
|
||||||
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
|
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
|
||||||
} catch(e) {
|
}) ||
|
||||||
}
|
tryIt(function() {
|
||||||
try {
|
return new ActiveXObject("Msxml2.XMLHTTP.3.0");
|
||||||
return new ActiveXObject("Msxml2.XMLHTTP.3.0");
|
}) ||
|
||||||
} catch(e) {
|
tryIt(function() {
|
||||||
}
|
return new ActiveXObject("Msxml2.XMLHTTP");
|
||||||
try {
|
}) ||
|
||||||
return new ActiveXObject("Msxml2.XMLHTTP");
|
tryIt(function() {
|
||||||
} catch(e) {
|
return new ActiveXObject("Microsoft.XMLHTTP");
|
||||||
}
|
});
|
||||||
try {
|
|
||||||
return new ActiveXObject("Microsoft.XMLHTTP");
|
if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
|
||||||
} catch(e) {
|
|
||||||
}
|
return xhr;
|
||||||
throw new Error("This browser does not support XMLHttpRequest.");
|
|
||||||
} : XMLHttpRequest;
|
} : XMLHttpRequest;
|
||||||
/**
|
/**
|
||||||
* @namespace
|
* @namespace
|
||||||
|
|
@ -606,7 +634,7 @@ jasmine.util.inherit = function(childClass, parentClass) {
|
||||||
var subclass = function() {
|
var subclass = function() {
|
||||||
};
|
};
|
||||||
subclass.prototype = parentClass.prototype;
|
subclass.prototype = parentClass.prototype;
|
||||||
childClass.prototype = new subclass;
|
childClass.prototype = new subclass();
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.util.formatException = function(e) {
|
jasmine.util.formatException = function(e) {
|
||||||
|
|
@ -707,12 +735,17 @@ jasmine.Env.prototype.version = function () {
|
||||||
* @returns string containing jasmine version build info, if set.
|
* @returns string containing jasmine version build info, if set.
|
||||||
*/
|
*/
|
||||||
jasmine.Env.prototype.versionString = function() {
|
jasmine.Env.prototype.versionString = function() {
|
||||||
if (jasmine.version_) {
|
if (!jasmine.version_) {
|
||||||
var version = this.version();
|
|
||||||
return version.major + "." + version.minor + "." + version.build + " revision " + version.revision;
|
|
||||||
} else {
|
|
||||||
return "version unknown";
|
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -760,14 +793,14 @@ jasmine.Env.prototype.describe = function(description, specDefinitions) {
|
||||||
declarationError = e;
|
declarationError = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentSuite = parentSuite;
|
|
||||||
|
|
||||||
if (declarationError) {
|
if (declarationError) {
|
||||||
this.it("encountered a declaration exception", function() {
|
this.it("encountered a declaration exception", function() {
|
||||||
throw declarationError;
|
throw declarationError;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.currentSuite = parentSuite;
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -828,7 +861,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
|
||||||
b.__Jasmine_been_here_before__ = a;
|
b.__Jasmine_been_here_before__ = a;
|
||||||
|
|
||||||
var hasKey = function(obj, keyName) {
|
var hasKey = function(obj, keyName) {
|
||||||
return obj != null && obj[keyName] !== jasmine.undefined;
|
return obj !== null && obj[keyName] !== jasmine.undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var property in b) {
|
for (var property in b) {
|
||||||
|
|
@ -854,7 +887,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
|
||||||
|
|
||||||
delete a.__Jasmine_been_here_before__;
|
delete a.__Jasmine_been_here_before__;
|
||||||
delete b.__Jasmine_been_here_before__;
|
delete b.__Jasmine_been_here_before__;
|
||||||
return (mismatchKeys.length == 0 && mismatchValues.length == 0);
|
return (mismatchKeys.length === 0 && mismatchValues.length === 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
||||||
|
|
@ -1302,16 +1335,16 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
|
||||||
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
||||||
}
|
}
|
||||||
this.message = function() {
|
this.message = function() {
|
||||||
if (this.actual.callCount == 0) {
|
if (this.actual.callCount === 0) {
|
||||||
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
|
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
|
||||||
return [
|
return [
|
||||||
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
||||||
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
|
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
|
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
|
||||||
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
|
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1333,7 +1366,7 @@ jasmine.Matchers.prototype.wasNotCalledWith = function() {
|
||||||
return [
|
return [
|
||||||
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
|
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
|
||||||
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
|
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
|
||||||
]
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
return !this.env.contains_(this.actual.argsForCall, expectedArgs);
|
return !this.env.contains_(this.actual.argsForCall, expectedArgs);
|
||||||
|
|
@ -1366,6 +1399,23 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
|
||||||
return this.actual > expected;
|
return this.actual > expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Matcher that checks that the expected item is equal to the actual item
|
||||||
|
* up to a given level of decimal precision (default 2).
|
||||||
|
*
|
||||||
|
* @param {Number} expected
|
||||||
|
* @param {Number} precision
|
||||||
|
*/
|
||||||
|
jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
|
||||||
|
if (!(precision === 0)) {
|
||||||
|
precision = precision || 2;
|
||||||
|
}
|
||||||
|
var multiplier = Math.pow(10, precision);
|
||||||
|
var actual = Math.round(this.actual * multiplier);
|
||||||
|
expected = Math.round(expected * multiplier);
|
||||||
|
return expected == actual;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that checks that the expected exception was thrown by the actual.
|
* Matcher that checks that the expected exception was thrown by the actual.
|
||||||
*
|
*
|
||||||
|
|
@ -1390,7 +1440,7 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
|
||||||
|
|
||||||
this.message = function() {
|
this.message = function() {
|
||||||
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
||||||
return ["Expected function " + not + "to throw", expected ? expected.message || expected : " an exception", ", but it threw", exception.message || exception].join(' ');
|
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
|
||||||
} else {
|
} else {
|
||||||
return "Expected function to throw an exception.";
|
return "Expected function to throw an exception.";
|
||||||
}
|
}
|
||||||
|
|
@ -1602,7 +1652,8 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||||
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
||||||
for (var property in obj) {
|
for (var property in obj) {
|
||||||
if (property == '__Jasmine_been_here_before__') continue;
|
if (property == '__Jasmine_been_here_before__') continue;
|
||||||
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false);
|
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
|
||||||
|
obj.__lookupGetter__(property) !== null) : false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1962,7 +2013,8 @@ jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessag
|
||||||
jasmine.Spec.prototype.fail = function (e) {
|
jasmine.Spec.prototype.fail = function (e) {
|
||||||
var expectationResult = new jasmine.ExpectationResult({
|
var expectationResult = new jasmine.ExpectationResult({
|
||||||
passed: false,
|
passed: false,
|
||||||
message: e ? jasmine.util.formatException(e) : 'Exception'
|
message: e ? jasmine.util.formatException(e) : 'Exception',
|
||||||
|
trace: { stack: e.stack }
|
||||||
});
|
});
|
||||||
this.results_.addResult(expectationResult);
|
this.results_.addResult(expectationResult);
|
||||||
};
|
};
|
||||||
|
|
@ -2172,7 +2224,9 @@ jasmine.WaitsBlock = function(env, timeout, spec) {
|
||||||
jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
|
jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
|
||||||
|
|
||||||
jasmine.WaitsBlock.prototype.execute = function (onComplete) {
|
jasmine.WaitsBlock.prototype.execute = function (onComplete) {
|
||||||
this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
|
if (jasmine.VERBOSE) {
|
||||||
|
this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
|
||||||
|
}
|
||||||
this.env.setTimeout(function () {
|
this.env.setTimeout(function () {
|
||||||
onComplete();
|
onComplete();
|
||||||
}, this.timeout);
|
}, this.timeout);
|
||||||
|
|
@ -2200,8 +2254,9 @@ jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
|
||||||
jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10;
|
jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10;
|
||||||
|
|
||||||
jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
|
jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
|
||||||
// (i): disabled this log since its annoying
|
if (jasmine.VERBOSE) {
|
||||||
//this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
|
this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
|
||||||
|
}
|
||||||
var latchFunctionResult;
|
var latchFunctionResult;
|
||||||
try {
|
try {
|
||||||
latchFunctionResult = this.latchFunction.apply(this.spec);
|
latchFunctionResult = this.latchFunction.apply(this.spec);
|
||||||
|
|
@ -2413,10 +2468,9 @@ jasmine.getGlobal().clearInterval = function(timeoutKey) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
jasmine.version_= {
|
jasmine.version_= {
|
||||||
"major": 1,
|
"major": 1,
|
||||||
"minor": 0,
|
"minor": 1,
|
||||||
"build": 1,
|
"build": 0,
|
||||||
"revision": 1286311016
|
"revision": 1315677058
|
||||||
};
|
};
|
||||||
BIN
lib/jasmine/jasmine_favicon.png
Normal file
BIN
lib/jasmine/jasmine_favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 905 B |
1
lib/jasmine/version.txt
Normal file
1
lib/jasmine/version.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
1.1.0
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
1.3.2
|
1.3.3c
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue