@jobber/components-native 0.89.1-JOB-139857-e7771b4.7 → 0.89.2
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/dist/package.json +2 -2
- package/dist/src/ContentOverlay/UNSAFE_WrappedModalize.js +1 -4
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/BottomSheet/BottomSheet.test.tsx +17 -17
- package/src/ButtonGroup/ButtonGroup.test.tsx +11 -9
- package/src/ContentOverlay/UNSAFE_WrappedModalize.tsx +0 -2
- package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +2 -2
- package/src/FormatFile/FormatFile.test.tsx +15 -15
- package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +12 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.89.
|
|
3
|
+
"version": "0.89.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"react-native-safe-area-context": "^5.4.0",
|
|
95
95
|
"react-native-svg": ">=12.0.0"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "33e1f533d1cf64dc6746f5db8f00763994fe5895"
|
|
98
98
|
}
|
|
@@ -43,42 +43,42 @@ function setup({
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
it("renders a BottomSheet", async () => {
|
|
46
|
-
const {
|
|
46
|
+
const { findByText } = setup({});
|
|
47
47
|
|
|
48
48
|
await waitForUntestableRender(
|
|
49
49
|
"Wait for AccessibilityInfo.isScreenReaderEnabled to resolve",
|
|
50
50
|
);
|
|
51
51
|
|
|
52
|
-
act(() => {
|
|
52
|
+
await act(async () => {
|
|
53
53
|
ref.current?.open();
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
expect(
|
|
56
|
+
expect(await findByText("BottomSheet")).toBeDefined();
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
it("renders a BottomSheet with a header", async () => {
|
|
60
60
|
const header = "Hello this is header";
|
|
61
|
-
const {
|
|
61
|
+
const { findByText } = setup({ heading: header });
|
|
62
62
|
|
|
63
63
|
await waitForUntestableRender(
|
|
64
64
|
"Wait for AccessibilityInfo.isScreenReaderEnabled to resolve",
|
|
65
65
|
);
|
|
66
66
|
|
|
67
|
-
act(() => {
|
|
67
|
+
await act(async () => {
|
|
68
68
|
ref.current?.open();
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
expect(
|
|
71
|
+
expect(await findByText(header)).toBeDefined();
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
it("BottomSheet can be closed with the cancel action", async () => {
|
|
75
|
-
const {
|
|
75
|
+
const { findByLabelText, queryByText } = setup({ showCancel: true });
|
|
76
76
|
|
|
77
|
-
act(() => {
|
|
77
|
+
await act(async () => {
|
|
78
78
|
ref.current?.open();
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
fireEvent.press(
|
|
81
|
+
fireEvent.press(await findByLabelText("Cancel"));
|
|
82
82
|
|
|
83
83
|
await waitFor(() => {
|
|
84
84
|
expect(queryByText("BottomSheet")).toBeNull();
|
|
@@ -93,7 +93,7 @@ describe("when loading is provided and true", () => {
|
|
|
93
93
|
"Wait for AccessibilityInfo.isScreenReaderEnabled to resolve",
|
|
94
94
|
);
|
|
95
95
|
|
|
96
|
-
act(() => {
|
|
96
|
+
await act(async () => {
|
|
97
97
|
ref.current?.open();
|
|
98
98
|
});
|
|
99
99
|
|
|
@@ -104,25 +104,25 @@ describe("when loading is provided and true", () => {
|
|
|
104
104
|
it("calls onClose when BottomSheet is closed", async () => {
|
|
105
105
|
setup({});
|
|
106
106
|
|
|
107
|
-
act(() => {
|
|
107
|
+
await act(async () => {
|
|
108
108
|
ref.current?.open();
|
|
109
109
|
ref.current?.close();
|
|
110
110
|
});
|
|
111
111
|
|
|
112
112
|
await waitFor(() => {
|
|
113
|
-
expect(mockOnClose).
|
|
113
|
+
expect(mockOnClose).toHaveBeenCalledTimes(1);
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
116
|
|
|
117
117
|
it("calls onOpen when BottomSheet is opened", async () => {
|
|
118
118
|
setup({});
|
|
119
119
|
|
|
120
|
-
act(() => {
|
|
120
|
+
await act(async () => {
|
|
121
121
|
ref.current?.open();
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
await waitFor(() => {
|
|
125
|
-
expect(mockOnOpen).
|
|
125
|
+
expect(mockOnOpen).toHaveBeenCalledTimes(1);
|
|
126
126
|
});
|
|
127
127
|
});
|
|
128
128
|
|
|
@@ -132,17 +132,17 @@ describe("when there is a screen reader enabled", () => {
|
|
|
132
132
|
.spyOn(AccessibilityInfo, "isScreenReaderEnabled")
|
|
133
133
|
.mockImplementation(() => Promise.resolve(true));
|
|
134
134
|
|
|
135
|
-
const {
|
|
135
|
+
const { findByLabelText, queryByText } = setup({});
|
|
136
136
|
|
|
137
137
|
await waitForUntestableRender(
|
|
138
138
|
"Wait for AccessibilityInfo.isScreenReaderEnabled to resolve",
|
|
139
139
|
);
|
|
140
140
|
|
|
141
|
-
act(() => {
|
|
141
|
+
await act(async () => {
|
|
142
142
|
ref.current?.open();
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
-
fireEvent.press(
|
|
145
|
+
fireEvent.press(await findByLabelText("Cancel"));
|
|
146
146
|
|
|
147
147
|
await waitFor(() => {
|
|
148
148
|
expect(queryByText("BottomSheet")).toBeNull();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { fireEvent, render } from "@testing-library/react-native";
|
|
2
|
+
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
3
3
|
import { Host } from "react-native-portalize";
|
|
4
4
|
import { Alert } from "react-native";
|
|
5
5
|
import type { ButtonGroupProps } from "./ButtonGroup";
|
|
@@ -168,7 +168,7 @@ it("fires the press handlers when the primary action buttons are pressed", () =>
|
|
|
168
168
|
expect(editAction).toHaveBeenCalled();
|
|
169
169
|
});
|
|
170
170
|
|
|
171
|
-
it("opens the secondary action menu when the More button is pressed", () => {
|
|
171
|
+
it("opens the secondary action menu when the More button is pressed", async () => {
|
|
172
172
|
const createAction = jest.fn();
|
|
173
173
|
const editAction = jest.fn();
|
|
174
174
|
const deleteAction = jest.fn();
|
|
@@ -196,11 +196,11 @@ it("opens the secondary action menu when the More button is pressed", () => {
|
|
|
196
196
|
|
|
197
197
|
fireEvent.press(getByLabelText("More"));
|
|
198
198
|
|
|
199
|
-
expect(findByText("Edit")).not.toBeNull();
|
|
200
|
-
expect(findByText("Delete")).not.toBeNull();
|
|
199
|
+
expect(await findByText("Edit")).not.toBeNull();
|
|
200
|
+
expect(await findByText("Delete")).not.toBeNull();
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
-
it("renders heading and cancel options if passed in", () => {
|
|
203
|
+
it("renders heading and cancel options if passed in", async () => {
|
|
204
204
|
const createAction = jest.fn();
|
|
205
205
|
const editAction = jest.fn();
|
|
206
206
|
const { findByText, getByLabelText } = render(
|
|
@@ -223,8 +223,8 @@ it("renders heading and cancel options if passed in", () => {
|
|
|
223
223
|
|
|
224
224
|
fireEvent.press(getByLabelText("More"));
|
|
225
225
|
|
|
226
|
-
expect(findByText("Heading")).not.toBeNull();
|
|
227
|
-
expect(findByText("Cancel")).not.toBeNull();
|
|
226
|
+
expect(await findByText("Heading")).not.toBeNull();
|
|
227
|
+
expect(await findByText("Cancel")).not.toBeNull();
|
|
228
228
|
});
|
|
229
229
|
|
|
230
230
|
it("renders custom button for primary action if passed in", () => {
|
|
@@ -249,7 +249,7 @@ it("renders custom button for primary action if passed in", () => {
|
|
|
249
249
|
expect(queryByText("Create")).toBeNull();
|
|
250
250
|
});
|
|
251
251
|
|
|
252
|
-
it("calls onOpenBottomSheet when the secondary actions are opened", () => {
|
|
252
|
+
it("calls onOpenBottomSheet when the secondary actions are opened", async () => {
|
|
253
253
|
const createAction = jest.fn();
|
|
254
254
|
const editAction = jest.fn();
|
|
255
255
|
const deleteAction = jest.fn();
|
|
@@ -275,7 +275,9 @@ it("calls onOpenBottomSheet when the secondary actions are opened", () => {
|
|
|
275
275
|
|
|
276
276
|
fireEvent.press(getByLabelText("More"));
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
await waitFor(() => {
|
|
279
|
+
expect(mockOnOpen).toHaveBeenCalledTimes(1);
|
|
280
|
+
});
|
|
279
281
|
});
|
|
280
282
|
|
|
281
283
|
describe("ButtonGroup Offline/Online", () => {
|
|
@@ -23,11 +23,9 @@ export const UNSAFE_WrappedModalize = forwardRef<IHandles | undefined, Props>(
|
|
|
23
23
|
requestAnimationFrame(() => {
|
|
24
24
|
innerRef.current?.open(dest);
|
|
25
25
|
});
|
|
26
|
-
props.onOpen?.();
|
|
27
26
|
},
|
|
28
27
|
close(dest) {
|
|
29
28
|
innerRef.current?.close(dest);
|
|
30
|
-
props.onClose?.();
|
|
31
29
|
},
|
|
32
30
|
}),
|
|
33
31
|
[],
|
|
@@ -127,7 +127,7 @@ describe("when a secondaryActions is passed in", () => {
|
|
|
127
127
|
const beforeSubmitMock = jest.fn().mockImplementation(() => {
|
|
128
128
|
return Promise.resolve(true);
|
|
129
129
|
});
|
|
130
|
-
const { getByLabelText } = render(
|
|
130
|
+
const { findByLabelText, getByLabelText } = render(
|
|
131
131
|
<ButtonGroupForTest
|
|
132
132
|
primaryAction={pressHandler}
|
|
133
133
|
loading={false}
|
|
@@ -145,7 +145,7 @@ describe("when a secondaryActions is passed in", () => {
|
|
|
145
145
|
/>,
|
|
146
146
|
);
|
|
147
147
|
fireEvent.press(getByLabelText("More"));
|
|
148
|
-
expect(
|
|
148
|
+
expect(await findByLabelText("hi")).toBeDefined();
|
|
149
149
|
fireEvent.press(getByLabelText("hi"));
|
|
150
150
|
expect(beforeSubmitMock).toHaveBeenCalled();
|
|
151
151
|
await waitFor(() => {
|
|
@@ -210,17 +210,17 @@ function basicRenderTestWithValue() {
|
|
|
210
210
|
jest.advanceTimersByTime(progressBarAnimationTime);
|
|
211
211
|
});
|
|
212
212
|
|
|
213
|
-
it("shows a BottomSheet with a remove option when tapped", () => {
|
|
214
|
-
const { getByTestId,
|
|
213
|
+
it("shows a BottomSheet with a remove option when tapped", async () => {
|
|
214
|
+
const { getByTestId, findByLabelText } = tree;
|
|
215
215
|
fireEvent.press(getByTestId(testId));
|
|
216
|
-
expect(
|
|
216
|
+
expect(await findByLabelText(removeLabel)).toBeDefined();
|
|
217
217
|
});
|
|
218
218
|
|
|
219
219
|
describe("when the BottomSheet remove option is tapped", () => {
|
|
220
|
-
it("calls the onRemove action", () => {
|
|
221
|
-
const { getByTestId,
|
|
220
|
+
it("calls the onRemove action", async () => {
|
|
221
|
+
const { getByTestId, findByLabelText } = tree;
|
|
222
222
|
fireEvent.press(getByTestId(testId));
|
|
223
|
-
fireEvent.press(
|
|
223
|
+
fireEvent.press(await findByLabelText(removeLabel));
|
|
224
224
|
expect(onRemove).toHaveBeenCalledTimes(1);
|
|
225
225
|
});
|
|
226
226
|
});
|
|
@@ -233,36 +233,36 @@ function basicRenderTestWithValue() {
|
|
|
233
233
|
);
|
|
234
234
|
|
|
235
235
|
describe("when the preview option is tapped", () => {
|
|
236
|
-
it("calls onPreview with a valid image", () => {
|
|
236
|
+
it("calls onPreview with a valid image", async () => {
|
|
237
237
|
const previewLabel = "Preview image";
|
|
238
|
-
const { getByTestId,
|
|
238
|
+
const { getByTestId, findByLabelText } = renderFormatFile(
|
|
239
239
|
FILE_UPLOAD_MOCK_IMAGE({ progress: 1, status: StatusCode.Completed }),
|
|
240
240
|
"image",
|
|
241
241
|
);
|
|
242
242
|
fireEvent.press(getByTestId("test-image"));
|
|
243
|
-
fireEvent.press(
|
|
243
|
+
fireEvent.press(await findByLabelText(previewLabel));
|
|
244
244
|
expect(mockOnPreview).toHaveBeenCalledTimes(1);
|
|
245
245
|
});
|
|
246
246
|
|
|
247
|
-
it("calls onPreview with a valid pdf file", () => {
|
|
247
|
+
it("calls onPreview with a valid pdf file", async () => {
|
|
248
248
|
const previewLabel = "Preview file";
|
|
249
|
-
const { getByTestId,
|
|
249
|
+
const { getByTestId, findByLabelText } = renderFormatFile(
|
|
250
250
|
FILE_UPLOAD_MOCK_PDF({ progress: 1, status: StatusCode.Completed }),
|
|
251
251
|
"file",
|
|
252
252
|
);
|
|
253
253
|
fireEvent.press(getByTestId("test-file"));
|
|
254
|
-
fireEvent.press(
|
|
254
|
+
fireEvent.press(await findByLabelText(previewLabel));
|
|
255
255
|
expect(mockOnPreview).toHaveBeenCalledTimes(1);
|
|
256
256
|
});
|
|
257
257
|
|
|
258
|
-
it("calls onPreview with a valid external PDF file", () => {
|
|
258
|
+
it("calls onPreview with a valid external PDF file", async () => {
|
|
259
259
|
const previewLabel = "Preview file";
|
|
260
|
-
const { getByTestId,
|
|
260
|
+
const { getByTestId, findByLabelText } = renderFormatFile(
|
|
261
261
|
FILE_MOCK_PDF,
|
|
262
262
|
"file",
|
|
263
263
|
);
|
|
264
264
|
fireEvent.press(getByTestId("test-file"));
|
|
265
|
-
fireEvent.press(
|
|
265
|
+
fireEvent.press(await findByLabelText(previewLabel));
|
|
266
266
|
expect(mockOnPreview).toHaveBeenCalledTimes(1);
|
|
267
267
|
});
|
|
268
268
|
|
|
@@ -52,29 +52,29 @@ const basicRenderTestWithValue = () => {
|
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
describe("onPreviewPress", () => {
|
|
55
|
-
it("renders the preview option", () => {
|
|
56
|
-
const {
|
|
55
|
+
it("renders the preview option", async () => {
|
|
56
|
+
const { findByLabelText } = tree;
|
|
57
57
|
|
|
58
|
-
expect(
|
|
58
|
+
expect(await findByLabelText(previewLabel)).toBeDefined();
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
it("is called when pressed", () => {
|
|
62
|
-
const {
|
|
63
|
-
fireEvent.press(
|
|
61
|
+
it("is called when pressed", async () => {
|
|
62
|
+
const { findByLabelText } = tree;
|
|
63
|
+
fireEvent.press(await findByLabelText(previewLabel));
|
|
64
64
|
expect(onPreview).toHaveBeenCalledTimes(1);
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
describe("onRemovePress", () => {
|
|
69
|
-
it("renders the remove option", () => {
|
|
70
|
-
const {
|
|
69
|
+
it("renders the remove option", async () => {
|
|
70
|
+
const { findByLabelText } = tree;
|
|
71
71
|
|
|
72
|
-
expect(
|
|
72
|
+
expect(await findByLabelText(removeLabel)).toBeDefined();
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
it("is called when pressed", () => {
|
|
76
|
-
const {
|
|
77
|
-
fireEvent.press(
|
|
75
|
+
it("is called when pressed", async () => {
|
|
76
|
+
const { findByLabelText } = tree;
|
|
77
|
+
fireEvent.press(await findByLabelText(removeLabel));
|
|
78
78
|
|
|
79
79
|
expect(onRemove).toHaveBeenCalledTimes(1);
|
|
80
80
|
});
|