Merge branch 'seanparmelee-keys-fix'

- Merges #1326 from @seanparmelee
- Fixes #1321
- Fixes #1324
This commit is contained in:
Gregg Van Hove
2017-04-25 13:47:53 -07:00
2 changed files with 48 additions and 1 deletions

View File

@@ -413,6 +413,53 @@ describe("matchersUtil", function() {
var setB = new Set([6, 3]);
expect(jasmineUnderTest.matchersUtil.equals(setA, setB)).toBe(false);
});
describe("when running in an environment with array polyfills", function() {
// IE 8 doesn't support `definePropery` on non-DOM nodes
if (jasmine.getEnv().ieVersion < 9) { return; }
var findIndexDescriptor = Object.getOwnPropertyDescriptor(Array.prototype, 'findIndex');
if (!findIndexDescriptor) {
return;
}
beforeEach(function() {
Object.defineProperty(Array.prototype, 'findIndex', {
enumerable: true,
value: function (predicate) {
if (this === null) {
throw new TypeError('Array.prototype.findIndex called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;
for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return i;
}
}
return -1;
}
});
});
afterEach(function() {
Object.defineProperty(Array.prototype, 'findIndex', findIndexDescriptor);
});
it("passes when there's an array polyfill", function() {
expect(['foo']).toEqual(['foo']);
});
});
});
describe("contains", function() {

View File

@@ -327,7 +327,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
}
var extraKeys = [];
for (var i in allKeys) {
for (var i = 0; i < allKeys.length; i++) {
if (!allKeys[i].match(/^[0-9]+$/)) {
extraKeys.push(allKeys[i]);
}