123456789101112131415161718192021222324252627282930313233343536373839404142 |
- var falafel = require('../');
- var acorn = require('acorn-jsx');
- var test = require('tape');
- test('custom parser', function (t) {
- var src = '(function() { var f = {a: "b"}; var a = <div {...f} className="test"></div>; })()';
- var nodeTypes = [
- 'Identifier',
- 'Identifier',
- 'Literal',
- 'Property',
- 'ObjectExpression',
- 'VariableDeclarator',
- 'VariableDeclaration',
- 'Identifier',
- 'Identifier',
- 'JSXSpreadAttribute',
- 'JSXIdentifier',
- 'Literal',
- 'JSXAttribute',
- 'JSXIdentifier',
- 'JSXOpeningElement',
- 'JSXIdentifier',
- 'JSXClosingElement',
- 'JSXElement',
- 'VariableDeclarator',
- 'VariableDeclaration',
- 'BlockStatement',
- 'FunctionExpression',
- 'CallExpression',
- 'ExpressionStatement',
- 'Program'
- ];
- t.plan(nodeTypes.length);
- var output = falafel(src, {parser: acorn, ecmaVersion: 6, plugins: { jsx: true }}, function(node) {
- t.equal(node.type, nodeTypes.shift());
- });
- });
|