Front end of the Slack clone application.

custom-parser.js 975B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var falafel = require('../');
  2. var acorn = require('acorn-jsx');
  3. var test = require('tape');
  4. test('custom parser', function (t) {
  5. var src = '(function() { var f = {a: "b"}; var a = <div {...f} className="test"></div>; })()';
  6. var nodeTypes = [
  7. 'Identifier',
  8. 'Identifier',
  9. 'Literal',
  10. 'Property',
  11. 'ObjectExpression',
  12. 'VariableDeclarator',
  13. 'VariableDeclaration',
  14. 'Identifier',
  15. 'Identifier',
  16. 'JSXSpreadAttribute',
  17. 'JSXIdentifier',
  18. 'Literal',
  19. 'JSXAttribute',
  20. 'JSXIdentifier',
  21. 'JSXOpeningElement',
  22. 'JSXIdentifier',
  23. 'JSXClosingElement',
  24. 'JSXElement',
  25. 'VariableDeclarator',
  26. 'VariableDeclaration',
  27. 'BlockStatement',
  28. 'FunctionExpression',
  29. 'CallExpression',
  30. 'ExpressionStatement',
  31. 'Program'
  32. ];
  33. t.plan(nodeTypes.length);
  34. var output = falafel(src, {parser: acorn, ecmaVersion: 6, plugins: { jsx: true }}, function(node) {
  35. t.equal(node.type, nodeTypes.shift());
  36. });
  37. });