mirror of https://github.com/codefeathers/isEq
Muthu Kumar
7 years ago
5 changed files with 892 additions and 692 deletions
File diff suppressed because it is too large
@ -0,0 +1,91 @@ |
|||
'use strict'; |
|||
|
|||
const isEq = require('../umd/isEq.min.js'); |
|||
|
|||
describe("Objects (equality):", () => { |
|||
|
|||
it("Comparing same object references", () => { |
|||
const a = { |
|||
'x': 10, |
|||
'y': 20 |
|||
}; |
|||
const b = a; |
|||
|
|||
expect(isEq(a, b)).toBe(true); |
|||
}) |
|||
|
|||
it("Comparing two equal simple objects", () => { |
|||
const a = { |
|||
'x': 10, |
|||
'y': 20, |
|||
'isAlive': true, |
|||
'power': 'Over 9000' |
|||
}; |
|||
const b = { |
|||
'x': 10, |
|||
'y': 20, |
|||
'isAlive': true, |
|||
'power': 'Over 9000' |
|||
}; |
|||
|
|||
expect(isEq(a, b)).toBe(true); |
|||
}) |
|||
|
|||
it("Comparing two equal nested objects", () => { |
|||
const a = { |
|||
'x': 10, |
|||
'y': 20, |
|||
'isAlive': true, |
|||
'power': 'Over 9000', |
|||
'props': { |
|||
'abilities': [ 'run', 'fight' ], |
|||
} |
|||
}; |
|||
const b = { |
|||
'x': 10, |
|||
'y': 20, |
|||
'isAlive': true, |
|||
'power': 'Over 9000', |
|||
'props': { |
|||
'abilities': [ 'run', 'fight' ], |
|||
} |
|||
}; |
|||
|
|||
expect(isEq(a, b)).toBe(true); |
|||
}) |
|||
|
|||
it("Comparing two equal nested objects with external reference", () => { |
|||
const abilities = [ 'run', 'fight' ]; |
|||
|
|||
const a = { |
|||
'x': 10, |
|||
'y': 20, |
|||
'isAlive': true, |
|||
'power': 'Over 9000', |
|||
'props': { |
|||
abilities, |
|||
} |
|||
}; |
|||
const b = { |
|||
'x': 10, |
|||
'y': 20, |
|||
'isAlive': true, |
|||
'power': 'Over 9000', |
|||
'props': { |
|||
abilities |
|||
} |
|||
}; |
|||
|
|||
expect(isEq(a, b)).toBe(true); |
|||
}) |
|||
|
|||
it("Comparing two equal cyclic objects", () => { |
|||
const a = {}; |
|||
a.a = a; |
|||
|
|||
const b = { a }; |
|||
|
|||
expect(isEq(a, b)).toBe(true); |
|||
}) |
|||
|
|||
}) |
@ -0,0 +1,81 @@ |
|||
'use strict'; |
|||
|
|||
const isEq = require('../umd/isEq.min.js'); |
|||
|
|||
describe("Primitives (equality):", () => { |
|||
|
|||
it("Comparing two equal numbers", () => { |
|||
const a = 10; |
|||
const b = 10; |
|||
|
|||
expect(isEq(a, b)).toBe(true); |
|||
}) |
|||
|
|||
it("Comparing two equal strings", () => { |
|||
const a = 'Hello!'; |
|||
const b = 'Hello!'; |
|||
|
|||
expect(isEq(a, b)).toBe(true); |
|||
}) |
|||
|
|||
it("Comparing two equal booleans", () => { |
|||
const a = true; |
|||
const b = true; |
|||
|
|||
expect(isEq(a, b)).toBe(true); |
|||
}) |
|||
|
|||
it("Comparing two equal regexes", () => { |
|||
const a = /$hello^/; |
|||
const b = /$hello^/; |
|||
|
|||
expect(isEq(a, b)).toBe(true); |
|||
}) |
|||
|
|||
it("Comparing two nulls", () => { |
|||
const a = null; |
|||
const b = null; |
|||
|
|||
expect(isEq(a, b)).toBe(true); |
|||
}) |
|||
|
|||
}) |
|||
|
|||
describe("Primitives (inequality):", () => { |
|||
|
|||
it("Comparing two inequal numbers", () => { |
|||
const a = 10; |
|||
const b = 0; |
|||
|
|||
expect(isEq(a, b)).toBe(false); |
|||
}) |
|||
|
|||
it("Comparing two inequal strings", () => { |
|||
const a = 'Hello!'; |
|||
const b = 'Bye!'; |
|||
|
|||
expect(isEq(a, b)).toBe(false); |
|||
}) |
|||
|
|||
it("Comparing two inequal booleans", () => { |
|||
const a = true; |
|||
const b = false; |
|||
|
|||
expect(isEq(a, b)).toBe(false); |
|||
}) |
|||
|
|||
it("Comparing two NaNs", () => { |
|||
const a = NaN; |
|||
const b = NaN; |
|||
|
|||
expect(isEq(a, b)).toBe(false); |
|||
}) |
|||
|
|||
it("Comparing null to undefined", () => { |
|||
const a = null; |
|||
const b = undefined; |
|||
|
|||
expect(isEq(a, b)).toBe(false); |
|||
}) |
|||
|
|||
}) |
@ -0,0 +1,11 @@ |
|||
{ |
|||
"spec_dir": "spec", |
|||
"spec_files": [ |
|||
"**/*[sS]pec.js" |
|||
], |
|||
"helpers": [ |
|||
"helpers/**/*.js" |
|||
], |
|||
"stopSpecOnExpectationFailure": false, |
|||
"random": true |
|||
} |
Loading…
Reference in new issue