@shopgate/engage
Version:
Shopgate's ENGAGE library.
5 lines • 1.32 kB
JavaScript
import React from'react';import{Provider}from'react-redux';import configureStore from'redux-mock-store';import mockRenderOptions from'@shopgate/pwa-common/helpers/mocks/mockRenderOptions';import{mount}from'enzyme';import Shipping from"./index";import{mockedStoreWithShippingPrice,mockedStoreWithFreeShipping,mockedStoreWithUnknownShipping}from"./mock";var mockedStore=configureStore();describe('Shipping label',function(){/**
* Creates connected the component
* @param {Object} state The mocked redux state
* @return {ReactWrapper}
*/var createComponent=function createComponent(state){return mount(React.createElement(Provider,{store:mockedStore(state)},React.createElement(Shipping,{productId:"fakeId"})),mockRenderOptions);};it('should render shipping price',function(){var component=createComponent(mockedStoreWithShippingPrice);expect(component).toMatchSnapshot();expect(component.html().includes('shipping.cost')).toBe(true);});it('should render free shipping',function(){var component=createComponent(mockedStoreWithFreeShipping);expect(component).toMatchSnapshot();expect(component.html().includes('shipping.free')).toBe(true);});it('should not render when shipping is unknown',function(){var component=createComponent(mockedStoreWithUnknownShipping);expect(component.isEmptyRender()).toBe(true);});});