1import React from 'react';
2import renderer from 'react-test-renderer';
3
4import View from '../../primitives/View';
5import { createSafeStyledView } from '../createSafeStyledView';
6
7const Safe = createSafeStyledView(View);
8
9const originalConsoleError = console.error;
10const originalConsoleWarn = console.warn;
11
12beforeEach(() => {
13  console.error = jest.fn();
14  console.warn = jest.fn();
15});
16afterAll(() => {
17  console.error = originalConsoleError;
18  console.warn = originalConsoleWarn;
19});
20
21it(`strips invalid style properties`, () => {
22  const tree = renderer.create(
23    <Safe
24      style={{
25        transitionDuration: '200ms',
26        position: 'absolute',
27      }}
28    />
29  );
30  //   expect(tree.root.children[0]).toHaveStyle({ position: 'absolute' });
31  expect(tree).toMatchSnapshot();
32});
33
34it(`replaces invalid position with "relative"`, () => {
35  const tree = renderer.create(
36    <Safe
37      style={{
38        position: 'fixed',
39      }}
40    />
41  );
42  expect(tree).toMatchSnapshot();
43  expect(console.warn).toBeCalledWith(`Unsupported position: 'fixed'`);
44});
45
46it(`mocks out visibility: hidden by lowering the opacity`, () => {
47  const tree = renderer.create(
48    <Safe
49      style={{
50        visibility: 'hidden',
51      }}
52    />
53  );
54  expect(tree).toMatchSnapshot();
55});
56