You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
975 B

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());
});
});