@jest/expect-utils 30.0.0-alpha.4 → 30.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/build/index.js +14 -8
  2. package/package.json +4 -4
package/build/index.js CHANGED
@@ -177,17 +177,17 @@ function eq(a, b, aStack, bStack, customTesters, strictCheck) {
177
177
  }
178
178
  }
179
179
  if (a instanceof Error && b instanceof Error) {
180
- return a.message == b.message;
180
+ return a.message === b.message;
181
181
  }
182
182
  if (Object.is(a, b)) {
183
183
  return true;
184
184
  }
185
185
  // A strict comparison is necessary because `null == undefined`.
186
186
  if (a === null || b === null) {
187
- return a === b;
187
+ return false;
188
188
  }
189
189
  const className = Object.prototype.toString.call(a);
190
- if (className != Object.prototype.toString.call(b)) {
190
+ if (className !== Object.prototype.toString.call(b)) {
191
191
  return false;
192
192
  }
193
193
  switch (className) {
@@ -199,7 +199,7 @@ function eq(a, b, aStack, bStack, customTesters, strictCheck) {
199
199
  return false;
200
200
  } else if (typeof a !== 'object' && typeof b !== 'object') {
201
201
  // both are proper primitives
202
- return Object.is(a, b);
202
+ return false;
203
203
  } else {
204
204
  // both are `new Primitive()`s
205
205
  return Object.is(a.valueOf(), b.valueOf());
@@ -208,7 +208,7 @@ function eq(a, b, aStack, bStack, customTesters, strictCheck) {
208
208
  // Coerce dates to numeric primitive values. Dates are compared by their
209
209
  // millisecond representations. Note that invalid dates with millisecond representations
210
210
  // of `NaN` are not equivalent.
211
- return +a == +b;
211
+ return +a === +b;
212
212
  // RegExps are compared by their source patterns and flags.
213
213
  case '[object RegExp]':
214
214
  return a.source === b.source && a.flags === b.flags;
@@ -243,7 +243,7 @@ function eq(a, b, aStack, bStack, customTesters, strictCheck) {
243
243
  bStack.push(b);
244
244
  // Recursively compare objects and arrays.
245
245
  // Compare array lengths to determine if a deep comparison is necessary.
246
- if (strictCheck && className == '[object Array]' && a.length !== b.length) {
246
+ if (strictCheck && className === '[object Array]' && a.length !== b.length) {
247
247
  return false;
248
248
  }
249
249
 
@@ -426,7 +426,7 @@ const hasIterator = object => !!(object != null && object[IteratorSymbol]);
426
426
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
427
427
  const iterableEquality = (a, b, customTesters = [], /* eslint-enable @typescript-eslint/explicit-module-boundary-types */
428
428
  aStack = [], bStack = []) => {
429
- if (typeof a !== 'object' || typeof b !== 'object' || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b)) {
429
+ if (typeof a !== 'object' || typeof b !== 'object' || Array.isArray(a) || Array.isArray(b) || ArrayBuffer.isView(a) || ArrayBuffer.isView(b) || !hasIterator(a) || !hasIterator(b)) {
430
430
  return undefined;
431
431
  }
432
432
  if (a.constructor !== b.constructor) {
@@ -581,9 +581,12 @@ exports.typeEquality = typeEquality;
581
581
  const arrayBufferEquality = (a, b) => {
582
582
  let dataViewA = a;
583
583
  let dataViewB = b;
584
- if (a instanceof ArrayBuffer && b instanceof ArrayBuffer) {
584
+ if (isArrayBuffer(a) && isArrayBuffer(b)) {
585
585
  dataViewA = new DataView(a);
586
586
  dataViewB = new DataView(b);
587
+ } else if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
588
+ dataViewA = new DataView(a.buffer, a.byteOffset, a.byteLength);
589
+ dataViewB = new DataView(b.buffer, b.byteOffset, b.byteLength);
587
590
  }
588
591
  if (!(dataViewA instanceof DataView && dataViewB instanceof DataView)) {
589
592
  return undefined;
@@ -603,6 +606,9 @@ const arrayBufferEquality = (a, b) => {
603
606
  return true;
604
607
  };
605
608
  exports.arrayBufferEquality = arrayBufferEquality;
609
+ function isArrayBuffer(obj) {
610
+ return Object.prototype.toString.call(obj) === '[object ArrayBuffer]';
611
+ }
606
612
  const sparseArrayEquality = (a, b, customTesters = []) => {
607
613
  if (!Array.isArray(a) || !Array.isArray(b)) {
608
614
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jest/expect-utils",
3
- "version": "30.0.0-alpha.4",
3
+ "version": "30.0.0-alpha.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/jestjs/jest.git",
@@ -19,11 +19,11 @@
19
19
  "./package.json": "./package.json"
20
20
  },
21
21
  "dependencies": {
22
- "jest-get-type": "30.0.0-alpha.4"
22
+ "jest-get-type": "30.0.0-alpha.6"
23
23
  },
24
24
  "devDependencies": {
25
25
  "immutable": "^4.0.0",
26
- "jest-matcher-utils": "30.0.0-alpha.4"
26
+ "jest-matcher-utils": "30.0.0-alpha.6"
27
27
  },
28
28
  "engines": {
29
29
  "node": "^16.10.0 || ^18.12.0 || >=20.0.0"
@@ -31,5 +31,5 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "32b966f988d47a7673d2ef4b92e834dab7d66f07"
34
+ "gitHead": "ba74b7de1b9cca88daf33f9d1b46bfe2b7f485a5"
35
35
  }