UNPKG

1.2 kBTypeScriptView Raw
1import { mount } from 'enzyme';
2import React from 'react';
3import { StyleSheet } from 'react-native';
4
5import { BlurView } from '..';
6
7const getStyleProp = (component, prop) => StyleSheet.flatten(component.prop('style'))[prop];
8
9// @ts-ignore
10const originalCSS = global.CSS;
11
12beforeEach(() => {
13 // @ts-ignore
14 global.CSS = {
15 supports() {
16 return true;
17 },
18 };
19});
20
21afterAll(() => {
22 // @ts-ignore
23 global.CSS = originalCSS;
24});
25
26it(`prefers filters to background color`, () => {
27 const withNativeBlur = mount(<BlurView tint="light" />);
28 expect(getStyleProp(withNativeBlur.find('div'), 'WebkitBackdropFilter')).toBeDefined();
29 expect(getStyleProp(withNativeBlur.find('div'), 'backdropFilter')).toBeDefined();
30});
31
32it(`uses a transparent background color when filters aren't supported`, () => {
33 // @ts-ignore
34 global.CSS = undefined;
35
36 const withoutNativeBlur = mount(<BlurView tint="light" />);
37 expect(getStyleProp(withoutNativeBlur.find('div'), 'WebkitBackdropFilter')).not.toBeDefined();
38 expect(getStyleProp(withoutNativeBlur.find('div'), 'backdropFilter')).not.toBeDefined();
39 expect(getStyleProp(withoutNativeBlur.find('div'), 'backgroundColor')).toBeDefined();
40});