UNPKG

667 BJavaScriptView Raw
1var assert = require('assert')
2var babylon = require('babylon')
3var horchata = require('horchata')
4var transform = require('../')
5
6assert.equal(transform(`
7 var el = <div />;
8`, { parser: babylon, plugins: [ 'jsx' ] }, function (node) {
9 if (node.type === 'JSXElement') {
10 node.edit.update(JSON.stringify(node.getSource()))
11 }
12}).toString(), `
13 var el = "<div />";
14`)
15
16assert.equal(transform(`
17X = () -> {
18 @prop or= 'value'
19}
20new X
21`, { parser: horchata }, function (node) {
22 switch (node.type) {
23 case 'FunctionExpression':
24 node.edit.update('function () ' + node.body.getSource())
25 }
26}).toString(), `
27X = function () {
28 @prop or= 'value'
29}
30new X
31`)