-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
82 lines (73 loc) · 1.73 KB
/
test.js
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"use strict";
const pluginTester = require("babel-plugin-tester").default;
const reactMoveAnonymousInlineStyleObjects = require("./src/index.js");
const testSimple = `
import React from "react";
import SomeComponent from "react-library";
export const MComponent = () => {
const fn = () => alert('hey there');
return (
<SomeComponent
css={{
color: "red",
}}
style={{
padding: 10,
backgroundColor: "yellow",
}}
isActive
onPress={fn}
>
Text
</SomeComponent>
);
};
`;
const testTenaryAndLogicalExpression = `
import React from "react";
export const MComponent = () => {
const myValue = 0.3;
return (
<div
css={{
color: "red",
margin: \`\$\{myValue > 0.5 ? 10 : 20\}px\`,
}}
style={{
padding: 10,
backgroundColor: "yellow",
}}
untouched
>
Text
</div>
);
};
`;
const testConditionalExpression = `
import React from "react";
const displayNewStyles = true;
export const MComponent = () => {
return (
<div
css={{
color: "red",
backgroundColor: displayNewStyles ? "orange" : "transparent",
}}
>
Text
</div>
);
};
`;
pluginTester({
pluginName: "react-move-anonymous-inline-style-objects",
plugin: reactMoveAnonymousInlineStyleObjects,
snapshot: true,
babelOptions: require("./babel.config.js"),
tests: [
{ code: testTenaryAndLogicalExpression },
{ code: testSimple },
{ code: testConditionalExpression },
],
});