@pagopa/io-app-design-system 5.11.11 → 5.11.13-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.
- package/lib/commonjs/components/templates/ForceScrollDownView.js +43 -73
- package/lib/commonjs/components/templates/ForceScrollDownView.js.map +1 -1
- package/lib/commonjs/components/toast/ToastProvider.js +5 -1
- package/lib/commonjs/components/toast/ToastProvider.js.map +1 -1
- package/lib/module/components/templates/ForceScrollDownView.js +45 -75
- package/lib/module/components/templates/ForceScrollDownView.js.map +1 -1
- package/lib/module/components/toast/ToastProvider.js +6 -2
- package/lib/module/components/toast/ToastProvider.js.map +1 -1
- package/lib/typescript/components/templates/ForceScrollDownView.d.ts +7 -1
- package/lib/typescript/components/templates/ForceScrollDownView.d.ts.map +1 -1
- package/lib/typescript/components/toast/ToastProvider.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/templates/ForceScrollDownView.tsx +72 -104
- package/src/components/toast/ToastProvider.tsx +13 -1
- package/lib/commonjs/components/templates/__test__/ForceScrollDownView.test.js +0 -115
- package/lib/commonjs/components/templates/__test__/ForceScrollDownView.test.js.map +0 -1
- package/lib/commonjs/components/templates/__test__/__snapshots__/ForceScrollDownView.test.tsx.snap +0 -18
- package/lib/module/components/templates/__test__/ForceScrollDownView.test.js +0 -113
- package/lib/module/components/templates/__test__/ForceScrollDownView.test.js.map +0 -1
- package/lib/module/components/templates/__test__/__snapshots__/ForceScrollDownView.test.tsx.snap +0 -18
- package/lib/typescript/components/templates/__test__/ForceScrollDownView.test.d.ts +0 -2
- package/lib/typescript/components/templates/__test__/ForceScrollDownView.test.d.ts.map +0 -1
- package/src/components/templates/__test__/ForceScrollDownView.test.tsx +0 -106
- package/src/components/templates/__test__/__snapshots__/ForceScrollDownView.test.tsx.snap +0 -18
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/* eslint-disable functional/immutable-data */
|
|
2
|
-
import { fireEvent, render } from "@testing-library/react-native";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { Text } from "react-native";
|
|
5
|
-
import { ForceScrollDownView } from "../ForceScrollDownView";
|
|
6
|
-
|
|
7
|
-
const tContent = "Some content";
|
|
8
|
-
|
|
9
|
-
describe("ForceScrollDownView", () => {
|
|
10
|
-
jest.useFakeTimers();
|
|
11
|
-
|
|
12
|
-
it("should match snapshot", () => {
|
|
13
|
-
const tChildren = <Text>{tContent}</Text>;
|
|
14
|
-
|
|
15
|
-
const component = render(
|
|
16
|
-
<ForceScrollDownView threshold={100}>{tChildren}</ForceScrollDownView>
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
expect(component).toMatchSnapshot();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("renders the content correctly", () => {
|
|
23
|
-
const tChildren = <Text>{tContent}</Text>;
|
|
24
|
-
|
|
25
|
-
const { getByText } = render(
|
|
26
|
-
<ForceScrollDownView threshold={100}>{tChildren}</ForceScrollDownView>
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
expect(getByText(tContent)).toBeDefined();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("displays the scroll down button when necessary", async () => {
|
|
33
|
-
const tChildren = <Text>{tContent}</Text>;
|
|
34
|
-
|
|
35
|
-
const tScreenHeight = 1000;
|
|
36
|
-
|
|
37
|
-
const { getByTestId, queryByTestId } = render(
|
|
38
|
-
<ForceScrollDownView threshold={100}>{tChildren}</ForceScrollDownView>
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const scrollView = getByTestId("ScrollView");
|
|
42
|
-
|
|
43
|
-
// Update scroll view height
|
|
44
|
-
fireEvent(scrollView, "layout", {
|
|
45
|
-
nativeEvent: {
|
|
46
|
-
layout: {
|
|
47
|
-
height: tScreenHeight
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Update scroll view content height
|
|
53
|
-
fireEvent(scrollView, "contentSizeChange", null, tScreenHeight - 500);
|
|
54
|
-
|
|
55
|
-
// Button should not be visible because content does not need scrolling
|
|
56
|
-
const buttonBefore = queryByTestId("ScrollDownButton");
|
|
57
|
-
expect(buttonBefore).toBeNull();
|
|
58
|
-
|
|
59
|
-
// Increase content height to force button to be shown
|
|
60
|
-
fireEvent(scrollView, "contentSizeChange", null, tScreenHeight + 500);
|
|
61
|
-
|
|
62
|
-
jest.advanceTimersByTime(500);
|
|
63
|
-
|
|
64
|
-
// Button should be visible now beacuse content needs scrolling
|
|
65
|
-
const buttonAfter = queryByTestId("ScrollDownButton");
|
|
66
|
-
expect(buttonAfter).not.toBeNull();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("scrolls to the bottom when the button is pressed", () => {
|
|
70
|
-
const tChildren = <Text>{tContent}</Text>;
|
|
71
|
-
|
|
72
|
-
const tScreenHeight = 1000;
|
|
73
|
-
|
|
74
|
-
const { getByTestId, queryByTestId } = render(
|
|
75
|
-
<ForceScrollDownView threshold={100}>{tChildren}</ForceScrollDownView>
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const scrollView = getByTestId("ScrollView");
|
|
79
|
-
|
|
80
|
-
// Update scroll view height
|
|
81
|
-
fireEvent(scrollView, "layout", {
|
|
82
|
-
nativeEvent: {
|
|
83
|
-
layout: {
|
|
84
|
-
height: tScreenHeight
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// Update scroll view content height
|
|
90
|
-
fireEvent(scrollView, "contentSizeChange", null, tScreenHeight + 500);
|
|
91
|
-
|
|
92
|
-
// Button should be visible
|
|
93
|
-
const buttonBefore = getByTestId("ScrollDownButton");
|
|
94
|
-
expect(buttonBefore).not.toBeNull();
|
|
95
|
-
|
|
96
|
-
// Fire button press event
|
|
97
|
-
fireEvent.press(buttonBefore);
|
|
98
|
-
|
|
99
|
-
// Wait for the scroll animation
|
|
100
|
-
jest.advanceTimersByTime(500);
|
|
101
|
-
|
|
102
|
-
// Button should not be visible after scrolling
|
|
103
|
-
const buttonAfter = queryByTestId("ScrollDownButton");
|
|
104
|
-
expect(buttonAfter).toBeNull();
|
|
105
|
-
});
|
|
106
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`ForceScrollDownView should match snapshot 1`] = `
|
|
4
|
-
<RCTScrollView
|
|
5
|
-
onContentSizeChange={[Function]}
|
|
6
|
-
onLayout={[Function]}
|
|
7
|
-
onScroll={[Function]}
|
|
8
|
-
scrollEnabled={true}
|
|
9
|
-
scrollEventThrottle={8}
|
|
10
|
-
testID="ScrollView"
|
|
11
|
-
>
|
|
12
|
-
<View>
|
|
13
|
-
<Text>
|
|
14
|
-
Some content
|
|
15
|
-
</Text>
|
|
16
|
-
</View>
|
|
17
|
-
</RCTScrollView>
|
|
18
|
-
`;
|