Skip to content

Commit 4d79726

Browse files
fix: isEql to align with isObj
1 parent 66bdf45 commit 4d79726

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

packages/std/__tests__/assert/isEql.spec.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { isEql } from '../../src';
22

3+
class A {
4+
constructor() {
5+
this.a = 1;
6+
}
7+
}
8+
39
describe('Assert => isEql', () => {
410
test('truthy', () => {
511
expect(isEql()).toBe(true);
@@ -57,17 +63,6 @@ describe('Assert => isEql', () => {
5763
expect(isEql(o1, o2)).toBe(true);
5864
}
5965

60-
class A {
61-
constructor() {
62-
this.a = 1;
63-
}
64-
}
65-
66-
const first = new A();
67-
const second = { a: 1 };
68-
69-
expect(isEql(first, second)).toBe(true);
70-
7166
expect(isEql(new Int16Array([1, 2]), new Int16Array([1, 2]))).toBe(true);
7267

7368
expect(
@@ -130,6 +125,10 @@ describe('Assert => isEql', () => {
130125
expect(isEql(re, re2)).toBe(false);
131126

132127
expect(isEql([1, , 2], [1, undefined, 2])).toBe(false);
128+
129+
const first = new A();
130+
const second = { a: 1 };
131+
expect(isEql(first, second)).toBe(false);
133132
});
134133

135134
test('Deep objs with all supported types in it', () => {

packages/std/src/assert/isEql.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ function isEqlVal(
3838
}
3939

4040
// Check both has same type string tag
41-
if (typeof val1 !== typeof val2) {
41+
if (
42+
Object.prototype.toString.call(val1) !==
43+
Object.prototype.toString.call(val2)
44+
) {
4245
return false;
4346
}
4447

0 commit comments

Comments
 (0)