Updating Metadata to use react-testing-library
This commit is contained in:
		
							parent
							
								
									a1281543e2
								
							
						
					
					
						commit
						0d512a1a4d
					
				@ -1,30 +1,31 @@
 | 
			
		||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
 | 
			
		||||
 | 
			
		||||
exports[`Metadata rendering 1`] = `
 | 
			
		||||
<HelmetWrapper
 | 
			
		||||
  defer={true}
 | 
			
		||||
  encodeSpecialCharacters={true}
 | 
			
		||||
  htmlAttributes={
 | 
			
		||||
    Object {
 | 
			
		||||
      "lang": "test-lang",
 | 
			
		||||
    }
 | 
			
		||||
<DocumentFragment>
 | 
			
		||||
  <span
 | 
			
		||||
    data-component="HelmetWrapper"
 | 
			
		||||
    data-props="{
 | 
			
		||||
  \\"htmlAttributes\\": {
 | 
			
		||||
    \\"lang\\": \\"test-lang\\"
 | 
			
		||||
  }
 | 
			
		||||
}"
 | 
			
		||||
  >
 | 
			
		||||
    <title>
 | 
			
		||||
      Regexper
 | 
			
		||||
    </title>
 | 
			
		||||
</HelmetWrapper>
 | 
			
		||||
  </span>
 | 
			
		||||
</DocumentFragment>
 | 
			
		||||
`;
 | 
			
		||||
 | 
			
		||||
exports[`Metadata rendering with a title and description 1`] = `
 | 
			
		||||
<HelmetWrapper
 | 
			
		||||
  defer={true}
 | 
			
		||||
  encodeSpecialCharacters={true}
 | 
			
		||||
  htmlAttributes={
 | 
			
		||||
    Object {
 | 
			
		||||
      "lang": "test-lang",
 | 
			
		||||
    }
 | 
			
		||||
<DocumentFragment>
 | 
			
		||||
  <span
 | 
			
		||||
    data-component="HelmetWrapper"
 | 
			
		||||
    data-props="{
 | 
			
		||||
  \\"htmlAttributes\\": {
 | 
			
		||||
    \\"lang\\": \\"test-lang\\"
 | 
			
		||||
  }
 | 
			
		||||
}"
 | 
			
		||||
  >
 | 
			
		||||
    <title>
 | 
			
		||||
      Regexper - Testing
 | 
			
		||||
@ -33,5 +34,6 @@ exports[`Metadata rendering with a title and description 1`] = `
 | 
			
		||||
      content="Test description"
 | 
			
		||||
      name="description"
 | 
			
		||||
    />
 | 
			
		||||
</HelmetWrapper>
 | 
			
		||||
  </span>
 | 
			
		||||
</DocumentFragment>
 | 
			
		||||
`;
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,13 @@
 | 
			
		||||
jest.mock('react-helmet', () => {
 | 
			
		||||
  const helmet = jest.requireActual('react-helmet');
 | 
			
		||||
  return {
 | 
			
		||||
    ...helmet,
 | 
			
		||||
    Helmet: require('__mocks__/component-mock').buildMock(helmet.Helmet)
 | 
			
		||||
  };
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import { shallow } from 'enzyme';
 | 
			
		||||
import { render } from 'react-testing-library';
 | 
			
		||||
 | 
			
		||||
import { Metadata } from 'components/Metadata';
 | 
			
		||||
 | 
			
		||||
@ -9,19 +17,19 @@ const commonProps = {
 | 
			
		||||
 | 
			
		||||
describe('Metadata', () => {
 | 
			
		||||
  test('rendering', () => {
 | 
			
		||||
    const component = shallow(
 | 
			
		||||
    const { asFragment } = render(
 | 
			
		||||
      <Metadata { ...commonProps } />
 | 
			
		||||
    );
 | 
			
		||||
    expect(component).toMatchSnapshot();
 | 
			
		||||
    expect(asFragment()).toMatchSnapshot();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  test('rendering with a title and description', () => {
 | 
			
		||||
    const component = shallow(
 | 
			
		||||
    const { asFragment } = render(
 | 
			
		||||
      <Metadata
 | 
			
		||||
        title="Testing"
 | 
			
		||||
        description="Test description"
 | 
			
		||||
        { ...commonProps } />
 | 
			
		||||
    );
 | 
			
		||||
    expect(component).toMatchSnapshot();
 | 
			
		||||
    expect(asFragment()).toMatchSnapshot();
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user