Add support for ArrayBuffers to matcherUtil.equals.

Fixes #1687
This commit is contained in:
Daniel Kurka
2019-05-02 09:49:21 -07:00
parent afb24d1050
commit 2745d7d515
2 changed files with 46 additions and 1 deletions

View File

@@ -164,7 +164,7 @@ describe("matchersUtil", function() {
expect(jasmineUnderTest.matchersUtil.equals(a,b)).toBe(true);
});
it("passes for equivalent Promises (GitHub issue #1314)", function() {
if (typeof Promise === 'undefined') { return; }
@@ -524,6 +524,20 @@ describe("matchersUtil", function() {
expect(jasmineUnderTest.matchersUtil.equals(mapA, mapB)).toBe(false);
});
it("passes for ArrayBuffers with same length and content", function() {
var buffer1 = new ArrayBuffer(4);
var buffer2 = new ArrayBuffer(4);
expect(jasmineUnderTest.matchersUtil.equals(buffer1, buffer2)).toBe(true);
});
it("fails for ArrayBuffers with same length but different content", function() {
var buffer1 = new ArrayBuffer(4);
var buffer2 = new ArrayBuffer(4);
var array1 = new Uint8Array(buffer1);
array1[0] = 1;
expect(jasmineUnderTest.matchersUtil.equals(buffer1, buffer2)).toBe(false);
});
describe("when running in an environment with array polyfills", function() {
var findIndexDescriptor = Object.getOwnPropertyDescriptor(Array.prototype, 'findIndex');
if (!findIndexDescriptor) {