@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/dist/package.json +3 -3
- package/dist/src/Form/Form.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/Disclosure/Disclosure.test.tsx +102 -44
- package/src/Form/Form.tsx +1 -1
- package/src/Glimmer/Glimmer.test.tsx +16 -5
- package/src/Disclosure/__snapshots__/Disclosure.test.tsx.snap +0 -482
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.80.1-upgrade-to-
|
|
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.
|
|
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": "
|
|
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
|
-
|
|
27
|
-
const
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
@@ -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
|
-
|
|
69
|
+
expect(timingSpy).toHaveBeenCalled();
|
|
66
70
|
|
|
67
|
-
|
|
68
|
-
|
|
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
|
});
|