-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.ts
150 lines (140 loc) · 4.36 KB
/
index.test.ts
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import path from 'path';
import { transformAsync } from '@babel/core';
import packageJson from '../package.json';
const options = {
plugins: [
path.resolve(process.cwd(), `dist/${packageJson.name}.cjs.production.min`),
],
babelrc: false,
};
it('add missing _c', async () => {
const result = await transformAsync(
`const Divider = /*#__PURE__*/ _s(React.forwardRef(_c = _s(function Divider(inProps, ref) {
_s();
const props = useThemeProps({
props: inProps,
name: "MuiDivider"
});
const { absolute = false, children, className, component = children ? "div" : "hr", flexItem = false, light = false, orientation = "horizontal", role = component !== "hr" ? "separator" : undefined, textAlign = "center", variant = "fullWidth" } = props, other = _objectWithoutPropertiesLoose(props, _excluded);
const ownerState = _extends({}, props, {
absolute,
component,
flexItem,
light,
orientation,
role,
textAlign,
variant
});
const classes = useUtilityClasses(ownerState);
return /*#__PURE__*/ _jsx(DividerRoot, _extends({
as: component,
className: clsx(classes.root, className),
role: role,
ref: ref,
ownerState: ownerState
}, other, {
children: children ? /*#__PURE__*/ _jsx(DividerWrapper, {
className: classes.wrapper,
ownerState: ownerState,
children: children
}) : null
}));
}, "526RDEpO1CGEADq5vnCvoNyCejQ=", false, function() {
return [
useThemeProps,
useUtilityClasses
];
})), "526RDEpO1CGEADq5vnCvoNyCejQ=", false, function() {
return [
useThemeProps,
useUtilityClasses
];
});
_c1 = Divider;
/**
* The following flag is used to ensure that this component isn't tabbable i.e.
* does not get highlight/focus inside of MUI List.
*/ Divider.muiSkipListHighlight = true;
export default Divider;
var _c1;
$RefreshReg$(_c1, "Divider");
`,
options
);
expect(result?.code).toMatchSnapshot();
});
it('does not add if _c is already defined', async () => {
const result = await transformAsync(
`const Divider = /*#__PURE__*/ _s(React.forwardRef(_c = _s(function Divider(inProps, ref) {
_s();
const props = useThemeProps({
props: inProps,
name: "MuiDivider"
});
const { absolute = false, children, className, component = children ? "div" : "hr", flexItem = false, light = false, orientation = "horizontal", role = component !== "hr" ? "separator" : undefined, textAlign = "center", variant = "fullWidth" } = props, other = _objectWithoutPropertiesLoose(props, _excluded);
const ownerState = _extends({}, props, {
absolute,
component,
flexItem,
light,
orientation,
role,
textAlign,
variant
});
const classes = useUtilityClasses(ownerState);
return /*#__PURE__*/ _jsx(DividerRoot, _extends({
as: component,
className: clsx(classes.root, className),
role: role,
ref: ref,
ownerState: ownerState
}, other, {
children: children ? /*#__PURE__*/ _jsx(DividerWrapper, {
className: classes.wrapper,
ownerState: ownerState,
children: children
}) : null
}));
}, "526RDEpO1CGEADq5vnCvoNyCejQ=", false, function() {
return [
useThemeProps,
useUtilityClasses
];
})), "526RDEpO1CGEADq5vnCvoNyCejQ=", false, function() {
return [
useThemeProps,
useUtilityClasses
];
});
_c1 = Divider;
/**
* The following flag is used to ensure that this component isn't tabbable i.e.
* does not get highlight/focus inside of MUI List.
*/ Divider.muiSkipListHighlight = true;
export default Divider;
var _c, _c1;
$RefreshReg$(_c, "Divider$forwardRef");
$RefreshReg$(_c1, "Divider");
`,
options
);
expect(result?.code).toMatchSnapshot();
});
it('add missing _systemDefaultTheme', async () => {
const result = await transformAsync(
`'use client';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.shouldForwardProp = shouldForwardProp;
exports.systemDefaultTheme = void 0;
function shouldForwardProp(prop) {
return prop !== 'ownerState' && prop !== 'theme' && prop !== 'sx' && prop !== 'as';
}
_systemDefaultTheme = (0, _createTheme.default)();`,
options
);
expect(result?.code).toMatchSnapshot();
});