|
@@ -1,6 +1,6 @@
|
1
|
1
|
import * as React from 'react';
|
2
|
2
|
import * as ReactTestRenderer from 'react-test-renderer';
|
3
|
|
-import { View } from 'react-native';
|
|
3
|
+import { View, UIManager } from 'react-native';
|
4
|
4
|
import { SafeAreaProvider, SafeAreaView, useSafeArea } from '../index';
|
5
|
5
|
import NativeSafeAreaView from '../NativeSafeAreaView';
|
6
|
6
|
|
|
@@ -136,3 +136,34 @@ describe('SafeAreaView', () => {
|
136
|
136
|
expect(component).toMatchSnapshot();
|
137
|
137
|
});
|
138
|
138
|
});
|
|
139
|
+
|
|
140
|
+describe('initialWindowSafeAreaInsets', () => {
|
|
141
|
+ it('is null when no view config is available', () => {
|
|
142
|
+ jest.resetModules();
|
|
143
|
+ expect(require('../index').initialWindowSafeAreaInsets).toBe(null);
|
|
144
|
+ });
|
|
145
|
+
|
|
146
|
+ it('it uses the constant provided by the view config', () => {
|
|
147
|
+ jest.resetModules();
|
|
148
|
+ const testInsets = {
|
|
149
|
+ top: 20,
|
|
150
|
+ left: 0,
|
|
151
|
+ right: 0,
|
|
152
|
+ bottom: 0,
|
|
153
|
+ };
|
|
154
|
+ UIManager.getViewManagerConfig = jest.fn(name => {
|
|
155
|
+ if (name === 'RNCSafeAreaView') {
|
|
156
|
+ return {
|
|
157
|
+ Commands: {},
|
|
158
|
+ Constants: {
|
|
159
|
+ initialWindowSafeAreaInsets: testInsets,
|
|
160
|
+ },
|
|
161
|
+ };
|
|
162
|
+ }
|
|
163
|
+ return { Commands: {} };
|
|
164
|
+ });
|
|
165
|
+
|
|
166
|
+ expect(require('../index').initialWindowSafeAreaInsets).toBe(testInsets);
|
|
167
|
+ expect(UIManager.getViewManagerConfig).toBeCalledWith('RNCSafeAreaView');
|
|
168
|
+ });
|
|
169
|
+});
|