[TNL-7268] Remove icon mock

As we're not using snapshots, we will not need this anymore.
This commit is contained in:
Agrendalath
2020-07-15 22:53:04 +02:00
committed by David Joy
parent 0c5fd44d13
commit 7c046870e3
2 changed files with 3 additions and 35 deletions

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { render, screen } from '../../../../setupTest';
import { render } from '../../../../setupTest';
import UnitIcon from './UnitIcon';
describe('Unit Icon', () => {
@@ -19,8 +19,8 @@ describe('Unit Icon', () => {
jest.spyOn(console, 'error').mockImplementation(() => {});
}
render(<UnitIcon type={key} />);
expect(screen.getByTestId('icon')).toHaveClass(value);
const { container } = render(<UnitIcon type={key} />);
expect(container.querySelector('svg')).toHaveClass(value);
});
});
});

View File

@@ -1,32 +0,0 @@
/**
* Mocks `@fortawesome/react-fontawesome.js` to return a simple <img> element containing `data-testid` attribute.
* This way we can check whether the icon matches without relying on its internal implementation
* and avoid storing its <svg> content in the snapshot tests.
*/
import React from 'react';
import PropTypes from 'prop-types';
// eslint-disable-next-line no-use-before-define
FontAwesomeIcon.propTypes = {
icon: PropTypes.oneOfType([
PropTypes.string,
PropTypes.shape({
icon: PropTypes.arrayOf(PropTypes.any),
}),
]).isRequired,
};
// eslint-disable-next-line import/prefer-default-export
export function FontAwesomeIcon(props) {
const { icon } = props;
let iconName;
if (typeof icon === 'string') {
iconName = icon;
} else {
iconName = `fa-${icon.iconName}`;
}
// eslint-disable-next-line react/jsx-filename-extension
return <svg data-testid="icon" className={iconName} />;
}