import * as React from 'react';
import { View } from 'react-native';
import renderer from 'react-test-renderer';
import {
IMDBorderShadowProps,
IMDBoxShadowProps,
MDBorderShadow,
MDBoxShadow,
} from '../index';
const BoxShadowOpt: IMDBoxShadowProps = {
width: 100,
height: 100,
color: '#333',
border: 2,
radius: 3,
opacity: 0.2,
x: 0,
y: 3,
style: { marginVertical: 5 },
};
const BorderShadowOpt: IMDBorderShadowProps = {
width: 100,
color: '#333',
border: 2,
opacity: 0.2,
side: 'bottom',
inset: false,
style: { marginVertical: 5 },
};
it('renders correctly with defaults', () => {
const component = renderer.create().toJSON();
expect(component).toMatchSnapshot();
});
it('render correctly with box shadow', () => {
const component = renderer
.create(
)
.toJSON();
expect(component).toMatchSnapshot();
});
it('render correctly with border shadow', () => {
const component = renderer
.create(
)
.toJSON();
expect(component).toMatchSnapshot();
});
it('render correctly with invalid color string', () => {
const invalidSetting = Object.assign({}, BoxShadowOpt, {
color: '123',
});
try {
renderer
.create(
)
.toJSON();
} catch (error) {
expect(error).toEqual(Error('Invalid Color!'));
}
});
it('render correctly with top border shadow', () => {
const borderShadowOpt = Object.assign({}, BorderShadowOpt, {
side: 'top',
});
const component = renderer
.create(
)
.toJSON();
expect(component).toMatchSnapshot();
});
it('render correctly with other side border shadow', () => {
const borderShadowOpt = Object.assign({}, BorderShadowOpt, {
side: 'left',
});
try {
renderer.create(
);
} catch (error) {
expect(error).toEqual(
Error('Wrong Type of Side! We just support \'top\' and \'bottom\'')
);
}
});
it('render border shadow correctly with string child', () => {
const component = renderer
.create(children)
.toJSON();
expect(component).toMatchSnapshot();
});
it('render box shadow correctly with string child', () => {
const component = renderer
.create(children)
.toJSON();
expect(component).toMatchSnapshot();
});
it('render border shadow correctly with true inset ', () => {
const borderShadowOpt = Object.assign({}, BorderShadowOpt, {
inset: true,
});
const component = renderer
.create(
)
.toJSON();
expect(component).toMatchSnapshot();
});
it('render border shadow correctly with undefined setting', () => {
const component = renderer
.create(
)
.toJSON();
expect(component).toMatchSnapshot();
});
it('render correctly with hex color string', () => {
const invalidSetting = Object.assign({}, BoxShadowOpt, {
color: '#123456AA',
});
try {
renderer
.create(
)
.toJSON();
} catch (error) {
expect(error).toEqual(Error('Invalid Color!'));
}
});