Commit d2cb2a34 authored by Mickaël Bourgier's avatar Mickaël Bourgier
Browse files

Remove Anchor snapshot testing

parent 0d8011c6
Pipeline #1074 passed with stage
in 1 minute and 46 seconds
import React from 'react';
import renderer from 'react-test-renderer';
import { SheetsRegistry } from 'react-jss';
import { cleanup, render } from '@testing-library/react';
import wrapToTest from '../utils/wrapToTest';
import Anchor from './Anchor';
describe('<Anchor />', () => {
let componentToTest;
let sheets;
beforeEach(() => {
componentToTest = null;
sheets = null;
});
afterEach(() => {
if (componentToTest !== null) {
const options = sheets === null ? {} : { sheets };
const component = renderer.create(wrapToTest(options)(componentToTest));
afterEach(cleanup);
expect(component.toJSON()).toMatchSnapshot();
if (sheets !== null) {
expect(sheets.toString()).toMatchSnapshot();
}
}
});
test('Render with minimum required props', () => {
componentToTest = <Anchor id='id' />;
sheets = new SheetsRegistry();
});
test('Could render a custom component', () => {
componentToTest = <Anchor id='id' component='p' />;
});
test('Render with children', () => {
componentToTest = (
<Anchor id='id'>
Hello <strong>you</strong>
</Anchor>
it('can be rendered', () => {
const { getByText } = render(
wrapToTest()(<Anchor id='anchor-id'>anchor</Anchor>)
);
});
test('Should include className and other props', () => {
componentToTest = (
<Anchor id='id' className='my-custom-class' myCustomProp='value' />
);
});
const anchor = getByText(/anchor/);
test('Render with custom offset', () => {
componentToTest = <Anchor id='id' offset={42} />;
sheets = new SheetsRegistry();
expect(anchor).toHaveTextContent('anchor');
expect(anchor).toContainElement(document.getElementById('anchor-id'));
});
});
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Anchor /> Could render a custom component 1`] = `
<p
className="Anchor-root-0-1-1"
>
<div
className="Anchor-anchor-0-1-2 Anchor-anchor-0-1-3"
id="id"
/>
</p>
`;
exports[`<Anchor /> Render with children 1`] = `
<div
className="Anchor-root-0-1-1"
>
<div
className="Anchor-anchor-0-1-2 Anchor-anchor-0-1-3"
id="id"
/>
Hello
<strong>
you
</strong>
</div>
`;
exports[`<Anchor /> Render with custom offset 1`] = `
<div
className="Anchor-root-0-1-1"
>
<div
className="Anchor-anchor-0-1-2 Anchor-anchor-0-1-3"
id="id"
/>
</div>
`;
exports[`<Anchor /> Render with custom offset 2`] = `
".Anchor-root-0-1-1 {
position: relative;
}
.Anchor-anchor-0-1-3 {
position: absolute;
top: -42px;
}
@media (min-width:0px) and (orientation: landscape) {
.Anchor-anchor-0-1-3 {
top: -42px;
}
}
@media (min-width:576px) {
.Anchor-anchor-0-1-3 {
top: -42px;
}
}"
`;
exports[`<Anchor /> Render with minimum required props 1`] = `
<div
className="Anchor-root-0-1-1"
>
<div
className="Anchor-anchor-0-1-2 Anchor-anchor-0-1-3"
id="id"
/>
</div>
`;
exports[`<Anchor /> Render with minimum required props 2`] = `
".Anchor-root-0-1-1 {
position: relative;
}
.Anchor-anchor-0-1-3 {
position: absolute;
top: -56px;
}
@media (min-width:0px) and (orientation: landscape) {
.Anchor-anchor-0-1-3 {
top: -48px;
}
}
@media (min-width:576px) {
.Anchor-anchor-0-1-3 {
top: -64px;
}
}"
`;
exports[`<Anchor /> Should include className and other props 1`] = `
<div
className="Anchor-root-0-1-1 my-custom-class"
myCustomProp="value"
>
<div
className="Anchor-anchor-0-1-2 Anchor-anchor-0-1-3"
id="id"
/>
</div>
`;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment