ensure properties in arrays are tested #1497
This commit is contained in:
parent
d7732d3560
commit
b62663bdc1
4 changed files with 16 additions and 5 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
Noiseless testing framework
|
||||
|
||||
Version: 1.2.1
|
||||
Version: 1.2.2
|
||||
License: MIT
|
||||
|
||||
## About
|
||||
|
|
|
|||
|
|
@ -143,8 +143,11 @@ module.exports = new function init() {
|
|||
return true
|
||||
}
|
||||
if (a.length === b.length && (a instanceof Array && b instanceof Array || aIsArgs && bIsArgs)) {
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
if (!deepEqual(a[i], b[i])) return false
|
||||
var aKeys = Object.getOwnPropertyNames(a), bKeys = Object.getOwnPropertyNames(b)
|
||||
if (aKeys.length !== bKeys.length) return false
|
||||
var larger = aKeys.length < bKeys.length ? bKeys : aKeys
|
||||
for (var i = 0; i < larger.length; i++) {
|
||||
if (!deepEqual(a[larger[i]], b[larger[i]])) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ospec",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.2",
|
||||
"description": "Noiseless testing framework",
|
||||
"main": "ospec.js",
|
||||
"directories": {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ o.spec("ospec", function() {
|
|||
o.beforeEach(function() {b = 1})
|
||||
o.afterEach(function() {b = 0})
|
||||
|
||||
o("assertions", function() {
|
||||
o.only("assertions", function() {
|
||||
var spy = o.spy()
|
||||
spy(a)
|
||||
|
||||
|
|
@ -36,6 +36,14 @@ o.spec("ospec", function() {
|
|||
o(a).notEquals(2)
|
||||
o({a: [1, 2], b: 3}).deepEquals({a: [1, 2], b: 3})
|
||||
o([{a: 1, b: 2}, {c: 3}]).deepEquals([{a: 1, b: 2}, {c: 3}])
|
||||
|
||||
var monkeypatch1 = [1, 2]
|
||||
monkeypatch1.field = 3
|
||||
var monkeypatch2 = [1, 2]
|
||||
monkeypatch2.field = 4
|
||||
|
||||
o(monkeypatch1).notDeepEquals([1, 2])
|
||||
o(monkeypatch1).notDeepEquals(monkeypatch2)
|
||||
|
||||
var values = ["a", "", 1, 0, true, false, null, undefined, Date(0), ["a"], [], function() {return arguments}.call(), new Uint8Array(), {a: 1}, {}]
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue