2
0
mirror of https://github.com/iconify/iconify.git synced 2024-09-21 09:39:11 +00:00
iconify/components/react/tests/offline/20-dimensions.test.js

52 lines
1.3 KiB
JavaScript

import React from 'react';
import { InlineIcon } from '../../dist/offline';
import renderer from 'react-test-renderer';
const iconData = {
body: '<path d="M4 19h16v2H4zm5-4h11v2H9zm-5-4h16v2H4zm0-8h16v2H4zm5 4h11v2H9z" fill="currentColor"/>',
width: 24,
height: 24,
};
describe('Dimensions', () => {
test('height', () => {
const component = renderer.create(
<InlineIcon icon={iconData} height="48" />
);
const tree = component.toJSON();
expect(tree.props.height).toStrictEqual('48');
expect(tree.props.width).toStrictEqual('48');
});
test('width and height', () => {
const component = renderer.create(
<InlineIcon icon={iconData} width={32} height="48" />
);
const tree = component.toJSON();
expect(tree.props.height).toStrictEqual('48');
expect(tree.props.width).toStrictEqual('32');
});
test('auto', () => {
const component = renderer.create(
<InlineIcon icon={iconData} height="auto" />
);
const tree = component.toJSON();
expect(tree.props.height).toStrictEqual('24');
expect(tree.props.width).toStrictEqual('24');
});
test('undefined', () => {
const component = renderer.create(
<InlineIcon icon={iconData} height="undefined" />
);
const tree = component.toJSON();
expect(tree.props.height).toStrictEqual(void 0);
expect(tree.props.width).toStrictEqual(void 0);
});
});