@shopgate/engage
Version:
Shopgate's ENGAGE library.
1 lines • 1.35 kB
JavaScript
import React from'react';import{shallow}from'enzyme';import Tiers from"./index";jest.mock("./connector",function(){return function(cmp){return cmp;};});describe('<Tiers />',function(){describe('Rendering with data',function(){it('should render tier prices when tier prices are available',function(){var price={tiers:[{from:1,to:2,unitPrice:92.5},{from:3,to:5,unitPrice:77.5},{from:6,to:null,unitPrice:68.5}],currency:'USD'};var wrapper=shallow(React.createElement(Tiers,{price:price}));expect(wrapper).toMatchSnapshot();});});describe('Rendering without data',function(){it('should render nothing when price data are not available ({})',function(){var wrapper=shallow(React.createElement(Tiers,{price:{}}));expect(wrapper).toBeEmptyRender();});it('should render nothing when price data are not available (null)',function(){var wrapper=shallow(React.createElement(Tiers,{price:null}));expect(wrapper).toBeEmptyRender();});it('should render nothing when tier prices are empty ([])',function(){var price={tiers:[],currency:'USD'};var wrapper=shallow(React.createElement(Tiers,{price:price}));expect(wrapper).toBeEmptyRender();});it('should render nothing when tier prices are not available (field missing)',function(){var price={currency:'USD'};var wrapper=shallow(React.createElement(Tiers,{price:price}));expect(wrapper).toBeEmptyRender();});});});