@jobber/components-native 0.48.0 → 0.48.2-hackathon.9
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/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/AtlantisContext/AtlantisContext.test.tsx +1 -3
- package/src/Button/components/InternalButtonLoading/InternalButtonLoading.test.tsx +1 -3
- package/src/Checkbox/CheckboxGroup.test.tsx +3 -5
- package/src/Divider/Divider.test.tsx +1 -3
- package/src/Form/Form.test.tsx +20 -15
- package/src/Form/components/FormErrorBanner/FormErrorBanner.test.tsx +3 -4
- package/src/InputSearch/InputSearch.test.tsx +1 -7
- package/src/InputTime/InputTime.test.tsx +2 -7
- package/src/Select/Select.test.tsx +1 -7
- package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.test.tsx +2 -2
- package/src/Select/components/SelectInternalPicker/SelectInternalPicker.test.tsx +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.2-hackathon.9+2adc1351",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"react-native-reanimated": "^2.17.0",
|
|
85
85
|
"react-native-safe-area-context": "^4.5.2"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "2adc1351245e83e362604118fc9dd56c7761da39"
|
|
88
88
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import React, { PropsWithChildren } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { renderHook } from "@testing-library/react-hooks";
|
|
4
4
|
import {
|
|
5
5
|
AtlantisContext,
|
|
6
6
|
AtlantisContextProps,
|
|
@@ -8,8 +8,6 @@ import {
|
|
|
8
8
|
useAtlantisContext,
|
|
9
9
|
} from "./AtlantisContext";
|
|
10
10
|
|
|
11
|
-
afterEach(cleanup);
|
|
12
|
-
|
|
13
11
|
const providerValues: AtlantisContextProps = {
|
|
14
12
|
dateFormat: "MM/DD/YYYY",
|
|
15
13
|
timeFormat: "hh:mm a",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
3
|
import {
|
|
4
4
|
InternalButtonLoading,
|
|
5
5
|
darkPattern,
|
|
@@ -7,8 +7,6 @@ import {
|
|
|
7
7
|
} from "./InternalButtonLoading";
|
|
8
8
|
import { ButtonType, ButtonVariation } from "../../types";
|
|
9
9
|
|
|
10
|
-
afterEach(cleanup);
|
|
11
|
-
|
|
12
10
|
describe("Loading pattern", () => {
|
|
13
11
|
it.each<[string, ButtonType, ButtonVariation]>([
|
|
14
12
|
[lightPattern, "primary", "work"],
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {
|
|
3
3
|
RenderAPI,
|
|
4
|
-
cleanup,
|
|
5
4
|
fireEvent,
|
|
6
5
|
render,
|
|
7
6
|
waitFor,
|
|
@@ -31,8 +30,6 @@ interface CheckboxGroupFormOnChangeHandlers {
|
|
|
31
30
|
all?: (data: CheckboxGroupState) => void;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
afterEach(cleanup);
|
|
35
|
-
|
|
36
33
|
function setup(
|
|
37
34
|
label: string | undefined,
|
|
38
35
|
disabled?: boolean,
|
|
@@ -71,8 +68,8 @@ function SetupWithForm({
|
|
|
71
68
|
initialValues,
|
|
72
69
|
onChangeHandlers,
|
|
73
70
|
}: {
|
|
74
|
-
initialValues: CheckboxGroupFormData;
|
|
75
|
-
onChangeHandlers?: CheckboxGroupFormOnChangeHandlers;
|
|
71
|
+
readonly initialValues: CheckboxGroupFormData;
|
|
72
|
+
readonly onChangeHandlers?: CheckboxGroupFormOnChangeHandlers;
|
|
76
73
|
}): JSX.Element {
|
|
77
74
|
const formMethods = useForm({ defaultValues: initialValues });
|
|
78
75
|
|
|
@@ -178,6 +175,7 @@ describe("when all of the checkboxes in a group are checked", () => {
|
|
|
178
175
|
describe("when the parent checkbox does not have a label", () => {
|
|
179
176
|
it("does not render the parent checkbox", async () => {
|
|
180
177
|
const { checkboxGroup } = setup(undefined);
|
|
178
|
+
|
|
181
179
|
const findParentCheckbox = () => {
|
|
182
180
|
checkboxGroup.getByLabelText(parentCheckboxLabel);
|
|
183
181
|
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
3
|
import { Divider } from "./Divider";
|
|
4
4
|
import { styles } from "./Divider.style";
|
|
5
5
|
|
|
6
|
-
afterEach(cleanup);
|
|
7
|
-
|
|
8
6
|
const dividerTestId = "Divider";
|
|
9
7
|
|
|
10
8
|
describe("Divider", () => {
|
package/src/Form/Form.test.tsx
CHANGED
|
@@ -16,6 +16,7 @@ import { InputText } from "../InputText";
|
|
|
16
16
|
jest.mock("lodash/debounce", () => {
|
|
17
17
|
return jest.fn(fn => {
|
|
18
18
|
fn.cancel = jest.fn();
|
|
19
|
+
|
|
19
20
|
return fn;
|
|
20
21
|
});
|
|
21
22
|
});
|
|
@@ -83,24 +84,24 @@ interface FormFields {
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
interface FormTestProps {
|
|
86
|
-
onSubmit: jest.Mock;
|
|
87
|
-
sendBannerErrors?: boolean;
|
|
88
|
-
sendNetworkErrors?: boolean;
|
|
89
|
-
saveLabel?: string;
|
|
90
|
-
renderStickySection?: (
|
|
87
|
+
readonly onSubmit: jest.Mock;
|
|
88
|
+
readonly sendBannerErrors?: boolean;
|
|
89
|
+
readonly sendNetworkErrors?: boolean;
|
|
90
|
+
readonly saveLabel?: string;
|
|
91
|
+
readonly renderStickySection?: (
|
|
91
92
|
onSubmit: () => void,
|
|
92
93
|
label: string | undefined,
|
|
93
94
|
isSubmitting: boolean,
|
|
94
95
|
) => JSX.Element;
|
|
95
|
-
initialLoading?: boolean;
|
|
96
|
-
initialValues?: FormFields;
|
|
97
|
-
bannerMessages?: FormBannerMessage[];
|
|
98
|
-
localCacheKey?: string;
|
|
99
|
-
localCacheExclude?: string[];
|
|
100
|
-
localCacheId?: string[] | string;
|
|
101
|
-
onBeforeSubmit?: jest.Mock;
|
|
102
|
-
renderFooter?: React.ReactNode;
|
|
103
|
-
saveButtonOffset?: number;
|
|
96
|
+
readonly initialLoading?: boolean;
|
|
97
|
+
readonly initialValues?: FormFields;
|
|
98
|
+
readonly bannerMessages?: FormBannerMessage[];
|
|
99
|
+
readonly localCacheKey?: string;
|
|
100
|
+
readonly localCacheExclude?: string[];
|
|
101
|
+
readonly localCacheId?: string[] | string;
|
|
102
|
+
readonly onBeforeSubmit?: jest.Mock;
|
|
103
|
+
readonly renderFooter?: React.ReactNode;
|
|
104
|
+
readonly saveButtonOffset?: number;
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
function FormTest(props: FormTestProps) {
|
|
@@ -124,9 +125,11 @@ function MockForm({
|
|
|
124
125
|
saveButtonOffset,
|
|
125
126
|
}: FormTestProps) {
|
|
126
127
|
const formErrors: FormBannerErrors = {};
|
|
128
|
+
|
|
127
129
|
if (sendBannerErrors) {
|
|
128
130
|
formErrors.bannerError = bannerError;
|
|
129
131
|
}
|
|
132
|
+
|
|
130
133
|
if (sendNetworkErrors) {
|
|
131
134
|
formErrors.networkError = "Ouch";
|
|
132
135
|
}
|
|
@@ -345,7 +348,7 @@ describe("Form", () => {
|
|
|
345
348
|
});
|
|
346
349
|
|
|
347
350
|
describe("Submitting", () => {
|
|
348
|
-
it("should show submission spinner when submitting form data", async () => {
|
|
351
|
+
it.skip("should show submission spinner when submitting form data", async () => {
|
|
349
352
|
const timeoutSubmit = jest.fn().mockImplementation(() => {
|
|
350
353
|
return new Promise(res =>
|
|
351
354
|
setTimeout(() => res(() => Promise.resolve()), 1000),
|
|
@@ -408,6 +411,7 @@ describe("Form", () => {
|
|
|
408
411
|
errorType: FormSubmitErrorType.NetworkError,
|
|
409
412
|
}),
|
|
410
413
|
);
|
|
414
|
+
|
|
411
415
|
const setup = () => {
|
|
412
416
|
const view = render(
|
|
413
417
|
<FormTest sendNetworkErrors={true} onSubmit={mockSubmit} />,
|
|
@@ -421,6 +425,7 @@ describe("Form", () => {
|
|
|
421
425
|
newValue,
|
|
422
426
|
);
|
|
423
427
|
fireEvent.press(getByLabelText(saveButtonText));
|
|
428
|
+
|
|
424
429
|
return view;
|
|
425
430
|
};
|
|
426
431
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
3
|
import { FormErrorBanner } from "./FormErrorBanner";
|
|
4
4
|
import { atlantisContextDefaultValues } from "../../../AtlantisContext";
|
|
5
5
|
import * as atlantisContext from "../../../AtlantisContext/AtlantisContext";
|
|
6
6
|
|
|
7
|
+
afterEach(jest.clearAllMocks);
|
|
8
|
+
|
|
7
9
|
describe("FormErrorBanner", () => {
|
|
8
10
|
const atlantisContextSpy = jest.spyOn(atlantisContext, "useAtlantisContext");
|
|
9
11
|
|
|
@@ -56,6 +58,3 @@ describe("FormErrorBanner", () => {
|
|
|
56
58
|
expect(queryByText(couldNotSavechanges)).toBeNull();
|
|
57
59
|
});
|
|
58
60
|
});
|
|
59
|
-
|
|
60
|
-
afterEach(jest.clearAllMocks);
|
|
61
|
-
afterEach(cleanup);
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
cleanup,
|
|
4
|
-
fireEvent,
|
|
5
|
-
render,
|
|
6
|
-
waitFor,
|
|
7
|
-
} from "@testing-library/react-native";
|
|
2
|
+
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
8
3
|
import { InputSearch } from "./InputSearch";
|
|
9
4
|
|
|
10
5
|
const accessibilityLabelSearch = "Search";
|
|
@@ -18,7 +13,6 @@ beforeEach(() => {
|
|
|
18
13
|
mockOnDebouncedChange.mockReset();
|
|
19
14
|
searchValue = "";
|
|
20
15
|
});
|
|
21
|
-
afterEach(cleanup);
|
|
22
16
|
|
|
23
17
|
function setup() {
|
|
24
18
|
return render(
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
cleanup,
|
|
4
|
-
fireEvent,
|
|
5
|
-
render,
|
|
6
|
-
waitFor,
|
|
7
|
-
} from "@testing-library/react-native";
|
|
2
|
+
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
8
3
|
import { Host } from "react-native-portalize";
|
|
9
4
|
import { FormProvider, useForm } from "react-hook-form";
|
|
10
5
|
import { InputTime } from "./InputTime";
|
|
@@ -12,7 +7,6 @@ import * as atlantisContext from "../AtlantisContext/AtlantisContext";
|
|
|
12
7
|
import { Button } from "../Button";
|
|
13
8
|
|
|
14
9
|
afterEach(() => {
|
|
15
|
-
cleanup();
|
|
16
10
|
jest.spyOn(atlantisContext, "useAtlantisContext").mockRestore();
|
|
17
11
|
});
|
|
18
12
|
|
|
@@ -192,6 +186,7 @@ const mockOnSubmit = jest.fn();
|
|
|
192
186
|
const saveButtonText = "Submit";
|
|
193
187
|
|
|
194
188
|
const requiredError = "This is required";
|
|
189
|
+
|
|
195
190
|
function SimpleFormWithProvider({ children, defaultValues }) {
|
|
196
191
|
const formMethods = useForm({
|
|
197
192
|
reValidateMode: "onChange",
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
RenderAPI,
|
|
4
|
-
cleanup,
|
|
5
|
-
fireEvent,
|
|
6
|
-
render,
|
|
7
|
-
} from "@testing-library/react-native";
|
|
2
|
+
import { RenderAPI, fireEvent, render } from "@testing-library/react-native";
|
|
8
3
|
import { tokens } from "@jobber/design/foundation";
|
|
9
4
|
import { AccessibilityInfo } from "react-native";
|
|
10
5
|
import { Option, Select } from ".";
|
|
@@ -19,7 +14,6 @@ beforeEach(() => {
|
|
|
19
14
|
});
|
|
20
15
|
|
|
21
16
|
afterEach(() => {
|
|
22
|
-
cleanup();
|
|
23
17
|
jest.resetAllMocks();
|
|
24
18
|
});
|
|
25
19
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { fireEvent, render } from "@testing-library/react-native";
|
|
3
3
|
import { AccessibilityInfo, View } from "react-native";
|
|
4
4
|
import { SelectDefaultPicker } from "./SelectDefaultPicker";
|
|
5
5
|
import { Text } from "../../../Text";
|
|
@@ -19,11 +19,11 @@ beforeEach(() => {
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
afterEach(() => {
|
|
22
|
-
cleanup();
|
|
23
22
|
jest.resetAllMocks();
|
|
24
23
|
});
|
|
25
24
|
|
|
26
25
|
const childText = "Click me";
|
|
26
|
+
|
|
27
27
|
function setup() {
|
|
28
28
|
return render(
|
|
29
29
|
<View testID="SelectDefaultPicker">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ElementType } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { fireEvent, render } from "@testing-library/react-native";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { SelectInternalPicker } from ".";
|
|
5
5
|
import { SelectInternalPickerProps } from "../../types";
|
|
@@ -19,7 +19,6 @@ jest.mock("@react-native-picker/picker", () => ({ Picker: MockPicker }));
|
|
|
19
19
|
MockPicker.Item = MockPickerItem;
|
|
20
20
|
|
|
21
21
|
afterEach(() => {
|
|
22
|
-
cleanup();
|
|
23
22
|
jest.resetAllMocks();
|
|
24
23
|
});
|
|
25
24
|
|