import React from 'react'; import { shallow } from 'enzyme'; import Flex from '../Flex'; /* eslint-disable comma-dangle */ describe('Flex', () => { it('styles itself properly with wrap flag set to false', () => { const noWrapComponent = shallow(
Hey
Hi
Hello
); expect(noWrapComponent.prop('style').display).toBe('flex'); expect(noWrapComponent.prop('style').flexWrap).toBe('no-wrap'); }); it('styles itself properly with wrap flag set to true', () => { const wrapComponent = shallow(
Hey
Hi
Hello
); expect(wrapComponent.prop('style').display).toBe('flex'); expect(wrapComponent.prop('style').flexWrap).toBe('wrap'); }); it('renders all given children', () => { const component = shallow(
Hey
Hi
Hello
); const children = component.children(); expect(children).toHaveLength(3); expect(children.at(0).text()).toBe('Hey'); expect(children.at(1).text()).toBe('Hi'); expect(children.at(2).text()).toBe('Hello'); }); it('properly sizes and positions all the elements', () => { const component = shallow(
Hey
Hi
); const children = component.children(); children.forEach(child => expect(parseFloat(child.prop('style').flexBasis)).toBeCloseTo(33.33)); expect(parseFloat(children.first().prop('style').marginLeft)).toBeCloseTo(33.33); }); });