Skip to content

Commit

Permalink
Fix invalid test for "does not walk the same property twice"
Browse files Browse the repository at this point in the history
The previous test only worked because of a faulty implementation in our source,
once that is fixed, this test will fail, because we walk ALL own properties.

Instead, this test has been rewritten to ensure that each property is only
examined once, by looking at what property names have been used.
  • Loading branch information
mroderick authored and fatso83 committed Dec 17, 2016
1 parent 9d6ae3b commit 33d7326
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/walk-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,22 @@

"does not walk the same property twice": function () {
var parent = {
func: function () {}
func: function parentFunc() {}
};
var child = sinon.create(parent);
child.func = function () {};
child.func = function childFunc() {};
var iterator = sinon.spy();

sinon.walk(child, iterator);

assert.equals(iterator.callCount, 1);
var propertyNames = iterator.args.map(function (call) {
return call[1];
});

// make sure that each property name only exists once
propertyNames.forEach(function (name, index) {
assert.equals(index, propertyNames.lastIndexOf(name));
});
}
});
}(this));

0 comments on commit 33d7326

Please sign in to comment.