@jobber/components-native 0.87.1 → 0.88.1-JOB-139048-04134dd.0

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.
Files changed (32) hide show
  1. package/dist/package.json +15 -16
  2. package/dist/src/Button/components/InternalButtonLoading/InternalButtonLoading.js +0 -1
  3. package/dist/src/ContentOverlay/ContentOverlay.js +2 -2
  4. package/dist/src/ContentOverlay/UNSAFE_WrappedModalize.js +27 -0
  5. package/dist/src/ContentOverlay/index.js +1 -0
  6. package/dist/src/utils/meta/meta.json +2 -1
  7. package/dist/tsconfig.build.tsbuildinfo +1 -1
  8. package/dist/types/src/ContentOverlay/ContentOverlay.d.ts +1 -1
  9. package/dist/types/src/ContentOverlay/UNSAFE_WrappedModalize.d.ts +3 -0
  10. package/dist/types/src/ContentOverlay/index.d.ts +1 -0
  11. package/dist/types/src/InputText/InputText.d.ts +2 -2
  12. package/package.json +15 -16
  13. package/src/AtlantisContext/AtlantisContext.test.tsx +1 -1
  14. package/src/AutoLink/AutoLink.test.tsx +2 -4
  15. package/src/Button/components/InternalButtonLoading/InternalButtonLoading.tsx +0 -1
  16. package/src/Checkbox/CheckboxGroup.test.tsx +2 -6
  17. package/src/ContentOverlay/ContentOverlay.test.tsx +30 -23
  18. package/src/ContentOverlay/ContentOverlay.tsx +4 -3
  19. package/src/ContentOverlay/UNSAFE_WrappedModalize.tsx +45 -0
  20. package/src/ContentOverlay/hooks/useKeyboardVisibility.test.ts +1 -1
  21. package/src/ContentOverlay/hooks/useViewLayoutHeight.test.ts +1 -1
  22. package/src/ContentOverlay/index.ts +1 -0
  23. package/src/EmptyState/EmptyState.test.tsx +29 -42
  24. package/src/Form/components/FormMessage/FormMessage.test.tsx +40 -27
  25. package/src/Form/context/AtlantisFormContext.test.tsx +1 -1
  26. package/src/Form/hooks/useScrollToError/useScrollToError.test.tsx +2 -1
  27. package/src/FormatFile/FormatFile.test.tsx +6 -6
  28. package/src/Icon/__snapshots__/Icon.test.tsx.snap +7 -0
  29. package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +5 -11
  30. package/src/InputText/InputText.tsx +2 -5
  31. package/src/ThumbnailList/ThumbnailList.test.tsx +5 -5
  32. package/src/utils/meta/meta.json +2 -1
@@ -1,30 +1,41 @@
1
1
  import React from "react";
2
- import { fireEvent, render } from "@testing-library/react-native";
2
+ import {
3
+ fireEvent,
4
+ render,
5
+ screen,
6
+ waitFor,
7
+ } from "@testing-library/react-native";
3
8
  import { FormMessage } from ".";
4
9
 
5
10
  describe("FormMessage", () => {
6
11
  it("should render null when there are no message to show", () => {
7
- const view = render(<FormMessage />);
8
- expect(view.toJSON()).toMatchInlineSnapshot(`null`);
12
+ render(<FormMessage />);
13
+ expect(screen.toJSON()).toMatchInlineSnapshot(`null`);
9
14
  });
10
15
 
11
- it("should show the message", () => {
12
- const { getByText } = render(<FormMessage />);
16
+ it("should show the message", async () => {
17
+ render(<FormMessage />);
13
18
 
14
19
  const description = "🔥";
15
20
  FormMessage.show({ description });
16
- expect(getByText(description)).toBeDefined();
21
+ await waitFor(() => {
22
+ expect(screen.getByText(description)).toBeDefined();
23
+ });
17
24
  });
18
25
 
19
- it("should close the message", () => {
20
- const { getByText, queryByText } = render(<FormMessage />);
26
+ it("should close the message", async () => {
27
+ render(<FormMessage />);
21
28
 
22
29
  const description = "🌚";
23
30
  FormMessage.show({ description });
24
- expect(getByText(description)).toBeDefined();
31
+ await waitFor(() => {
32
+ expect(screen.getByText(description)).toBeDefined();
33
+ });
25
34
 
26
35
  FormMessage.close();
27
- expect(queryByText(description)).toBeNull();
36
+ await waitFor(() => {
37
+ expect(screen.queryByText(description)).toBeNull();
38
+ });
28
39
  });
29
40
 
30
41
  describe("Opening another message through a message", () => {
@@ -40,33 +51,35 @@ describe("FormMessage", () => {
40
51
  },
41
52
  });
42
53
 
43
- it("should show the most recent message", () => {
44
- const { getByText, queryByText, getByLabelText } = render(
45
- <FormMessage />,
46
- );
54
+ it("should show the most recent message", async () => {
55
+ render(<FormMessage />);
47
56
 
48
57
  showMessage();
49
58
 
50
- expect(getByText(firstMessage)).toBeDefined();
51
- expect(queryByText(secondMessage)).toBeNull();
59
+ await waitFor(() => {
60
+ expect(screen.getByText(firstMessage)).toBeDefined();
61
+ });
62
+ expect(screen.queryByText(secondMessage)).toBeNull();
52
63
 
53
- fireEvent.press(getByLabelText("Click me"));
64
+ fireEvent.press(screen.getByLabelText("Click me"));
54
65
 
55
- expect(getByText(secondMessage)).toBeDefined();
56
- expect(queryByText(firstMessage)).toBeNull();
66
+ expect(screen.getByText(secondMessage)).toBeDefined();
67
+ expect(screen.queryByText(firstMessage)).toBeNull();
57
68
  });
58
69
 
59
- it("should close the most recent message", () => {
60
- const { getByText, queryByText, getByLabelText } = render(
61
- <FormMessage />,
62
- );
70
+ it("should close the most recent message", async () => {
71
+ render(<FormMessage />);
63
72
 
64
73
  showMessage();
65
- fireEvent.press(getByLabelText("Click me"));
74
+ await waitFor(() => {
75
+ expect(screen.getByText("Click me")).toBeDefined();
76
+ });
77
+ fireEvent.press(screen.getByLabelText("Click me"));
66
78
  FormMessage.close();
67
-
68
- expect(getByText(firstMessage)).toBeDefined();
69
- expect(queryByText(secondMessage)).toBeNull();
79
+ await waitFor(() => {
80
+ expect(screen.getByText(firstMessage)).toBeDefined();
81
+ });
82
+ expect(screen.queryByText(secondMessage)).toBeNull();
70
83
  });
71
84
  });
72
85
  });
@@ -1,6 +1,6 @@
1
1
  import type { PropsWithChildren } from "react";
2
2
  import React from "react";
3
- import { renderHook } from "@testing-library/react-hooks";
3
+ import { renderHook } from "@testing-library/react-native";
4
4
  import type { AtlantisFormContextProps } from "./types";
5
5
  import {
6
6
  AtlantisFormContext,
@@ -1,4 +1,4 @@
1
- import { renderHook } from "@testing-library/react-hooks";
1
+ import { renderHook } from "@testing-library/react-native";
2
2
  import { useScrollToError } from "./useScrollToError";
3
3
 
4
4
  const mockFormState = {
@@ -25,6 +25,7 @@ jest.mock("../../../ErrorMessageWrapper", () => ({
25
25
  el: {
26
26
  measure: jest.fn((_, callback) => callback()),
27
27
  hasErrorMessage: true,
28
+ accessibilityFocus: jest.fn(),
28
29
  },
29
30
  },
30
31
  register: jest.fn(),
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
2
  import type { RenderAPI } from "@testing-library/react-native";
3
- import { fireEvent, render } from "@testing-library/react-native";
4
- import { Host } from "react-native-portalize";
3
+ import { fireEvent, render, waitFor } from "@testing-library/react-native";
5
4
  import { Alert } from "react-native";
5
+ import { Host } from "react-native-portalize";
6
6
  import type { File } from ".";
7
7
  import { FormatFile } from ".";
8
8
  import {
@@ -117,12 +117,12 @@ function basicRenderTestWithValue() {
117
117
  );
118
118
  });
119
119
 
120
- it("renders ProgressBar state advancing with the upload percentage", () => {
120
+ it("renders ProgressBar state advancing with the upload percentage", async () => {
121
121
  jest.useFakeTimers();
122
122
  const { getByTestId } = renderFormatFile(file);
123
123
  jest.advanceTimersByTime(progressBarAnimationTime);
124
- const formatFileInnerProgressBar = getByTestId(
125
- "format-file-inner-progress-bar",
124
+ const formatFileInnerProgressBar = await waitFor(() =>
125
+ getByTestId("format-file-inner-progress-bar"),
126
126
  );
127
127
  const innerProgressBarWidth = parseInt(
128
128
  formatFileInnerProgressBar.props.style.width,
@@ -226,7 +226,7 @@ function basicRenderTestWithValue() {
226
226
  });
227
227
 
228
228
  it("creates a thumbnail when a media file is used", () => {
229
- const expectedCalls = testId.includes("image") ? 2 : 0;
229
+ const expectedCalls = testId.includes("image") ? 1 : 0;
230
230
  expect(mockCreateThumbnail).toHaveBeenCalledTimes(expectedCalls);
231
231
  });
232
232
  },
@@ -433,6 +433,13 @@ exports[`renders thumbsDown icon 1`] = `
433
433
  ]
434
434
  }
435
435
  testID="thumbsDown"
436
+ transform={
437
+ [
438
+ {
439
+ "scaleY": -1,
440
+ },
441
+ ]
442
+ }
436
443
  vbHeight={24}
437
444
  vbWidth={24}
438
445
  >
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
- import { render, renderHook } from "@testing-library/react-native";
2
+ import { render, renderHook, screen } from "@testing-library/react-native";
3
3
  import type { TextStyle } from "react-native";
4
4
  import type { ReactTestInstance } from "react-test-renderer";
5
+ import { Path } from "react-native-svg";
5
6
  import type { PrefixIconProps, PrefixLabelProps } from "./Prefix";
6
7
  import {
7
8
  PrefixIcon,
@@ -12,9 +13,6 @@ import {
12
13
  import { useTypographyStyles } from "../../../Typography";
13
14
  import { useStyles } from "../../InputFieldWrapper.style";
14
15
  import { tokens } from "../../../utils/design";
15
- import * as IconComponent from "../../../Icon/Icon";
16
-
17
- const iconSpy = jest.spyOn(IconComponent, "Icon");
18
16
 
19
17
  const mockLabel = "$";
20
18
 
@@ -180,13 +178,9 @@ describe("Prefix", () => {
180
178
  setupIcon({
181
179
  disabled: true,
182
180
  });
183
- expect(iconSpy).toHaveBeenCalledWith(
184
- {
185
- customColor: tokens["color-disabled"],
186
- name: "invoice",
187
- },
188
- {},
189
- );
181
+ const icon = screen.getByTestId("invoice");
182
+ const path = icon.findByType(Path);
183
+ expect(path.props.fill).toEqual(tokens["color-disabled"]);
190
184
  });
191
185
  });
192
186
 
@@ -8,10 +8,9 @@ import React, {
8
8
  useState,
9
9
  } from "react";
10
10
  import type {
11
- NativeSyntheticEvent,
11
+ FocusEvent,
12
12
  ReturnKeyTypeOptions,
13
13
  StyleProp,
14
- TextInputFocusEventData,
15
14
  TextInputProps,
16
15
  TextStyle,
17
16
  } from "react-native";
@@ -113,9 +112,7 @@ export interface InputTextProps
113
112
  * Callback that is called when the text input is focused
114
113
  * @param event
115
114
  */
116
- readonly onFocus?: (
117
- event?: NativeSyntheticEvent<TextInputFocusEventData>,
118
- ) => void;
115
+ readonly onFocus?: (event?: FocusEvent) => void;
119
116
 
120
117
  /**
121
118
  * Callback that is called when the text input is blurred
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { fireEvent, render } from "@testing-library/react-native";
2
+ import { fireEvent, render, screen } from "@testing-library/react-native";
3
3
  import { Host } from "react-native-portalize";
4
4
  import { ThumbnailList } from "./ThumbnailList";
5
5
  import type { File } from "../FormatFile/types";
@@ -61,15 +61,15 @@ beforeEach(() => {
61
61
  });
62
62
 
63
63
  it("renders a thumbnail component with attachments", () => {
64
- const tree = setup(true);
65
- expect(tree.toJSON()).toMatchSnapshot();
64
+ setup(true);
65
+ expect(screen.toJSON()).toMatchSnapshot();
66
66
  });
67
67
 
68
68
  describe("when a an array of files is provided", () => {
69
69
  it("calls the previewImages util on pressing a valid file", () => {
70
- const { getByLabelText } = setup();
70
+ setup();
71
71
  fireEvent.press(
72
- getByLabelText(files[0].fileName ? files[0].fileName : "file"),
72
+ screen.getByLabelText(files[0].fileName ? files[0].fileName : "file"),
73
73
  );
74
74
  expect(onOpenFile).toHaveBeenCalledTimes(1);
75
75
  });
@@ -64,6 +64,7 @@
64
64
  "ThumbnailList",
65
65
  "Toast",
66
66
  "Typography",
67
- "TypographyGestureDetector"
67
+ "TypographyGestureDetector",
68
+ "UNSAFE_WrappedModalize"
68
69
  ]
69
70
  }