@gympass/yoga 7.127.0 → 7.127.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/Input/native/Input.test.js +19 -12
- package/cjs/Input/web/Input.js +0 -1
- package/cjs/Input/web/Input.test.js +32 -11
- package/cjs/Snackbar/native/Snackbar.js +11 -5
- package/cjs/Snackbar/native/Snackbar.test.js +5 -0
- package/cjs/Snackbar/web/Snackbar.js +9 -3
- package/cjs/Snackbar/web/Snackbar.test.js +14 -0
- package/esm/Input/native/Input.test.js +19 -12
- package/esm/Input/web/Input.js +0 -1
- package/esm/Input/web/Input.test.js +32 -11
- package/esm/Snackbar/native/Snackbar.js +11 -5
- package/esm/Snackbar/native/Snackbar.test.js +5 -0
- package/esm/Snackbar/web/Snackbar.js +9 -3
- package/esm/Snackbar/web/Snackbar.test.js +14 -0
- package/package.json +2 -2
|
@@ -41,9 +41,9 @@ describe("<Input />", () => {
|
|
|
41
41
|
});
|
|
42
42
|
it("should match when input is focused", () => {
|
|
43
43
|
const { toJSON, getByTestId } = (0, import_react_native.render)(
|
|
44
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input" }) })
|
|
44
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input-test" }) })
|
|
45
45
|
);
|
|
46
|
-
(0, import_react_native.fireEvent)(getByTestId("input"), "focus");
|
|
46
|
+
(0, import_react_native.fireEvent)(getByTestId("input-test"), "focus");
|
|
47
47
|
expect(toJSON()).toMatchSnapshot();
|
|
48
48
|
});
|
|
49
49
|
it("should match with disabled input", () => {
|
|
@@ -81,9 +81,16 @@ describe("<Input />", () => {
|
|
|
81
81
|
it("should call onChangeText", () => {
|
|
82
82
|
const onChangeTextMock = jest.fn();
|
|
83
83
|
const { getByTestId } = (0, import_react_native.render)(
|
|
84
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
85
|
+
import__.Input,
|
|
86
|
+
{
|
|
87
|
+
label: "Input",
|
|
88
|
+
testID: "input-test",
|
|
89
|
+
onChangeText: onChangeTextMock
|
|
90
|
+
}
|
|
91
|
+
) })
|
|
85
92
|
);
|
|
86
|
-
import_react_native.fireEvent.changeText(getByTestId("input"), "foo");
|
|
93
|
+
import_react_native.fireEvent.changeText(getByTestId("input-test"), "foo");
|
|
87
94
|
expect(onChangeTextMock).toHaveBeenCalled();
|
|
88
95
|
});
|
|
89
96
|
it("should not call onChangeText when input is disabled", () => {
|
|
@@ -93,37 +100,37 @@ describe("<Input />", () => {
|
|
|
93
100
|
import__.Input,
|
|
94
101
|
{
|
|
95
102
|
label: "Input",
|
|
96
|
-
testID: "input",
|
|
103
|
+
testID: "input-test",
|
|
97
104
|
onChangeText: onChangeTextMock,
|
|
98
105
|
disabled: true
|
|
99
106
|
}
|
|
100
107
|
) })
|
|
101
108
|
);
|
|
102
|
-
(0, import_react_native.fireEvent)(getByTestId("input"), "focus");
|
|
109
|
+
(0, import_react_native.fireEvent)(getByTestId("input-test"), "focus");
|
|
103
110
|
expect(onChangeTextMock).not.toHaveBeenCalled();
|
|
104
111
|
});
|
|
105
112
|
it("should call onFocus", () => {
|
|
106
113
|
const onFocusMock = jest.fn();
|
|
107
114
|
const { getByTestId } = (0, import_react_native.render)(
|
|
108
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input", onFocus: onFocusMock }) })
|
|
115
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input-test", onFocus: onFocusMock }) })
|
|
109
116
|
);
|
|
110
|
-
(0, import_react_native.fireEvent)(getByTestId("input"), "focus");
|
|
117
|
+
(0, import_react_native.fireEvent)(getByTestId("input-test"), "focus");
|
|
111
118
|
expect(onFocusMock).toHaveBeenCalled();
|
|
112
119
|
});
|
|
113
120
|
it("should call onBlur", () => {
|
|
114
121
|
const onBlurMock = jest.fn();
|
|
115
122
|
const { getByTestId } = (0, import_react_native.render)(
|
|
116
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input", onBlur: onBlurMock }) })
|
|
123
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input-test", onBlur: onBlurMock }) })
|
|
117
124
|
);
|
|
118
|
-
(0, import_react_native.fireEvent)(getByTestId("input"), "focus");
|
|
119
|
-
(0, import_react_native.fireEvent)(getByTestId("input"), "blur");
|
|
125
|
+
(0, import_react_native.fireEvent)(getByTestId("input-test"), "focus");
|
|
126
|
+
(0, import_react_native.fireEvent)(getByTestId("input-test"), "blur");
|
|
120
127
|
expect(onBlurMock).toHaveBeenCalled();
|
|
121
128
|
});
|
|
122
129
|
});
|
|
123
130
|
describe("maxLength", () => {
|
|
124
131
|
it("should update maxLength counter when add character", () => {
|
|
125
132
|
const { getByText, rerender } = (0, import_react_native.render)(
|
|
126
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input",
|
|
133
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", maxLength: 10 }) })
|
|
127
134
|
);
|
|
128
135
|
expect(getByText("0/10")).toBeTruthy();
|
|
129
136
|
rerender(
|
package/cjs/Input/web/Input.js
CHANGED
|
@@ -87,14 +87,27 @@ describe("<Input />", () => {
|
|
|
87
87
|
);
|
|
88
88
|
expect(container).toMatchSnapshot();
|
|
89
89
|
});
|
|
90
|
+
it("should render with custom dataTestId", () => {
|
|
91
|
+
(0, import_react2.render)(
|
|
92
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", "data-testid": "custom-input" }) })
|
|
93
|
+
);
|
|
94
|
+
expect(import_react2.screen.getByTestId("custom-input")).toBeInTheDocument();
|
|
95
|
+
});
|
|
90
96
|
});
|
|
91
97
|
describe("Events", () => {
|
|
92
98
|
it("should call onChange", () => {
|
|
93
99
|
const onChangeMock = jest.fn();
|
|
94
100
|
(0, import_react2.render)(
|
|
95
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
102
|
+
import__.Input,
|
|
103
|
+
{
|
|
104
|
+
label: "Input",
|
|
105
|
+
onChange: onChangeMock,
|
|
106
|
+
"data-testid": "input-test"
|
|
107
|
+
}
|
|
108
|
+
) })
|
|
109
|
+
);
|
|
110
|
+
import_react2.fireEvent.change(import_react2.screen.getByTestId("input-test"), {
|
|
98
111
|
target: { value: "foo" }
|
|
99
112
|
});
|
|
100
113
|
expect(onChangeMock).toHaveBeenCalled();
|
|
@@ -110,10 +123,10 @@ describe("<Input />", () => {
|
|
|
110
123
|
it("should call onBlur", () => {
|
|
111
124
|
const onBlurMock = jest.fn();
|
|
112
125
|
(0, import_react2.render)(
|
|
113
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", "data-testid": "input", onBlur: onBlurMock }) })
|
|
126
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", "data-testid": "input-test", onBlur: onBlurMock }) })
|
|
114
127
|
);
|
|
115
|
-
import_react2.fireEvent.focus(import_react2.screen.getByTestId("input"));
|
|
116
|
-
import_react2.fireEvent.blur(import_react2.screen.getByTestId("input"));
|
|
128
|
+
import_react2.fireEvent.focus(import_react2.screen.getByTestId("input-test"));
|
|
129
|
+
import_react2.fireEvent.blur(import_react2.screen.getByTestId("input-test"));
|
|
117
130
|
expect(onBlurMock).toHaveBeenCalled();
|
|
118
131
|
});
|
|
119
132
|
});
|
|
@@ -151,18 +164,26 @@ describe("<Input />", () => {
|
|
|
151
164
|
it("should have aria-label", () => {
|
|
152
165
|
const value = "aria label value";
|
|
153
166
|
const { getByTestId } = (0, import_react2.render)(
|
|
154
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
155
|
-
|
|
156
|
-
|
|
167
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
168
|
+
import__.Input,
|
|
169
|
+
{
|
|
170
|
+
label: "Input",
|
|
171
|
+
value: "foo",
|
|
172
|
+
ariaLabel: value,
|
|
173
|
+
"data-testid": "input-test"
|
|
174
|
+
}
|
|
175
|
+
) })
|
|
176
|
+
);
|
|
177
|
+
const inputElement = getByTestId("input-test");
|
|
157
178
|
expect(inputElement).toBeInTheDocument();
|
|
158
179
|
expect(inputElement).toHaveAttribute("aria-label", value);
|
|
159
180
|
});
|
|
160
181
|
it("should have label value", () => {
|
|
161
182
|
const value = "label value";
|
|
162
183
|
const { getByTestId } = (0, import_react2.render)(
|
|
163
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: value, value: "foo" }) })
|
|
184
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: value, value: "foo", "data-testid": "input-test" }) })
|
|
164
185
|
);
|
|
165
|
-
const inputElement = getByTestId("input");
|
|
186
|
+
const inputElement = getByTestId("input-test");
|
|
166
187
|
expect(inputElement).toBeInTheDocument();
|
|
167
188
|
expect(inputElement).toHaveAttribute("aria-label", value);
|
|
168
189
|
});
|
|
@@ -109,7 +109,8 @@ const Snackbar = (0, import_react.forwardRef)((props, ref) => {
|
|
|
109
109
|
variant,
|
|
110
110
|
onSnackbarClose,
|
|
111
111
|
duration,
|
|
112
|
-
bottomOffset
|
|
112
|
+
bottomOffset,
|
|
113
|
+
dataTestId
|
|
113
114
|
} = _a, rest = __objRest(_a, [
|
|
114
115
|
"icon",
|
|
115
116
|
"message",
|
|
@@ -118,7 +119,8 @@ const Snackbar = (0, import_react.forwardRef)((props, ref) => {
|
|
|
118
119
|
"variant",
|
|
119
120
|
"onSnackbarClose",
|
|
120
121
|
"duration",
|
|
121
|
-
"bottomOffset"
|
|
122
|
+
"bottomOffset",
|
|
123
|
+
"dataTestId"
|
|
122
124
|
]);
|
|
123
125
|
const wrapperRef = (0, import_react.useRef)();
|
|
124
126
|
const [currentProps, setCurrentProps] = (0, import_react.useState)({
|
|
@@ -197,7 +199,8 @@ const Snackbar = (0, import_react.forwardRef)((props, ref) => {
|
|
|
197
199
|
SnackbarContainer,
|
|
198
200
|
__spreadProps(__spreadValues(__spreadValues({
|
|
199
201
|
variant: currentProps.variant,
|
|
200
|
-
bottomOffset
|
|
202
|
+
bottomOffset,
|
|
203
|
+
testID: dataTestId
|
|
201
204
|
}, rest), panResponder.panHandlers), {
|
|
202
205
|
children: [
|
|
203
206
|
currentProps.icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -252,7 +255,9 @@ Snackbar.propTypes = {
|
|
|
252
255
|
/** The duration sets how long it will take to close snackbar automatically, it may be "fast" (4 seconds), "default" (8 seconds), "slow" (10 seconds) or "indefinite" (it doesn't close automatically). */
|
|
253
256
|
duration: (0, import_prop_types.oneOf)(["fast", "default", "slow", "indefinite"]),
|
|
254
257
|
/** Add extra margin to Snackbar. Can be useful for SafeAreaView or button cases. */
|
|
255
|
-
bottomOffset: import_prop_types.number
|
|
258
|
+
bottomOffset: import_prop_types.number,
|
|
259
|
+
/* A unique identifier for the Snackbar component, used for testing purposes with tools like Jest and Testing Library. */
|
|
260
|
+
dataTestId: import_prop_types.string
|
|
256
261
|
};
|
|
257
262
|
Snackbar.defaultProps = {
|
|
258
263
|
variant: "success",
|
|
@@ -262,6 +267,7 @@ Snackbar.defaultProps = {
|
|
|
262
267
|
onAction: void 0,
|
|
263
268
|
onSnackbarClose: void 0,
|
|
264
269
|
duration: "default",
|
|
265
|
-
bottomOffset: 0
|
|
270
|
+
bottomOffset: 0,
|
|
271
|
+
dataTestId: "snackbar"
|
|
266
272
|
};
|
|
267
273
|
var Snackbar_default = Snackbar;
|
|
@@ -73,6 +73,11 @@ describe("<Snackbar />", () => {
|
|
|
73
73
|
const { toJSON } = (0, import_react_native.render)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}));
|
|
74
74
|
expect(toJSON()).toMatchSnapshot();
|
|
75
75
|
});
|
|
76
|
+
it("should render with custom dataTestId", () => {
|
|
77
|
+
const { getByTestId } = (0, import_react_native.render)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { dataTestId: "custom-snackbar" }));
|
|
78
|
+
import_react_native.fireEvent.press(getByTestId("custom-snackbar"));
|
|
79
|
+
expect(getByTestId("custom-snackbar")).toBeTruthy();
|
|
80
|
+
});
|
|
76
81
|
it("should match snapshot when have an icon and action", () => {
|
|
77
82
|
const overrideProps = {
|
|
78
83
|
icon: import_yoga_icons.CheckedFull,
|
|
@@ -175,6 +175,7 @@ const Snackbar = import_react.default.forwardRef(
|
|
|
175
175
|
onClose,
|
|
176
176
|
hideCloseButton,
|
|
177
177
|
ariaLabelClose,
|
|
178
|
+
dataTestId,
|
|
178
179
|
theme: {
|
|
179
180
|
yoga: {
|
|
180
181
|
components: { snackbar }
|
|
@@ -191,6 +192,7 @@ const Snackbar = import_react.default.forwardRef(
|
|
|
191
192
|
"onClose",
|
|
192
193
|
"hideCloseButton",
|
|
193
194
|
"ariaLabelClose",
|
|
195
|
+
"dataTestId",
|
|
194
196
|
"theme"
|
|
195
197
|
]);
|
|
196
198
|
const timeoutRef = (0, import_react.useRef)();
|
|
@@ -209,7 +211,8 @@ const Snackbar = import_react.default.forwardRef(
|
|
|
209
211
|
role: "alert",
|
|
210
212
|
"aria-label": variant,
|
|
211
213
|
variant,
|
|
212
|
-
ref
|
|
214
|
+
ref,
|
|
215
|
+
"data-testid": dataTestId
|
|
213
216
|
}, props), {
|
|
214
217
|
children: [
|
|
215
218
|
!hideIcon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -271,7 +274,9 @@ Snackbar.propTypes = {
|
|
|
271
274
|
/** Hides the close button. */
|
|
272
275
|
hideCloseButton: import_prop_types.bool,
|
|
273
276
|
/** Custom aria label for close button. */
|
|
274
|
-
ariaLabelClose: import_prop_types.string
|
|
277
|
+
ariaLabelClose: import_prop_types.string,
|
|
278
|
+
/* A unique identifier for the Snackbar component, used for testing purposes with tools like Jest and Testing Library. */
|
|
279
|
+
dataTestId: import_prop_types.string
|
|
275
280
|
};
|
|
276
281
|
Snackbar.defaultProps = {
|
|
277
282
|
open: false,
|
|
@@ -281,6 +286,7 @@ Snackbar.defaultProps = {
|
|
|
281
286
|
onAction: void 0,
|
|
282
287
|
variant: "success",
|
|
283
288
|
hideCloseButton: false,
|
|
284
|
-
ariaLabelClose: void 0
|
|
289
|
+
ariaLabelClose: void 0,
|
|
290
|
+
dataTestId: "snackbar"
|
|
285
291
|
};
|
|
286
292
|
var Snackbar_default = (0, import_react.memo)((0, import_styled_components.withTheme)(Snackbar));
|
|
@@ -53,6 +53,20 @@ describe("<Snackbar />", () => {
|
|
|
53
53
|
);
|
|
54
54
|
expect(container).toMatchSnapshot();
|
|
55
55
|
});
|
|
56
|
+
it("should render with custom dataTestId", () => {
|
|
57
|
+
(0, import_react2.render)(
|
|
58
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
59
|
+
import__.Snackbar,
|
|
60
|
+
{
|
|
61
|
+
open: true,
|
|
62
|
+
message: "Make wellbeing universal",
|
|
63
|
+
onClose: jest.fn(),
|
|
64
|
+
dataTestId: "custom-snackbar"
|
|
65
|
+
}
|
|
66
|
+
) })
|
|
67
|
+
);
|
|
68
|
+
expect(import_react2.screen.getByTestId("custom-snackbar")).toBeInTheDocument();
|
|
69
|
+
});
|
|
56
70
|
it("should render a minimal snackbar", () => {
|
|
57
71
|
(0, import_react2.render)(
|
|
58
72
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Snackbar, { open: true, message: "Make wellbeing universal", onClose: jest.fn() }) })
|
|
@@ -18,9 +18,9 @@ describe("<Input />", () => {
|
|
|
18
18
|
});
|
|
19
19
|
it("should match when input is focused", () => {
|
|
20
20
|
const { toJSON, getByTestId } = render(
|
|
21
|
-
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input" }) })
|
|
21
|
+
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input-test" }) })
|
|
22
22
|
);
|
|
23
|
-
fireEvent(getByTestId("input"), "focus");
|
|
23
|
+
fireEvent(getByTestId("input-test"), "focus");
|
|
24
24
|
expect(toJSON()).toMatchSnapshot();
|
|
25
25
|
});
|
|
26
26
|
it("should match with disabled input", () => {
|
|
@@ -58,9 +58,16 @@ describe("<Input />", () => {
|
|
|
58
58
|
it("should call onChangeText", () => {
|
|
59
59
|
const onChangeTextMock = jest.fn();
|
|
60
60
|
const { getByTestId } = render(
|
|
61
|
-
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
|
|
61
|
+
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
|
|
62
|
+
Input,
|
|
63
|
+
{
|
|
64
|
+
label: "Input",
|
|
65
|
+
testID: "input-test",
|
|
66
|
+
onChangeText: onChangeTextMock
|
|
67
|
+
}
|
|
68
|
+
) })
|
|
62
69
|
);
|
|
63
|
-
fireEvent.changeText(getByTestId("input"), "foo");
|
|
70
|
+
fireEvent.changeText(getByTestId("input-test"), "foo");
|
|
64
71
|
expect(onChangeTextMock).toHaveBeenCalled();
|
|
65
72
|
});
|
|
66
73
|
it("should not call onChangeText when input is disabled", () => {
|
|
@@ -70,37 +77,37 @@ describe("<Input />", () => {
|
|
|
70
77
|
Input,
|
|
71
78
|
{
|
|
72
79
|
label: "Input",
|
|
73
|
-
testID: "input",
|
|
80
|
+
testID: "input-test",
|
|
74
81
|
onChangeText: onChangeTextMock,
|
|
75
82
|
disabled: true
|
|
76
83
|
}
|
|
77
84
|
) })
|
|
78
85
|
);
|
|
79
|
-
fireEvent(getByTestId("input"), "focus");
|
|
86
|
+
fireEvent(getByTestId("input-test"), "focus");
|
|
80
87
|
expect(onChangeTextMock).not.toHaveBeenCalled();
|
|
81
88
|
});
|
|
82
89
|
it("should call onFocus", () => {
|
|
83
90
|
const onFocusMock = jest.fn();
|
|
84
91
|
const { getByTestId } = render(
|
|
85
|
-
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input", onFocus: onFocusMock }) })
|
|
92
|
+
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input-test", onFocus: onFocusMock }) })
|
|
86
93
|
);
|
|
87
|
-
fireEvent(getByTestId("input"), "focus");
|
|
94
|
+
fireEvent(getByTestId("input-test"), "focus");
|
|
88
95
|
expect(onFocusMock).toHaveBeenCalled();
|
|
89
96
|
});
|
|
90
97
|
it("should call onBlur", () => {
|
|
91
98
|
const onBlurMock = jest.fn();
|
|
92
99
|
const { getByTestId } = render(
|
|
93
|
-
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input", onBlur: onBlurMock }) })
|
|
100
|
+
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input-test", onBlur: onBlurMock }) })
|
|
94
101
|
);
|
|
95
|
-
fireEvent(getByTestId("input"), "focus");
|
|
96
|
-
fireEvent(getByTestId("input"), "blur");
|
|
102
|
+
fireEvent(getByTestId("input-test"), "focus");
|
|
103
|
+
fireEvent(getByTestId("input-test"), "blur");
|
|
97
104
|
expect(onBlurMock).toHaveBeenCalled();
|
|
98
105
|
});
|
|
99
106
|
});
|
|
100
107
|
describe("maxLength", () => {
|
|
101
108
|
it("should update maxLength counter when add character", () => {
|
|
102
109
|
const { getByText, rerender } = render(
|
|
103
|
-
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input",
|
|
110
|
+
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", maxLength: 10 }) })
|
|
104
111
|
);
|
|
105
112
|
expect(getByText("0/10")).toBeTruthy();
|
|
106
113
|
rerender(
|
package/esm/Input/web/Input.js
CHANGED
|
@@ -64,14 +64,27 @@ describe("<Input />", () => {
|
|
|
64
64
|
);
|
|
65
65
|
expect(container).toMatchSnapshot();
|
|
66
66
|
});
|
|
67
|
+
it("should render with custom dataTestId", () => {
|
|
68
|
+
render(
|
|
69
|
+
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", "data-testid": "custom-input" }) })
|
|
70
|
+
);
|
|
71
|
+
expect(screen.getByTestId("custom-input")).toBeInTheDocument();
|
|
72
|
+
});
|
|
67
73
|
});
|
|
68
74
|
describe("Events", () => {
|
|
69
75
|
it("should call onChange", () => {
|
|
70
76
|
const onChangeMock = jest.fn();
|
|
71
77
|
render(
|
|
72
|
-
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
|
|
79
|
+
Input,
|
|
80
|
+
{
|
|
81
|
+
label: "Input",
|
|
82
|
+
onChange: onChangeMock,
|
|
83
|
+
"data-testid": "input-test"
|
|
84
|
+
}
|
|
85
|
+
) })
|
|
86
|
+
);
|
|
87
|
+
fireEvent.change(screen.getByTestId("input-test"), {
|
|
75
88
|
target: { value: "foo" }
|
|
76
89
|
});
|
|
77
90
|
expect(onChangeMock).toHaveBeenCalled();
|
|
@@ -87,10 +100,10 @@ describe("<Input />", () => {
|
|
|
87
100
|
it("should call onBlur", () => {
|
|
88
101
|
const onBlurMock = jest.fn();
|
|
89
102
|
render(
|
|
90
|
-
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", "data-testid": "input", onBlur: onBlurMock }) })
|
|
103
|
+
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", "data-testid": "input-test", onBlur: onBlurMock }) })
|
|
91
104
|
);
|
|
92
|
-
fireEvent.focus(screen.getByTestId("input"));
|
|
93
|
-
fireEvent.blur(screen.getByTestId("input"));
|
|
105
|
+
fireEvent.focus(screen.getByTestId("input-test"));
|
|
106
|
+
fireEvent.blur(screen.getByTestId("input-test"));
|
|
94
107
|
expect(onBlurMock).toHaveBeenCalled();
|
|
95
108
|
});
|
|
96
109
|
});
|
|
@@ -128,18 +141,26 @@ describe("<Input />", () => {
|
|
|
128
141
|
it("should have aria-label", () => {
|
|
129
142
|
const value = "aria label value";
|
|
130
143
|
const { getByTestId } = render(
|
|
131
|
-
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
|
|
132
|
-
|
|
133
|
-
|
|
144
|
+
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
|
|
145
|
+
Input,
|
|
146
|
+
{
|
|
147
|
+
label: "Input",
|
|
148
|
+
value: "foo",
|
|
149
|
+
ariaLabel: value,
|
|
150
|
+
"data-testid": "input-test"
|
|
151
|
+
}
|
|
152
|
+
) })
|
|
153
|
+
);
|
|
154
|
+
const inputElement = getByTestId("input-test");
|
|
134
155
|
expect(inputElement).toBeInTheDocument();
|
|
135
156
|
expect(inputElement).toHaveAttribute("aria-label", value);
|
|
136
157
|
});
|
|
137
158
|
it("should have label value", () => {
|
|
138
159
|
const value = "label value";
|
|
139
160
|
const { getByTestId } = render(
|
|
140
|
-
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: value, value: "foo" }) })
|
|
161
|
+
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: value, value: "foo", "data-testid": "input-test" }) })
|
|
141
162
|
);
|
|
142
|
-
const inputElement = getByTestId("input");
|
|
163
|
+
const inputElement = getByTestId("input-test");
|
|
143
164
|
expect(inputElement).toBeInTheDocument();
|
|
144
165
|
expect(inputElement).toHaveAttribute("aria-label", value);
|
|
145
166
|
});
|
|
@@ -84,7 +84,8 @@ const Snackbar = forwardRef((props, ref) => {
|
|
|
84
84
|
variant,
|
|
85
85
|
onSnackbarClose,
|
|
86
86
|
duration,
|
|
87
|
-
bottomOffset
|
|
87
|
+
bottomOffset,
|
|
88
|
+
dataTestId
|
|
88
89
|
} = _a, rest = __objRest(_a, [
|
|
89
90
|
"icon",
|
|
90
91
|
"message",
|
|
@@ -93,7 +94,8 @@ const Snackbar = forwardRef((props, ref) => {
|
|
|
93
94
|
"variant",
|
|
94
95
|
"onSnackbarClose",
|
|
95
96
|
"duration",
|
|
96
|
-
"bottomOffset"
|
|
97
|
+
"bottomOffset",
|
|
98
|
+
"dataTestId"
|
|
97
99
|
]);
|
|
98
100
|
const wrapperRef = useRef();
|
|
99
101
|
const [currentProps, setCurrentProps] = useState({
|
|
@@ -172,7 +174,8 @@ const Snackbar = forwardRef((props, ref) => {
|
|
|
172
174
|
SnackbarContainer,
|
|
173
175
|
__spreadProps(__spreadValues(__spreadValues({
|
|
174
176
|
variant: currentProps.variant,
|
|
175
|
-
bottomOffset
|
|
177
|
+
bottomOffset,
|
|
178
|
+
testID: dataTestId
|
|
176
179
|
}, rest), panResponder.panHandlers), {
|
|
177
180
|
children: [
|
|
178
181
|
currentProps.icon && /* @__PURE__ */ jsx(
|
|
@@ -227,7 +230,9 @@ Snackbar.propTypes = {
|
|
|
227
230
|
/** The duration sets how long it will take to close snackbar automatically, it may be "fast" (4 seconds), "default" (8 seconds), "slow" (10 seconds) or "indefinite" (it doesn't close automatically). */
|
|
228
231
|
duration: oneOf(["fast", "default", "slow", "indefinite"]),
|
|
229
232
|
/** Add extra margin to Snackbar. Can be useful for SafeAreaView or button cases. */
|
|
230
|
-
bottomOffset: number
|
|
233
|
+
bottomOffset: number,
|
|
234
|
+
/* A unique identifier for the Snackbar component, used for testing purposes with tools like Jest and Testing Library. */
|
|
235
|
+
dataTestId: string
|
|
231
236
|
};
|
|
232
237
|
Snackbar.defaultProps = {
|
|
233
238
|
variant: "success",
|
|
@@ -237,7 +242,8 @@ Snackbar.defaultProps = {
|
|
|
237
242
|
onAction: void 0,
|
|
238
243
|
onSnackbarClose: void 0,
|
|
239
244
|
duration: "default",
|
|
240
|
-
bottomOffset: 0
|
|
245
|
+
bottomOffset: 0,
|
|
246
|
+
dataTestId: "snackbar"
|
|
241
247
|
};
|
|
242
248
|
var Snackbar_default = Snackbar;
|
|
243
249
|
export {
|
|
@@ -52,6 +52,11 @@ describe("<Snackbar />", () => {
|
|
|
52
52
|
const { toJSON } = render(/* @__PURE__ */ jsx(Component, {}));
|
|
53
53
|
expect(toJSON()).toMatchSnapshot();
|
|
54
54
|
});
|
|
55
|
+
it("should render with custom dataTestId", () => {
|
|
56
|
+
const { getByTestId } = render(/* @__PURE__ */ jsx(Component, { dataTestId: "custom-snackbar" }));
|
|
57
|
+
fireEvent.press(getByTestId("custom-snackbar"));
|
|
58
|
+
expect(getByTestId("custom-snackbar")).toBeTruthy();
|
|
59
|
+
});
|
|
55
60
|
it("should match snapshot when have an icon and action", () => {
|
|
56
61
|
const overrideProps = {
|
|
57
62
|
icon: CheckedFull,
|
|
@@ -144,6 +144,7 @@ const Snackbar = React.forwardRef(
|
|
|
144
144
|
onClose,
|
|
145
145
|
hideCloseButton,
|
|
146
146
|
ariaLabelClose,
|
|
147
|
+
dataTestId,
|
|
147
148
|
theme: {
|
|
148
149
|
yoga: {
|
|
149
150
|
components: { snackbar }
|
|
@@ -160,6 +161,7 @@ const Snackbar = React.forwardRef(
|
|
|
160
161
|
"onClose",
|
|
161
162
|
"hideCloseButton",
|
|
162
163
|
"ariaLabelClose",
|
|
164
|
+
"dataTestId",
|
|
163
165
|
"theme"
|
|
164
166
|
]);
|
|
165
167
|
const timeoutRef = useRef();
|
|
@@ -178,7 +180,8 @@ const Snackbar = React.forwardRef(
|
|
|
178
180
|
role: "alert",
|
|
179
181
|
"aria-label": variant,
|
|
180
182
|
variant,
|
|
181
|
-
ref
|
|
183
|
+
ref,
|
|
184
|
+
"data-testid": dataTestId
|
|
182
185
|
}, props), {
|
|
183
186
|
children: [
|
|
184
187
|
!hideIcon && /* @__PURE__ */ jsx(
|
|
@@ -240,7 +243,9 @@ Snackbar.propTypes = {
|
|
|
240
243
|
/** Hides the close button. */
|
|
241
244
|
hideCloseButton: bool,
|
|
242
245
|
/** Custom aria label for close button. */
|
|
243
|
-
ariaLabelClose: string
|
|
246
|
+
ariaLabelClose: string,
|
|
247
|
+
/* A unique identifier for the Snackbar component, used for testing purposes with tools like Jest and Testing Library. */
|
|
248
|
+
dataTestId: string
|
|
244
249
|
};
|
|
245
250
|
Snackbar.defaultProps = {
|
|
246
251
|
open: false,
|
|
@@ -250,7 +255,8 @@ Snackbar.defaultProps = {
|
|
|
250
255
|
onAction: void 0,
|
|
251
256
|
variant: "success",
|
|
252
257
|
hideCloseButton: false,
|
|
253
|
-
ariaLabelClose: void 0
|
|
258
|
+
ariaLabelClose: void 0,
|
|
259
|
+
dataTestId: "snackbar"
|
|
254
260
|
};
|
|
255
261
|
var Snackbar_default = memo(withTheme(Snackbar));
|
|
256
262
|
export {
|
|
@@ -36,6 +36,20 @@ var require_Snackbar_test = __commonJS({
|
|
|
36
36
|
);
|
|
37
37
|
expect(container).toMatchSnapshot();
|
|
38
38
|
});
|
|
39
|
+
it("should render with custom dataTestId", () => {
|
|
40
|
+
render(
|
|
41
|
+
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
|
|
42
|
+
Snackbar,
|
|
43
|
+
{
|
|
44
|
+
open: true,
|
|
45
|
+
message: "Make wellbeing universal",
|
|
46
|
+
onClose: jest.fn(),
|
|
47
|
+
dataTestId: "custom-snackbar"
|
|
48
|
+
}
|
|
49
|
+
) })
|
|
50
|
+
);
|
|
51
|
+
expect(screen.getByTestId("custom-snackbar")).toBeInTheDocument();
|
|
52
|
+
});
|
|
39
53
|
it("should render a minimal snackbar", () => {
|
|
40
54
|
render(
|
|
41
55
|
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Snackbar, { open: true, message: "Make wellbeing universal", onClose: jest.fn() }) })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gympass/yoga",
|
|
3
|
-
"version": "7.127.
|
|
3
|
+
"version": "7.127.1",
|
|
4
4
|
"description": "Gympass component library",
|
|
5
5
|
"main": "./cjs",
|
|
6
6
|
"types": "./typings/index.d.ts",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"react-native": "0.72.3",
|
|
59
59
|
"styled-components": "^4.4.0"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "b439914bbb4d61946a25af1aefdf94b7cf5b778d",
|
|
62
62
|
"module": "./esm",
|
|
63
63
|
"private": false,
|
|
64
64
|
"react-native": "./cjs/index.native.js"
|