@shopgate/engage
Version:
Shopgate's ENGAGE library.
36 lines • 1.48 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";
import { jsx as _jsx } from "react/jsx-runtime";
const mockedStore = configureStore();
describe('Shipping label', () => {
/**
* Creates connected the component
* @param {Object} state The mocked redux state
* @return {ReactWrapper}
*/
const createComponent = state => mount(/*#__PURE__*/_jsx(Provider, {
store: mockedStore(state),
children: /*#__PURE__*/_jsx(Shipping, {
productId: "fakeId"
})
}), mockRenderOptions);
it('should render shipping price', () => {
const component = createComponent(mockedStoreWithShippingPrice);
expect(component).toMatchSnapshot();
expect(component.html().includes('shipping.cost')).toBe(true);
});
it('should render free shipping', () => {
const component = createComponent(mockedStoreWithFreeShipping);
expect(component).toMatchSnapshot();
expect(component.html().includes('shipping.free')).toBe(true);
});
it('should not render when shipping is unknown', () => {
const component = createComponent(mockedStoreWithUnknownShipping);
expect(component.isEmptyRender()).toBe(true);
});
});