forked from facebook/create-react-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateElement-test.js
More file actions
64 lines (52 loc) · 1.61 KB
/
createElement-test.js
File metadata and controls
64 lines (52 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'use strict';
const plugin = require('../index.js');
const babel = require('@babel/core');
function transform(code) {
return babel.transform(code, {
plugins: [plugin],
}).code;
}
describe('React createElement transforms', () => {
it('should transform React.createElement calls', () => {
const test = `
import React from "react";
export function MyComponent() {
return React.createElement("div");
}
`;
const output = transform(test);
expect(output).toMatchSnapshot();
});
it('should transform React.createElement calls #2', () => {
const test = `
const React = require("react");
export function MyComponent() {
return React.createElement("div", null, React.createElement("span", null, "Hello world!"));
}
`;
const output = transform(test);
expect(output).toMatchSnapshot();
});
it('should transform React.createElement calls #3', () => {
const test = `
const React = require("react");
const node = React.createElement("div", null, React.createElement("span", null, "Hello world!"));
export function MyComponent() {
return node;
}
`;
const output = transform(test);
expect(output).toMatchSnapshot();
});
it('should transform React.createElement calls #4', () => {
const test = `
import * as React from "react";
const node = React.createElement("div", null, React.createElement("span", null, "Hello world!"));
export function MyComponent() {
return node;
}
`;
const output = transform(test);
expect(output).toMatchSnapshot();
});
});