import React from 'react'; import { InlineIcon } from '../../dist/offline'; import renderer from 'react-test-renderer'; const iconData = { body: '', width: 24, height: 32, }; describe('Rotation', () => { test('number', () => { const component = renderer.create( ); const tree = component.toJSON(); const body = tree.props.dangerouslySetInnerHTML.__html; expect(body).not.toStrictEqual(iconData.body); expect(body).toMatch('rotate(90 '); }); test('string', () => { const component = renderer.create( ); const tree = component.toJSON(); const body = tree.props.dangerouslySetInnerHTML.__html; expect(body).not.toStrictEqual(iconData.body); expect(body).toMatch('rotate(180 '); }); }); describe('Flip', () => { test('boolean', () => { const component = renderer.create( ); const tree = component.toJSON(); const body = tree.props.dangerouslySetInnerHTML.__html; expect(body).not.toStrictEqual(iconData.body); expect(body).toMatch('scale(-1 1)'); }); test('string', () => { const component = renderer.create( ); const tree = component.toJSON(); const body = tree.props.dangerouslySetInnerHTML.__html; expect(body).not.toStrictEqual(iconData.body); expect(body).toMatch('scale(1 -1)'); }); test('string and boolean', () => { const component = renderer.create( ); const tree = component.toJSON(); const body = tree.props.dangerouslySetInnerHTML.__html; expect(body).not.toStrictEqual(iconData.body); // horizontal + vertical = 180deg rotation expect(body).toMatch('rotate(180 '); }); test('string for boolean attribute', () => { const component = renderer.create( ); const tree = component.toJSON(); const body = tree.props.dangerouslySetInnerHTML.__html; expect(body).not.toStrictEqual(iconData.body); expect(body).toMatch('scale(-1 1)'); }); test('shorthand and boolean', () => { // 'flip' is processed after 'hFlip' because of order of elements in object, overwriting value const component = renderer.create( ); const tree = component.toJSON(); const body = tree.props.dangerouslySetInnerHTML.__html; expect(body).not.toStrictEqual(iconData.body); expect(body).toMatch('scale(-1 1)'); }); test('shorthand and boolean as string', () => { const component = renderer.create( ); const tree = component.toJSON(); const body = tree.props.dangerouslySetInnerHTML.__html; expect(body).not.toStrictEqual(iconData.body); // horizontal + vertical = 180deg rotation expect(body).toMatch('rotate(180 '); }); test('wrong case', () => { const component = renderer.create( ); const tree = component.toJSON(); const body = tree.props.dangerouslySetInnerHTML.__html; expect(body).not.toMatch('scale('); }); }); describe('Alignment and slice', () => { test('vAlign and slice', () => { const component = renderer.create( ); const tree = component.toJSON(); expect(tree.props.preserveAspectRatio).toStrictEqual('xMidYMin slice'); }); test('string', () => { const component = renderer.create( ); const tree = component.toJSON(); expect(tree.props.preserveAspectRatio).toStrictEqual('xMinYMax meet'); }); });