UNPKG

1.08 kBJavaScriptView Raw
1const path = require('path');
2const assert = require('assert');
3const execFileSync = require('child_process').execFileSync;
4const mocha = require('mocha');
5
6const { describe, it } = mocha;
7
8const execCLI = input =>
9 execFileSync(path.resolve(__dirname, '../../lib/cli.js'), {
10 input,
11 encoding: 'utf8',
12 });
13
14describe('jsx', () => {
15 it('jsx 1', () => {
16 const input = `
17const App = () => (<div><span><a href="http://localhost/index.html">index</a></span></div>);
18`;
19 const output = `
20const App = () => (
21 <div>
22 <span><a href="http://localhost/index.html">index</a></span>
23 </div>
24);
25`;
26 assert.equal(execCLI(input), output);
27 });
28
29 it('jsx 2', () => {
30 const input = `
31const App = () => (<div><Component attribute1="value1" attribute2="value2" attribute3={{a:1,b:2,c:3}}>foo</Component></div>);
32`;
33 const output = `
34const App = () => (
35 <div>
36 <Component
37 attribute1="value1"
38 attribute2="value2"
39 attribute3={{ a: 1, b: 2, c: 3 }}
40 >
41 foo
42 </Component>
43 </div>
44);
45`;
46 assert.equal(execCLI(input), output);
47 });
48});