import * as React from 'react';
import { renderHook } from '@testing-library/react-hooks';
import { Button } from '../../Button';
import { Rover } from '../index';
import render from '../../utils/_tests/render';
describe('props', () => {
it('should render correctly', () => {
function Component() {
const hidden = Rover.useState();
return (
Hello world
Hello world
Hello world
);
}
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
});
describe('composition', () => {
describe('use', () => {
it('should render correctly', () => {
function Component() {
const hidden = Rover.useState();
return (
Hello world
Hello world
Hello world
);
}
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
});
describe('hook', () => {
it('should return with Rover props', () => {
const { result } = renderHook(() => {
const hidden = Rover.useState();
return Rover.useProps({ ...hidden, stopId: 'test' });
});
expect(result.current).toMatchSnapshot();
});
});
describe('render props', () => {
it('should render correctly', () => {
function Component() {
const hidden = Rover.useState();
return (
{(RoverProps) => Hello world
}
);
}
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
});
});
describe('overrides', () => {
it('Rover.base should render correctly', () => {
function Component() {
const hidden = Rover.useState();
return (
Hello world
);
}
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
});
describe('theming', () => {
it('Rover.base should render correctly', () => {
function Component() {
const hidden = Rover.useState();
return (
Hello world
);
}
const { container } = render(, {
theme: { Rover: { styles: { base: { backgroundColor: 'red' } } } },
});
expect(container.firstChild).toMatchSnapshot();
});
});
describe('defaultProps', () => {
it('should render correctly for className', () => {
function Component() {
const hidden = Rover.useState();
return (
Hello world
);
}
const { container } = render(, {
theme: { Rover: { defaultProps: { className: 'test' } } },
});
expect(container.firstChild).toMatchSnapshot();
});
});
describe('useContext', () => {
it('should render correctly', () => {
let rover;
function ParentComponent({ children }: any) {
return (
{children}
);
}
function ChildComponent() {
const context = Rover.useContext();
rover = context.rover;
return hello world
;
}
render(
);
expect(rover).toMatchSnapshot();
});
});