import React from 'react'; import { shallow, mount } from 'enzyme'; import StoryHighlight from '.'; import StoryContent, { StyledLabel, StyledPrice } from './content'; import { Body } from '@Typography' import 'jest-styled-components'; const baseProps = { medias: [ { alt: `Women's Explore Technical T-Shirt`, aspect: '2:3', src: 'https://images.ctfassets.net/aagggu2xeezl/37M5GswtIRMngUu0k2yyqZ/d05a29fec2da7f11a29a1241a7da2cbb/Canyon_Sram_1.png' }, { alt: `Women's Explore Technical T-Shirt`, aspect: '2:3', src: 'https://images.ctfassets.net/aagggu2xeezl/2ARjn02KFaEoZn0rjahflf/938f0d5b90a48397707b446e93a83d51/Canyon_Sram_2.png' } ], product: { cta: 'Shop Now', description: 'A t-shirt designed to support exploration on and off the bike.', name: `Women's Explore Technical T-Shirt`, price: '£65.00', href: '/shop/womens-explore-technical-t-shirt/product/TTW01XXDNY', } } describe('StoryHighlight component', () => { test('renders', () => { const wrapper = shallow( ); expect(wrapper).toMatchSnapshot(); }); test('renders layout `2` with the direction `right`', () => { const wrapper = shallow( ); expect(wrapper.props().direction).toEqual('right'); expect(wrapper.props().layout).toEqual(2); }); test('renders layout `2` with the direction `left`', () => { const wrapper = shallow( ); expect(wrapper.props().direction).toEqual('left'); expect(wrapper.props().layout).toEqual(2); }); test('renders layout `3`', () => { const wrapper = shallow( ); expect(wrapper.props().layout).toEqual(3); }); test('renders content', () => { const wrapper = mount( ); const content = wrapper.find(StoryContent).first(); // const contentName = content.find(Label).first(); expect(content).toHaveLength(1); // expect(contentName).toHaveLength(1); }); test('renders content with the name equal to `Women\'s Explore Technical T-Shirt`', () => { const wrapper = mount( ); const content = wrapper.find(StoryContent).first(); const contentName = content.find(StyledLabel).first(); expect(contentName).toHaveLength(1); expect(contentName.text()).toEqual(`Women's Explore Technical T-Shirt`); }); test('renders content with the description equal to `A t-shirt designed to support exploration on and off the bike.`', () => { const wrapper = mount( ); const content = wrapper.find(StoryContent).first(); const contentDescription = content.find(Body).at(0); expect(contentDescription).toHaveLength(1); expect(contentDescription.text()).toEqual(`A t-shirt designed to support exploration on and off the bike.`); }); test('renders content with the price equal to `£65.00`', () => { const wrapper = mount( ); const content = wrapper.find(StoryContent).first(); const contentPrice = content.find(StyledPrice).first(); expect(contentPrice).toHaveLength(1); expect(contentPrice.text()).toEqual(`£65.00`); }); });