unexpected
Advanced tools
Comparing version 1.1.0 to 1.1.2
@@ -110,2 +110,6 @@ // Copyright (c) 2013 Sune Simonsen <sune@we-knowhow.dk> | ||
Unexpected.prototype.installPlugin = function (plugin) { | ||
plugin(this.expect); | ||
}; | ||
Unexpected.prototype.expect = function (subject, testDescriptionString) { | ||
@@ -159,2 +163,3 @@ if (arguments.length < 2) { | ||
expect.assertions = unexpected.assertions; | ||
expect.installPlugin = bind(unexpected.installPlugin, unexpected); | ||
return expect; | ||
@@ -628,5 +633,5 @@ } | ||
var errors = []; | ||
forEach(getKeys(obj), function (key) { | ||
forEach(getKeys(obj), function (key, index) { | ||
try { | ||
callback(obj[key]); | ||
callback(obj[key], index); | ||
} catch (e) { | ||
@@ -633,0 +638,0 @@ errors.push(' ' + key + ': ' + e.message.replace(/\n/g, '\n ')); |
{ | ||
"name": "unexpected", | ||
"version": "1.1.0", | ||
"version": "1.1.2", | ||
"author": "Sune Sloth Simonsen <sune@we-knowhow.dk>", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -310,3 +310,3 @@ # Unexpected | ||
```js | ||
expect([0, 1, 2, 3, 4], 'to be an array whose items satisfy', function (item) { | ||
expect([0, 1, 2, 3, 4], 'to be an array whose items satisfy', function (item, index) { | ||
expect(item, 'to be a number'); | ||
@@ -313,0 +313,0 @@ }); |
@@ -678,8 +678,10 @@ /*global describe, it, expect*/ | ||
it('asserts that the given callback does not throw for any items in the array', function () { | ||
expect([0,1,2,3], 'to be an array whose items satisfy', function (item) { | ||
expect([0,1,2,3], 'to be an array whose items satisfy', function (item, index) { | ||
expect(item, 'to be a number'); | ||
expect(index, 'to be a number'); | ||
}); | ||
expect(['0','1','2','3'], 'to be an array whose items satisfy', function (item) { | ||
expect(['0','1','2','3'], 'to be an array whose items satisfy', function (item, index) { | ||
expect(item, 'not to be a number'); | ||
expect(index, 'to be a number'); | ||
}); | ||
@@ -694,2 +696,10 @@ | ||
it('provides the item index to the callback function', function () { | ||
var arr = ['0','1','2','3']; | ||
expect(arr, 'to be an array whose items satisfy', function (item, index) { | ||
expect(index, 'to be a number'); | ||
expect(index, 'to be', arr.indexOf(item)); | ||
}); | ||
}); | ||
it('fails when the assertion fails', function () { | ||
@@ -1099,2 +1109,12 @@ expect(function () { | ||
}); | ||
describe('installPlugin', function () { | ||
it('calls the given plugin with the expect instance as the paramenter', function (done) { | ||
var plugin = function (expectInstance) { | ||
expect(expectInstance, 'to be', expect); | ||
done(); | ||
}; | ||
expect.installPlugin(plugin); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
231990
6832