@jobber/components-native 0.80.1-upgrade-to-feb557b.16 → 0.80.1-upgrade-to-2c02d1f.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.80.1-upgrade-to-feb557b.16+feb557bf",
3
+ "version": "0.80.1-upgrade-to-2c02d1f.23+2c02d1fc",
4
4
  "license": "MIT",
5
5
  "description": "React Native implementation of Atlantis",
6
6
  "repository": {
@@ -70,7 +70,7 @@
70
70
  "date-fns-tz": "^2.0.0",
71
71
  "react": "^18.2.0",
72
72
  "react-intl": "^6.4.2",
73
- "react-native": ">=0.69.2",
73
+ "react-native": ">=0.77.0",
74
74
  "react-native-gesture-handler": ">=2.10.0",
75
75
  "react-native-keyboard-aware-scroll-view": "^0.9.5",
76
76
  "react-native-modal-datetime-picker": " >=13.0.0",
@@ -80,5 +80,5 @@
80
80
  "react-native-safe-area-context": "^4.5.2",
81
81
  "react-native-svg": ">=12.0.0"
82
82
  },
83
- "gitHead": "feb557bf7d157f62138d5d34303d9fdb2cf61fb1"
83
+ "gitHead": "2c02d1fc6bffcecd659c2b0bdc58a22670c43548"
84
84
  }
@@ -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 { ReactTestInstance } from "react-test-renderer";
4
4
  import { Disclosure } from ".";
5
5
  import { Text } from "../Text";
@@ -23,49 +23,107 @@ function fireLayoutEvent(disclosureContent: ReactTestInstance) {
23
23
  });
24
24
  }
25
25
 
26
- it("renders a Disclosure with a header and a content when open is true", () => {
27
- const disclosure = render(
28
- <Disclosure
29
- header={<Text>This is the header</Text>}
30
- content={<Text>This is the content</Text>}
31
- open={true}
32
- isEmpty={false}
33
- onToggle={() => {
34
- return;
35
- }}
36
- />,
37
- );
38
- fireLayoutEvent(disclosure.getByTestId("content"));
39
- expect(disclosure).toMatchSnapshot();
40
- });
26
+ describe("Disclosure", () => {
27
+ const defaultProps = {
28
+ header: <Text>This is the header</Text>,
29
+ content: <Text>This is the content</Text>,
30
+ onToggle: jest.fn(),
31
+ };
41
32
 
42
- it("renders a Disclosure with a header and with a content of size 0 when closed is false", () => {
43
- const disclosure = render(
44
- <Disclosure
45
- header={<Text>This is the header</Text>}
46
- content={<Text>This is the content</Text>}
47
- open={false}
48
- isEmpty={false}
49
- onToggle={() => {
50
- return;
51
- }}
52
- />,
53
- );
54
- fireLayoutEvent(disclosure.getByTestId("content"));
55
- expect(disclosure).toMatchSnapshot();
56
- });
33
+ it("renders a Disclosure with a header and a content when open is true", () => {
34
+ render(
35
+ <Disclosure
36
+ header={<Text>This is the header</Text>}
37
+ content={<Text>This is the content</Text>}
38
+ open={true}
39
+ isEmpty={false}
40
+ onToggle={() => {
41
+ return;
42
+ }}
43
+ />,
44
+ );
45
+
46
+ expect(screen.getByText("This is the header")).toBeTruthy();
47
+
48
+ const content = screen.getByTestId("content");
49
+ fireLayoutEvent(content);
50
+
51
+ expect(screen.getByText("This is the content")).toBeTruthy();
52
+ expect(screen.getByTestId("arrowUp")).toBeTruthy();
53
+ });
54
+
55
+ it("renders a Disclosure with a header and with a content of size 0 when open is false", () => {
56
+ render(
57
+ <Disclosure
58
+ header={<Text>This is the header</Text>}
59
+ content={<Text>This is the content</Text>}
60
+ open={false}
61
+ isEmpty={false}
62
+ onToggle={() => {
63
+ return;
64
+ }}
65
+ />,
66
+ );
67
+
68
+ expect(screen.getByText("This is the header")).toBeTruthy();
69
+
70
+ const content = screen.getByTestId("content");
71
+ fireLayoutEvent(content);
72
+
73
+ expect(screen.getByText("This is the content")).toBeTruthy();
74
+ expect(screen.getByTestId("arrowUp")).toBeTruthy();
75
+ });
57
76
 
58
- it("should not render the caret when the Disclosure is empty", () => {
59
- const disclosure = render(
60
- <Disclosure
61
- header={<Text>This is the header</Text>}
62
- content={<Text>This is the content</Text>}
63
- open={false}
64
- isEmpty={true}
65
- onToggle={() => {
66
- return;
67
- }}
68
- />,
69
- );
70
- expect(disclosure).toMatchSnapshot();
77
+ it("should not render the caret when the Disclosure is empty", () => {
78
+ render(
79
+ <Disclosure
80
+ header={<Text>This is the header</Text>}
81
+ content={<Text>This is the content</Text>}
82
+ open={false}
83
+ isEmpty={true}
84
+ onToggle={() => {
85
+ return;
86
+ }}
87
+ />,
88
+ );
89
+
90
+ expect(screen.getByText("This is the header")).toBeTruthy();
91
+ expect(screen.queryByTestId("arrowUp")).toBeNull();
92
+ });
93
+
94
+ it("calls onToggle when header is pressed", () => {
95
+ const onToggleMock = jest.fn();
96
+ const { getByText } = render(
97
+ <Disclosure
98
+ {...defaultProps}
99
+ onToggle={onToggleMock}
100
+ open={false}
101
+ isEmpty={false}
102
+ />,
103
+ );
104
+
105
+ const headerText = getByText("This is the header");
106
+
107
+ fireEvent.press(headerText);
108
+
109
+ expect(onToggleMock).toHaveBeenCalledTimes(1);
110
+ });
111
+
112
+ it("does not call onToggle when header is pressed and isEmpty is true", () => {
113
+ const onToggleMock = jest.fn();
114
+ const { getByText } = render(
115
+ <Disclosure
116
+ {...defaultProps}
117
+ onToggle={onToggleMock}
118
+ open={false}
119
+ isEmpty={true}
120
+ />,
121
+ );
122
+
123
+ const headerText = getByText("This is the header");
124
+
125
+ fireEvent.press(headerText);
126
+
127
+ expect(onToggleMock).not.toHaveBeenCalled();
128
+ });
71
129
  });
package/src/Form/Form.tsx CHANGED
@@ -138,7 +138,7 @@ function InternalForm<T extends FieldValues, S>({
138
138
 
139
139
  const styles = useStyles();
140
140
 
141
- // Comment to trigger build once more
141
+ // Comment to trigger build once more and again and again
142
142
  return (
143
143
  <FormProvider {...formMethods}>
144
144
  <>
@@ -4,8 +4,8 @@ import {
4
4
  fireEvent,
5
5
  render as renderComponent,
6
6
  } from "@testing-library/react-native";
7
+ import { Animated } from "react-native";
7
8
  import { GLIMMER_SHINE_TEST_ID, GLIMMER_TEST_ID, Glimmer } from "./Glimmer";
8
- import { tokens } from "../utils/design";
9
9
 
10
10
  let screen: ReturnType<typeof renderComponent<typeof Glimmer>>;
11
11
 
@@ -48,6 +48,10 @@ describe("Glimmer", () => {
48
48
 
49
49
  it("renders sets the correct width", () => {
50
50
  jest.useFakeTimers();
51
+
52
+ // Spy on Animated.timing to verify the animation configuration
53
+ const timingSpy = jest.spyOn(Animated, "timing");
54
+
51
55
  render(<Glimmer />);
52
56
 
53
57
  act(() => {
@@ -62,12 +66,19 @@ describe("Glimmer", () => {
62
66
  expect.objectContaining({ transform: [{ translateX: -48 }] }),
63
67
  );
64
68
 
65
- jest.advanceTimersByTime(tokens["timing-loading--extended"]);
69
+ expect(timingSpy).toHaveBeenCalled();
66
70
 
67
- expect(element.props.style).toEqual(
68
- expect.objectContaining({ transform: [{ translateX: 348 }] }),
69
- );
71
+ // Get the last call to timing
72
+ const lastCall = timingSpy.mock.calls[timingSpy.mock.calls.length - 1];
73
+
74
+ // The first argument should be the animated value
75
+ // The second argument should be the config
76
+ const config = lastCall[1];
77
+
78
+ // Verify animation targets the right end position (300 + 48 = 348)
79
+ expect(config.toValue).toBe(348);
70
80
 
81
+ timingSpy.mockRestore();
71
82
  jest.useRealTimers();
72
83
  });
73
84
  });