|
@@ -1,7 +1,7 @@
|
1
|
1
|
import * as React from 'react';
|
2
|
2
|
import * as ReactTestRenderer from 'react-test-renderer';
|
3
|
3
|
import { View } from 'react-native';
|
4
|
|
-import { SafeAreaProvider, useSafeArea } from '../index';
|
|
4
|
+import { SafeAreaProvider, SafeAreaView, useSafeArea } from '../index';
|
5
|
5
|
import NativeSafeAreaView from '../NativeSafeAreaView';
|
6
|
6
|
|
7
|
7
|
const PrintInsetsTestView = () => {
|
|
@@ -51,27 +51,23 @@ describe('SafeAreaProvider', () => {
|
51
|
51
|
expect(component).toMatchSnapshot();
|
52
|
52
|
});
|
53
|
53
|
|
54
|
|
- it('uses parent insets when available', () => {
|
|
54
|
+ it('supports setting initial insets', () => {
|
55
|
55
|
const component = ReactTestRenderer.create(
|
56
|
56
|
<SafeAreaProvider
|
57
|
57
|
initialSafeAreaInsets={{ top: 1, left: 2, right: 3, bottom: 4 }}
|
58
|
58
|
>
|
59
|
|
- <SafeAreaProvider>
|
60
|
|
- <PrintInsetsTestView />
|
61
|
|
- </SafeAreaProvider>
|
|
59
|
+ <PrintInsetsTestView />
|
62
|
60
|
</SafeAreaProvider>,
|
63
|
61
|
);
|
64
|
62
|
expect(component).toMatchSnapshot();
|
65
|
63
|
});
|
66
|
64
|
|
67
|
|
- it('uses inner insets', () => {
|
|
65
|
+ it('uses parent insets when available', () => {
|
68
|
66
|
const component = ReactTestRenderer.create(
|
69
|
67
|
<SafeAreaProvider
|
70
|
68
|
initialSafeAreaInsets={{ top: 1, left: 2, right: 3, bottom: 4 }}
|
71
|
69
|
>
|
72
|
|
- <SafeAreaProvider
|
73
|
|
- initialSafeAreaInsets={{ top: 2, left: 3, right: 4, bottom: 5 }}
|
74
|
|
- >
|
|
70
|
+ <SafeAreaProvider>
|
75
|
71
|
<PrintInsetsTestView />
|
76
|
72
|
</SafeAreaProvider>
|
77
|
73
|
</SafeAreaProvider>,
|
|
@@ -79,12 +75,16 @@ describe('SafeAreaProvider', () => {
|
79
|
75
|
expect(component).toMatchSnapshot();
|
80
|
76
|
});
|
81
|
77
|
|
82
|
|
- it('supports setting initial insets', () => {
|
|
78
|
+ it('uses inner insets', () => {
|
83
|
79
|
const component = ReactTestRenderer.create(
|
84
|
80
|
<SafeAreaProvider
|
85
|
81
|
initialSafeAreaInsets={{ top: 1, left: 2, right: 3, bottom: 4 }}
|
86
|
82
|
>
|
87
|
|
- <PrintInsetsTestView />
|
|
83
|
+ <SafeAreaProvider
|
|
84
|
+ initialSafeAreaInsets={{ top: 2, left: 3, right: 4, bottom: 5 }}
|
|
85
|
+ >
|
|
86
|
+ <PrintInsetsTestView />
|
|
87
|
+ </SafeAreaProvider>
|
88
|
88
|
</SafeAreaProvider>,
|
89
|
89
|
);
|
90
|
90
|
expect(component).toMatchSnapshot();
|
|
@@ -108,3 +108,31 @@ describe('SafeAreaProvider', () => {
|
108
|
108
|
consoleErrorMock.mockRestore();
|
109
|
109
|
});
|
110
|
110
|
});
|
|
111
|
+
|
|
112
|
+describe('SafeAreaView', () => {
|
|
113
|
+ it('renders', () => {
|
|
114
|
+ const component = ReactTestRenderer.create(
|
|
115
|
+ <SafeAreaProvider
|
|
116
|
+ initialSafeAreaInsets={{ top: 1, left: 2, right: 3, bottom: 4 }}
|
|
117
|
+ >
|
|
118
|
+ <SafeAreaView>
|
|
119
|
+ <View />
|
|
120
|
+ </SafeAreaView>
|
|
121
|
+ </SafeAreaProvider>,
|
|
122
|
+ );
|
|
123
|
+ expect(component).toMatchSnapshot();
|
|
124
|
+ });
|
|
125
|
+
|
|
126
|
+ it('can override padding styles', () => {
|
|
127
|
+ const component = ReactTestRenderer.create(
|
|
128
|
+ <SafeAreaProvider
|
|
129
|
+ initialSafeAreaInsets={{ top: 1, left: 2, right: 3, bottom: 4 }}
|
|
130
|
+ >
|
|
131
|
+ <SafeAreaView style={{ paddingTop: 0 }}>
|
|
132
|
+ <View />
|
|
133
|
+ </SafeAreaView>
|
|
134
|
+ </SafeAreaProvider>,
|
|
135
|
+ );
|
|
136
|
+ expect(component).toMatchSnapshot();
|
|
137
|
+ });
|
|
138
|
+});
|