Updating tests for Loader to use react-testing-library

This commit is contained in:
Jeff Avallone 2019-03-24 13:07:39 -04:00
parent ace907779f
commit 092fd39da6
2 changed files with 66 additions and 73 deletions

View File

@ -1,82 +1,75 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Loader rendering 1`] = ` exports[`Loader rendering 1`] = `
<Loader <DocumentFragment>
t={[Function]}
>
<div <div
className="loader" class="loader"
> >
<Loader <svg
color="currentColor" fill="none"
size="24" height="24"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
> >
<svg <line
fill="none" x1="12"
height="24" x2="12"
stroke="currentColor" y1="2"
strokeLinecap="round" y2="6"
strokeLinejoin="round" />
strokeWidth="2" <line
viewBox="0 0 24 24" x1="12"
width="24" x2="12"
xmlns="http://www.w3.org/2000/svg" y1="18"
> y2="22"
<line />
x1="12" <line
x2="12" x1="4.93"
y1="2" x2="7.76"
y2="6" y1="4.93"
/> y2="7.76"
<line />
x1="12" <line
x2="12" x1="16.24"
y1="18" x2="19.07"
y2="22" y1="16.24"
/> y2="19.07"
<line />
x1="4.93" <line
x2="7.76" x1="2"
y1="4.93" x2="6"
y2="7.76" y1="12"
/> y2="12"
<line />
x1="16.24" <line
x2="19.07" x1="18"
y1="16.24" x2="22"
y2="19.07" y1="12"
/> y2="12"
<line />
x1="2" <line
x2="6" x1="4.93"
y1="12" x2="7.76"
y2="12" y1="19.07"
/> y2="16.24"
<line />
x1="18" <line
x2="22" x1="16.24"
y1="12" x2="19.07"
y2="12" y1="7.76"
/> y2="4.93"
<line />
x1="4.93" </svg>
x2="7.76"
y1="19.07"
y2="16.24"
/>
<line
x1="16.24"
x2="19.07"
y1="7.76"
y2="4.93"
/>
</svg>
</Loader>
<div <div
className="message" class="message"
> >
TRANSLATE(Loading...) TRANSLATE(Loading...)
</div> </div>
</div> </div>
</Loader> </DocumentFragment>
`; `;

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { mount } from 'enzyme'; import { render } from 'react-testing-library';
import { mockT } from 'i18n'; import { mockT } from 'i18n';
import { Loader } from 'components/Loader'; import { Loader } from 'components/Loader';
@ -8,9 +8,9 @@ describe('Loader', () => {
test('rendering', () => { test('rendering', () => {
// Using full rendering here since styles for this depend on the structure // Using full rendering here since styles for this depend on the structure
// of the SVG. // of the SVG.
const component = mount( const { asFragment } = render(
<Loader t={ mockT } /> <Loader t={ mockT } />
); );
expect(component).toMatchSnapshot(); expect(asFragment()).toMatchSnapshot();
}); });
}); });