import React from 'react';
import { render } from '@testing-library/react';
import 'jest-styled-components';
import { Grommet } from '../../Grommet';
import { Box, BoxProps } from '..';
import { Text } from '../../Text';
describe('Box', () => {
/* eslint-disable max-len */
test('background', () => {
const { container } = render(
,
);
expect(container.firstChild).toMatchSnapshot();
});
/* eslint-enable max-len */
test('background from theme', () => {
const customTheme = {
global: {
backgrounds: {
'image-2': {
dark: `url(https://images.unsplash.com/photo-1614292253389-bd2c1f89cd0e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=687&q=80)`,
light: `url(https://images.unsplash.com/photo-1603484477859-abe6a73f9366?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=687&q=80)`,
},
'gradient-1': `linear-gradient(
hsl(240deg 90% 55%) 0%,
hsl(341deg 90% 55%) 50%,
hsl(60deg 90% 55%) 100%)`,
},
},
};
const { asFragment } = render(
background gradient from theme
background image from theme
,
);
expect(asFragment()).toMatchSnapshot();
});
test('background clip', () => {
const customTheme = {
global: {
backgrounds: {
'gradient-1': `linear-gradient(
hsl(240deg 90% 55%) 0%,
hsl(341deg 90% 55%) 50%,
hsl(60deg 90% 55%) 100%)`,
},
},
};
const { asFragment } = render(
background with clipped text
,
);
expect(asFragment()).toMatchSnapshot();
});
test('background rotate', () => {
const customTheme = {
global: {
backgrounds: {
'gradient-1': `linear-gradient(
hsl(240deg 90% 55%) 0%,
hsl(341deg 90% 55%) 50%,
hsl(60deg 90% 55%) 100%)`,
},
},
};
const { asFragment } = render(
background gradient rotated
,
);
expect(asFragment()).toMatchSnapshot();
});
test('round', () => {
const { container } = render(
,
);
expect(container.firstChild).toMatchSnapshot();
});
test('border', () => {
const { container } = render(
one
two
one
two
,
);
expect(container.firstChild).toMatchSnapshot();
});
test('elevation', () => {
const { container } = render(
,
);
expect(container.firstChild).toMatchSnapshot();
});
test('animation', () => {
const animationProps: BoxProps['animation'][] = [
'fadeIn',
'fadeOut',
'jiggle',
'pulse',
'rotateLeft',
'rotateRight',
'slideUp',
'slideDown',
'slideLeft',
'slideRight',
'zoomIn',
'zoomOut',
];
const { container } = render(
{animationProps.map((type) => (
))}
,
);
expect(container.firstChild).toMatchSnapshot();
});
test('hoverIndicator', () => {
const { container } = render(
{}} hoverIndicator />
{}} hoverIndicator="background-contrast" />\
{}}
hoverIndicator={{ color: 'background-contrast' }}
/>
{}}
hoverIndicator={{
background: { color: 'background-contrast' },
elevation: 'medium',
}}
/>
,
);
expect(container.firstChild).toMatchSnapshot();
});
});