import * as React from 'react';
import { renderHook } from '@testing-library/react-hooks';
import { Columns } from '../index';
import { applyTheme } from '../../utils/applyTheme';
import render from '../../utils/_tests/render';
describe('props', () => {
it('should render correctly', () => {
const { container } = render(
Column
Column
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly with CSS props', () => {
const { container } = render(
Column
Column
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly when minBreakpoint is tablet', () => {
const { container } = render(
Column
Column
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly when minBreakpoint is mobile', () => {
const { container } = render(
Column
Column
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly when isOneLine = true', () => {
const { container } = render(Hello world);
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly when isOneLine = true and minBreakpoint = tablet', () => {
const { container } = render(
Hello world
);
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly when isOneLine = true and minBreakpoint = mobile', () => {
const { container } = render(
Hello world
);
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly when isGapless = true', () => {
const { container } = render(Hello world);
expect(container.firstChild).toMatchSnapshot();
});
describe('spreads', () => {
it('renders correctly when all columns have sizes', () => {
const { container } = render(
Column
Column
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders correctly when there is space still left on the right', () => {
const { container } = render(
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders correctly when one of the columns does not have a size', () => {
const { container } = render(
Column
Column
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders correctly when the first column does not have a size', () => {
const { container } = render(
Column
Column
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
});
describe('basic offsets', () => {
it('renders correctly for a spread offset of "left"', () => {
const { container } = render(
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders correctly for a spread offset of "right"', () => {
const { container } = render(
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders correctly for a spread offset of "both"', () => {
const { container } = render(
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders correctly for a spread offset of values between 1 and 11', () => {
const { container } = render(
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
});
describe('variable sizes', () => {
it('renders correctly when only spread and spreadDesktop is specified', () => {
const { container } = render(
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders correctly when all spreads are specified', () => {
const { container } = render(
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders correctly when only mobile spread is specified', () => {
const { container } = render(
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders correctly when only tablet spread is specified', () => {
const { container } = render(
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
});
describe('variable offsets', () => {
it('renders correctly when only spreadOffset and spreadDesktopOffset is specified', () => {
const { container } = render(
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders correctly when all spreadOffsets are specified', () => {
const { container } = render(
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders correctly when only mobile spread offset is specified', () => {
const { container } = render(
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('renders correctly when only tablet spread offset is specified', () => {
const { container } = render(
Column
);
expect(container.firstChild).toMatchSnapshot();
});
});
['left', 'right', 'center'].forEach((alignX) => {
it(`should render correctly for an alignX of ${alignX}`, () => {
const { container } = render(
// @ts-ignore
Column
Column
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
});
['top', 'bottom', 'center'].forEach((alignY) => {
it(`should render correctly for an alignY of ${alignY}`, () => {
const { container } = render(
// @ts-ignore
Column
Column
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
});
it('renders correctly for applyTheme', () => {
const CustomColumns = applyTheme(Columns, {
styles: {
base: {
backgroundColor: 'red',
},
},
});
const { container } = render(
test
);
expect(container.firstChild).toMatchSnapshot();
});
});
describe('composition', () => {
describe('as', () => {
it('should render correctly', () => {
const { container } = render(Hello world);
expect(container.firstChild).toMatchSnapshot();
});
});
describe('hook', () => {
it('should return with Columns props', () => {
const { result } = renderHook(() => Columns.useProps());
expect(result.current).toMatchSnapshot();
});
});
describe('render props', () => {
it('should render correctly', () => {
const { container } = render({(ColumnsProps) => Hello world
});
expect(container.firstChild).toMatchSnapshot();
});
});
});
describe('overrides', () => {
it('Columns.base should render correctly', () => {
const { container } = render(
Column
Column
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
it('Columns.Column.base should render correctly', () => {
const { container } = render(
Column
Column
Column
Column
);
expect(container.firstChild).toMatchSnapshot();
});
});
describe('theming', () => {
it('Columns.base should render correctly', () => {
const { container } = render(
Column
Column
Column
Column
,
{
theme: { Columns: { styles: { base: { backgroundColor: 'red' } } } },
}
);
expect(container.firstChild).toMatchSnapshot();
});
it('Columns.Column.base should render correctly', () => {
const { container } = render(
Column
Column
Column
Column
,
{
theme: { Columns: { Column: { styles: { base: { backgroundColor: 'red' } } } } },
}
);
expect(container.firstChild).toMatchSnapshot();
});
});
describe('defaultProps', () => {
it('should render correctly for className', () => {
const { container } = render(
Column
Column
Column
Column
,
{
theme: { Columns: { defaultProps: { className: 'test' } } },
}
);
expect(container.firstChild).toMatchSnapshot();
});
});