Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

visitor: remove 4th form of visitor #2957

Merged
merged 1 commit into from Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 5 additions & 23 deletions src/language/__tests__/visitor-test.js
Expand Up @@ -56,6 +56,11 @@ function getValue(node: ASTNode) {
}

describe('Visitor', () => {
it('handles empty visitor', () => {
const ast = parse('{ a }', { noLocation: true });
expect(() => visit(ast, {})).to.not.throw();
});

it('validates path argument', () => {
const visited = [];

Expand Down Expand Up @@ -114,29 +119,6 @@ describe('Visitor', () => {
});
});

it('allows visiting only specified nodes', () => {
const ast = parse('{ a }', { noLocation: true });
const visited = [];

visit(ast, {
enter: {
Field(node) {
visited.push(['enter', node.kind]);
},
},
leave: {
Field(node) {
visited.push(['leave', node.kind]);
},
},
});

expect(visited).to.deep.equal([
['enter', 'Field'],
['leave', 'Field'],
]);
});

it('allows editing a node both on enter and on leave', () => {
const ast = parse('{ a, b, c { a, b, c } }', { noLocation: true });

Expand Down