@jobber/components-native 0.80.1-upgrade-to-2ee92b7.19 → 0.80.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 +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/AtlantisThemeContext/AtlantisThemeContext.d.ts +1 -2
- package/dist/types/src/Glimmer/Glimmer.d.ts +1 -2
- package/dist/types/src/ProgressBar/ProgressBarStepped.d.ts +1 -2
- package/jestSetup.js +0 -1
- package/package.json +3 -3
- package/src/Disclosure/Disclosure.test.tsx +44 -102
- package/src/Disclosure/__snapshots__/Disclosure.test.tsx.snap +482 -0
- package/src/Form/Form.test.tsx +1 -1
- package/src/Glimmer/Glimmer.test.tsx +5 -16
- package/src/Switch/components/BaseSwitch/BaseSwitch.test.tsx +50 -75
- package/src/Switch/components/BaseSwitch/__snapshots__/BaseSwitch.test.tsx.snap +217 -0
|
@@ -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";
|
|
8
7
|
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,10 +48,6 @@ 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
|
-
|
|
55
51
|
render(<Glimmer />);
|
|
56
52
|
|
|
57
53
|
act(() => {
|
|
@@ -66,19 +62,12 @@ describe("Glimmer", () => {
|
|
|
66
62
|
expect.objectContaining({ transform: [{ translateX: -48 }] }),
|
|
67
63
|
);
|
|
68
64
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// Get the last call to timing
|
|
72
|
-
const lastCall = timingSpy.mock.calls[timingSpy.mock.calls.length - 1];
|
|
65
|
+
jest.advanceTimersByTime(tokens["timing-loading--extended"]);
|
|
73
66
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// Verify animation targets the right end position (300 + 48 = 348)
|
|
79
|
-
expect(config.toValue).toBe(348);
|
|
67
|
+
expect(element.props.style).toEqual(
|
|
68
|
+
expect.objectContaining({ transform: [{ translateX: 348 }] }),
|
|
69
|
+
);
|
|
80
70
|
|
|
81
|
-
timingSpy.mockRestore();
|
|
82
71
|
jest.useRealTimers();
|
|
83
72
|
});
|
|
84
73
|
});
|
|
@@ -2,86 +2,61 @@ import React from "react";
|
|
|
2
2
|
import { fireEvent, render } from "@testing-library/react-native";
|
|
3
3
|
import { BaseSwitch } from "./BaseSwitch";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const switchElement = getByRole("switch");
|
|
10
|
-
expect(switchElement).toBeDefined();
|
|
11
|
-
expect(switchElement.props.accessibilityState.checked).toBe(true);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("renders with defaultValue true", () => {
|
|
15
|
-
const { getByRole } = render(<BaseSwitch defaultValue={true} />);
|
|
16
|
-
const switchElement = getByRole("switch");
|
|
17
|
-
expect(switchElement).toBeDefined();
|
|
18
|
-
expect(switchElement.props.accessibilityState.checked).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("renders with value false", () => {
|
|
22
|
-
const { getByRole } = render(<BaseSwitch value={false} />);
|
|
23
|
-
const switchElement = getByRole("switch");
|
|
24
|
-
expect(switchElement).toBeDefined();
|
|
25
|
-
expect(switchElement.props.accessibilityState.checked).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("renders with defaultValue false", () => {
|
|
29
|
-
const { getByRole } = render(<BaseSwitch defaultValue={false} />);
|
|
30
|
-
const switchElement = getByRole("switch");
|
|
31
|
-
expect(switchElement).toBeDefined();
|
|
32
|
-
expect(switchElement.props.accessibilityState.checked).toBe(false);
|
|
33
|
-
});
|
|
5
|
+
it("renders a Switch with value true", () => {
|
|
6
|
+
const tree = render(<BaseSwitch value={true} />).toJSON();
|
|
7
|
+
expect(tree).toMatchSnapshot();
|
|
8
|
+
});
|
|
34
9
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
expect(switchElement.props.accessibilityState.checked).toBe(true);
|
|
40
|
-
expect(switchElement.props.accessibilityState.disabled).toBe(true);
|
|
41
|
-
});
|
|
10
|
+
it("renders a Switch with defaultValue true", () => {
|
|
11
|
+
const tree = render(<BaseSwitch defaultValue={true} />).toJSON();
|
|
12
|
+
expect(tree).toMatchSnapshot();
|
|
13
|
+
});
|
|
42
14
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const switchElement = getByRole("switch");
|
|
48
|
-
expect(switchElement).toBeDefined();
|
|
49
|
-
expect(switchElement.props.accessibilityState.checked).toBe(false);
|
|
50
|
-
expect(switchElement.props.accessibilityState.disabled).toBe(true);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
15
|
+
it("renders a Switch with value false", () => {
|
|
16
|
+
const tree = render(<BaseSwitch value={false} />).toJSON();
|
|
17
|
+
expect(tree).toMatchSnapshot();
|
|
18
|
+
});
|
|
53
19
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
<BaseSwitch
|
|
59
|
-
value={false}
|
|
60
|
-
onValueChange={valueChangedCallback}
|
|
61
|
-
accessibilityLabel={"test switch"}
|
|
62
|
-
/>,
|
|
63
|
-
);
|
|
20
|
+
it("renders a Switch with defaultValue false", () => {
|
|
21
|
+
const tree = render(<BaseSwitch defaultValue={false} />).toJSON();
|
|
22
|
+
expect(tree).toMatchSnapshot();
|
|
23
|
+
});
|
|
64
24
|
|
|
65
|
-
|
|
66
|
-
|
|
25
|
+
it("renders a disabled Switch with value true", () => {
|
|
26
|
+
const tree = render(<BaseSwitch value={true} disabled={true} />).toJSON();
|
|
27
|
+
expect(tree).toMatchSnapshot();
|
|
28
|
+
});
|
|
67
29
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
30
|
+
it("renders a disabled Switch with value false", () => {
|
|
31
|
+
const tree = render(<BaseSwitch value={false} disabled={true} />).toJSON();
|
|
32
|
+
expect(tree).toMatchSnapshot();
|
|
33
|
+
});
|
|
71
34
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
35
|
+
it("invokes the valueChange callback", () => {
|
|
36
|
+
const valueChangedCallback = jest.fn();
|
|
37
|
+
const tree = render(
|
|
38
|
+
<BaseSwitch
|
|
39
|
+
value={false}
|
|
40
|
+
onValueChange={valueChangedCallback}
|
|
41
|
+
accessibilityLabel={"test switch"}
|
|
42
|
+
/>,
|
|
43
|
+
);
|
|
44
|
+
fireEvent(tree.getByLabelText("test switch"), "valueChange", true);
|
|
45
|
+
expect(valueChangedCallback).toHaveBeenCalledWith(true);
|
|
46
|
+
fireEvent(tree.getByLabelText("test switch"), "valueChange", false);
|
|
47
|
+
expect(valueChangedCallback).toHaveBeenCalledWith(false);
|
|
48
|
+
});
|
|
82
49
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
50
|
+
it("doesn't invoke the valueChange callback if disabled", () => {
|
|
51
|
+
const valueChangedCallback = jest.fn();
|
|
52
|
+
const tree = render(
|
|
53
|
+
<BaseSwitch
|
|
54
|
+
value={false}
|
|
55
|
+
disabled={true}
|
|
56
|
+
onValueChange={valueChangedCallback}
|
|
57
|
+
accessibilityLabel={"test switch"}
|
|
58
|
+
/>,
|
|
59
|
+
);
|
|
60
|
+
fireEvent(tree.getByLabelText("test switch"), "valueChange", true);
|
|
61
|
+
expect(valueChangedCallback).not.toHaveBeenCalled();
|
|
87
62
|
});
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`renders a Switch with defaultValue false 1`] = `
|
|
4
|
+
<RCTSwitch
|
|
5
|
+
accessibilityRole="switch"
|
|
6
|
+
accessibilityState={
|
|
7
|
+
{
|
|
8
|
+
"checked": false,
|
|
9
|
+
"disabled": false,
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
collapsable={false}
|
|
13
|
+
disabled={false}
|
|
14
|
+
handlerTag={4}
|
|
15
|
+
handlerType="NativeViewGestureHandler"
|
|
16
|
+
onChange={[Function]}
|
|
17
|
+
onGestureHandlerEvent={[Function]}
|
|
18
|
+
onGestureHandlerStateChange={[Function]}
|
|
19
|
+
onResponderTerminationRequest={[Function]}
|
|
20
|
+
onStartShouldSetResponder={[Function]}
|
|
21
|
+
onTintColor="hsl(107, 58%, 33%)"
|
|
22
|
+
style={
|
|
23
|
+
[
|
|
24
|
+
{
|
|
25
|
+
"height": 31,
|
|
26
|
+
"width": 51,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"backgroundColor": "hsl(51, 17%, 85%)",
|
|
30
|
+
"borderRadius": 16,
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
tintColor="hsl(51, 17%, 85%)"
|
|
35
|
+
value={false}
|
|
36
|
+
/>
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`renders a Switch with defaultValue true 1`] = `
|
|
40
|
+
<RCTSwitch
|
|
41
|
+
accessibilityRole="switch"
|
|
42
|
+
accessibilityState={
|
|
43
|
+
{
|
|
44
|
+
"checked": true,
|
|
45
|
+
"disabled": false,
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
collapsable={false}
|
|
49
|
+
disabled={false}
|
|
50
|
+
handlerTag={2}
|
|
51
|
+
handlerType="NativeViewGestureHandler"
|
|
52
|
+
onChange={[Function]}
|
|
53
|
+
onGestureHandlerEvent={[Function]}
|
|
54
|
+
onGestureHandlerStateChange={[Function]}
|
|
55
|
+
onResponderTerminationRequest={[Function]}
|
|
56
|
+
onStartShouldSetResponder={[Function]}
|
|
57
|
+
onTintColor="hsl(107, 58%, 33%)"
|
|
58
|
+
style={
|
|
59
|
+
[
|
|
60
|
+
{
|
|
61
|
+
"height": 31,
|
|
62
|
+
"width": 51,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"backgroundColor": "hsl(51, 17%, 85%)",
|
|
66
|
+
"borderRadius": 16,
|
|
67
|
+
},
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
tintColor="hsl(51, 17%, 85%)"
|
|
71
|
+
value={true}
|
|
72
|
+
/>
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
exports[`renders a Switch with value false 1`] = `
|
|
76
|
+
<RCTSwitch
|
|
77
|
+
accessibilityRole="switch"
|
|
78
|
+
accessibilityState={
|
|
79
|
+
{
|
|
80
|
+
"checked": false,
|
|
81
|
+
"disabled": false,
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
collapsable={false}
|
|
85
|
+
disabled={false}
|
|
86
|
+
handlerTag={3}
|
|
87
|
+
handlerType="NativeViewGestureHandler"
|
|
88
|
+
onChange={[Function]}
|
|
89
|
+
onGestureHandlerEvent={[Function]}
|
|
90
|
+
onGestureHandlerStateChange={[Function]}
|
|
91
|
+
onResponderTerminationRequest={[Function]}
|
|
92
|
+
onStartShouldSetResponder={[Function]}
|
|
93
|
+
onTintColor="hsl(107, 58%, 33%)"
|
|
94
|
+
style={
|
|
95
|
+
[
|
|
96
|
+
{
|
|
97
|
+
"height": 31,
|
|
98
|
+
"width": 51,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"backgroundColor": "hsl(51, 17%, 85%)",
|
|
102
|
+
"borderRadius": 16,
|
|
103
|
+
},
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
tintColor="hsl(51, 17%, 85%)"
|
|
107
|
+
value={false}
|
|
108
|
+
/>
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
exports[`renders a Switch with value true 1`] = `
|
|
112
|
+
<RCTSwitch
|
|
113
|
+
accessibilityRole="switch"
|
|
114
|
+
accessibilityState={
|
|
115
|
+
{
|
|
116
|
+
"checked": true,
|
|
117
|
+
"disabled": false,
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
collapsable={false}
|
|
121
|
+
disabled={false}
|
|
122
|
+
handlerTag={1}
|
|
123
|
+
handlerType="NativeViewGestureHandler"
|
|
124
|
+
onChange={[Function]}
|
|
125
|
+
onGestureHandlerEvent={[Function]}
|
|
126
|
+
onGestureHandlerStateChange={[Function]}
|
|
127
|
+
onResponderTerminationRequest={[Function]}
|
|
128
|
+
onStartShouldSetResponder={[Function]}
|
|
129
|
+
onTintColor="hsl(107, 58%, 33%)"
|
|
130
|
+
style={
|
|
131
|
+
[
|
|
132
|
+
{
|
|
133
|
+
"height": 31,
|
|
134
|
+
"width": 51,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"backgroundColor": "hsl(51, 17%, 85%)",
|
|
138
|
+
"borderRadius": 16,
|
|
139
|
+
},
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
tintColor="hsl(51, 17%, 85%)"
|
|
143
|
+
value={true}
|
|
144
|
+
/>
|
|
145
|
+
`;
|
|
146
|
+
|
|
147
|
+
exports[`renders a disabled Switch with value false 1`] = `
|
|
148
|
+
<RCTSwitch
|
|
149
|
+
accessibilityRole="switch"
|
|
150
|
+
accessibilityState={
|
|
151
|
+
{
|
|
152
|
+
"checked": false,
|
|
153
|
+
"disabled": true,
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
collapsable={false}
|
|
157
|
+
disabled={true}
|
|
158
|
+
handlerTag={6}
|
|
159
|
+
handlerType="NativeViewGestureHandler"
|
|
160
|
+
onChange={[Function]}
|
|
161
|
+
onGestureHandlerEvent={[Function]}
|
|
162
|
+
onGestureHandlerStateChange={[Function]}
|
|
163
|
+
onResponderTerminationRequest={[Function]}
|
|
164
|
+
onStartShouldSetResponder={[Function]}
|
|
165
|
+
onTintColor="hsl(107, 58%, 33%)"
|
|
166
|
+
style={
|
|
167
|
+
[
|
|
168
|
+
{
|
|
169
|
+
"height": 31,
|
|
170
|
+
"width": 51,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"backgroundColor": "hsl(51, 17%, 85%)",
|
|
174
|
+
"borderRadius": 16,
|
|
175
|
+
},
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
tintColor="hsl(51, 17%, 85%)"
|
|
179
|
+
value={false}
|
|
180
|
+
/>
|
|
181
|
+
`;
|
|
182
|
+
|
|
183
|
+
exports[`renders a disabled Switch with value true 1`] = `
|
|
184
|
+
<RCTSwitch
|
|
185
|
+
accessibilityRole="switch"
|
|
186
|
+
accessibilityState={
|
|
187
|
+
{
|
|
188
|
+
"checked": true,
|
|
189
|
+
"disabled": true,
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
collapsable={false}
|
|
193
|
+
disabled={true}
|
|
194
|
+
handlerTag={5}
|
|
195
|
+
handlerType="NativeViewGestureHandler"
|
|
196
|
+
onChange={[Function]}
|
|
197
|
+
onGestureHandlerEvent={[Function]}
|
|
198
|
+
onGestureHandlerStateChange={[Function]}
|
|
199
|
+
onResponderTerminationRequest={[Function]}
|
|
200
|
+
onStartShouldSetResponder={[Function]}
|
|
201
|
+
onTintColor="hsl(107, 58%, 33%)"
|
|
202
|
+
style={
|
|
203
|
+
[
|
|
204
|
+
{
|
|
205
|
+
"height": 31,
|
|
206
|
+
"width": 51,
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"backgroundColor": "hsl(51, 17%, 85%)",
|
|
210
|
+
"borderRadius": 16,
|
|
211
|
+
},
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
tintColor="hsl(51, 17%, 85%)"
|
|
215
|
+
value={true}
|
|
216
|
+
/>
|
|
217
|
+
`;
|