Skip to content

Commit

Permalink
test: add test for depthFirst option and visit ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
kumavis committed Dec 12, 2023
1 parent e946e3d commit b6b2141
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,51 @@ test('depth 1', t => {
}
})

test('depthFirst - visit ordering', t => {
const a = Object.create(null);
const b = Object.create(null);
const c = Object.create(null);
const d = Object.create(null);
const e = Object.create(null);
const f = Object.create(null);

const start = {
__proto__: a,
b,
c,
}
a.d = d;
d.f = f;
b.e = e;

{
const allValues = getAll({}, start);
t.deepEqual(allValues, [
// indentation shows depth
start,
a,
b,
c,
d,
e,
f,
]);
}
{
const allValues = getAll({ depthFirst: true }, start);
t.deepEqual(allValues, [
// indentation shows depth
start,
a,
d,
f,
b,
e,
c,
]);
}
})

test('exhaustiveWeakMapSearch', t => {
const map = new WeakMap();
const obj = {};
Expand Down

0 comments on commit b6b2141

Please sign in to comment.