recurse.test.js 423 B

123456789101112131415161718192021222324
  1. const test = require('ava');
  2. const sinon = require('sinon');
  3. const { parse } = require('@babel/eslint-parser');
  4. const recurse = require('./recurse');
  5. test('recurse.visit', t => {
  6. const ast = parse(`
  7. foo.parentNode.removeChild(foo);
  8. foo.parentNode.removeChild(bar);
  9. `, {
  10. requireConfigFile: false,
  11. });
  12. const spy = sinon.spy();
  13. recurse.visit(ast, {
  14. MemberExpression: spy,
  15. });
  16. t.is(spy.callCount, 4);
  17. });