Skip to content

Commit b446116

Browse files
committed
Make test more explicit
1 parent af51035 commit b446116

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/language/__tests__/visitor-test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,28 +96,28 @@ describe('Visitor', () => {
9696

9797
it('validates ancestors argument', () => {
9898
const ast = parse('{ a }', { noLocation: true });
99-
const nodesInPath = [];
99+
const visitedNodes = [];
100100

101101
visit(ast, {
102102
enter(node, key, parent, path, ancestors) {
103103
const inArray = typeof key === 'number';
104-
const expectedAncestors = nodesInPath.slice(0, path.length - 1);
105-
expect(ancestors).to.deep.equal(expectedAncestors);
106-
107104
if (inArray) {
108-
nodesInPath.push(parent);
105+
visitedNodes.push(parent);
109106
}
110-
nodesInPath.push(node);
107+
visitedNodes.push(node);
108+
109+
const expectedAncestors = visitedNodes.slice(0, -2);
110+
expect(ancestors).to.deep.equal(expectedAncestors);
111111
},
112112
leave(node, key, parent, path, ancestors) {
113-
const inArray = typeof key === 'number';
114-
const expectedAncestors = nodesInPath.slice(0, path.length - 1);
113+
const expectedAncestors = visitedNodes.slice(0, -2);
115114
expect(ancestors).to.deep.equal(expectedAncestors);
116115

116+
const inArray = typeof key === 'number';
117117
if (inArray) {
118-
nodesInPath.pop();
118+
visitedNodes.pop();
119119
}
120-
nodesInPath.pop();
120+
visitedNodes.pop();
121121
},
122122
});
123123
});

0 commit comments

Comments
 (0)