jasmine-expect
Advanced tools
Comparing version 1.21.0 to 1.22.0
/* | ||
* Copyright © 2013 Jamie Mason, @GotNoSugarBaby, | ||
* Copyright © 2013 Jamie Mason, @fold_left, | ||
* https://github.com/JamieMason | ||
@@ -34,4 +34,10 @@ * | ||
var len = array.length; | ||
for (i = 0; i < len; i++) { | ||
fn.call(this, array[i], i, array); | ||
if ('length' in array) { | ||
for (i = 0; i < len; i++) { | ||
fn.call(this, array[i], i, array); | ||
} | ||
} else { | ||
for (i in array) { | ||
fn.call(this, array[i], i, array); | ||
} | ||
} | ||
@@ -76,2 +82,3 @@ }; | ||
*/ | ||
priv.is = function(subject, type) { | ||
@@ -85,2 +92,3 @@ return Object.prototype.toString.call(subject) === '[object ' + type + ']'; | ||
*/ | ||
priv.isHtmlElementOfType = function(subject, type) { | ||
@@ -95,2 +103,3 @@ return subject && subject.nodeType === type; | ||
*/ | ||
priv.toArray = function (list) { | ||
@@ -106,3 +115,3 @@ return [].slice.call(list); | ||
return matchers.toBeArray.call(this) && priv.expectAllMembers.call(this, toBeX); | ||
} | ||
}; | ||
}; | ||
@@ -601,4 +610,30 @@ | ||
this.addMatchers(matchers); | ||
// Create adapters for the original matchers so they can be compatible with Jasmine 2.0. | ||
var isJasmineV1 = typeof this.addMatchers === 'function'; | ||
var isJasmineV2 = typeof jasmine.addMatchers === 'function'; | ||
var v2Matchers = {}; | ||
if (isJasmineV1) { | ||
this.addMatchers(matchers); | ||
} else if (isJasmineV2) { | ||
priv.each(matchers, function(fn, name) { | ||
v2Matchers[name] = function() { | ||
return { | ||
compare: function(actual, expected) { | ||
var args = priv.toArray(arguments); | ||
var scope = { | ||
actual: actual | ||
}; | ||
args.shift(); | ||
return { | ||
pass: matchers[name].apply(scope, args) | ||
}; | ||
} | ||
}; | ||
}; | ||
}); | ||
jasmine.addMatchers(v2Matchers); | ||
} | ||
}); |
@@ -27,2 +27,3 @@ module.exports = function(grunt) { | ||
'src/*.js', | ||
'src/wrapper/add-matchers-adapter.js', | ||
'src/wrapper/foot.txt' | ||
@@ -29,0 +30,0 @@ ], |
@@ -1,16 +0,30 @@ | ||
files = [ | ||
JASMINE, | ||
JASMINE_ADAPTER, | ||
'dist/jasmine-matchers.js', | ||
'test/*.test.js' | ||
]; | ||
/*global process:true */ | ||
exclude = [ | ||
'karma.conf.js' | ||
]; | ||
module.exports = function(config) { | ||
autoWatch = true; | ||
'use strict'; | ||
reporters = ['progress']; | ||
config.set({ | ||
port = 7357; | ||
frameworks: ['jasmine'], | ||
files: [ | ||
'dist/jasmine-matchers.js', | ||
'test/*.test.js' | ||
], | ||
preprocessors: { | ||
'**/dist/*.js': ['coverage'] | ||
}, | ||
autoWatch: true, | ||
reporters: ['progress', 'coverage'], | ||
coverageReporter: { | ||
type: 'html', | ||
dir: 'build/coverage/' | ||
} | ||
}); | ||
}; |
{ | ||
"name": "jasmine-expect", | ||
"version": "1.21.0", | ||
"version": "1.22.0", | ||
"description": "35+ additional matchers for the Jasmine BDD JavaScript test library", | ||
"main": "index.js", | ||
"author": "Jamie Mason (https://github.com/JamieMason)", | ||
"contributors": [ | ||
"Jamie Mason (https://github.com/JamieMason)", | ||
"David Tanner (https://github.com/DavidTanner)" | ||
], | ||
"license": "MIT", | ||
"gitHead": "76aba51fb924e3f3c9b172174a7ee7296a0d950b", | ||
"readmeFilename": "README.md", | ||
"devDependencies": { | ||
"karma": "~0.8", | ||
"grunt": "~0.4.1", | ||
"grunt-contrib-concat": "~0.3.0", | ||
"grunt-contrib-watch": "~0.4.4" | ||
"grunt": "^0.4.5", | ||
"grunt-contrib-concat": "^0.5.0", | ||
"grunt-contrib-watch": "^0.6.1", | ||
"karma": "^0.12.17", | ||
"karma-chrome-launcher": "^0.1.4", | ||
"karma-coverage": "^0.2.4", | ||
"karma-firefox-launcher": "^0.1.3", | ||
"karma-jasmine": "^0.1.5", | ||
"karma-phantomjs-launcher": "^0.1.4", | ||
"karma-script-launcher": "^0.1.0" | ||
}, | ||
"scripts": { | ||
"test": "./node_modules/.bin/karma start --single-run --browsers PhantomJS" | ||
"test": "./node_modules/karma/bin/karma start --single-run --browsers PhantomJS" | ||
}, | ||
@@ -19,0 +28,0 @@ "repository": { |
@@ -7,3 +7,3 @@ // Arrays | ||
return matchers.toBeArray.call(this) && priv.expectAllMembers.call(this, toBeX); | ||
} | ||
}; | ||
}; | ||
@@ -10,0 +10,0 @@ |
priv.each = function(array, fn) { | ||
var i; | ||
var len = array.length; | ||
for (i = 0; i < len; i++) { | ||
fn.call(this, array[i], i, array); | ||
if ('length' in array) { | ||
for (i = 0; i < len; i++) { | ||
fn.call(this, array[i], i, array); | ||
} | ||
} else { | ||
for (i in array) { | ||
fn.call(this, array[i], i, array); | ||
} | ||
} | ||
@@ -7,0 +13,0 @@ }; |
@@ -1,3 +0,1 @@ | ||
this.addMatchers(matchers); | ||
}); |
/* | ||
* Copyright © 2013 Jamie Mason, @GotNoSugarBaby, | ||
* Copyright © 2013 Jamie Mason, @fold_left, | ||
* https://github.com/JamieMason | ||
@@ -4,0 +4,0 @@ * |
63106
31
1678
10