How to use the @shopgate/pwa-common/store.createMockStore function in @shopgate/pwa-common

To help you get started, we’ve selected a few @shopgate/pwa-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shopgate / pwa / themes / theme-ios11 / pages / More / components / Quicklinks / index.spec.jsx View on Github external
import React from 'react';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { createMockStore } from '@shopgate/pwa-common/store';
import { getMenuById } from '@shopgate/pwa-common/selectors/menu';
import Quicklinks from './index';

const store = createMockStore();

jest.mock('@shopgate/pwa-common/components/Link', () => {
  /* eslint-disable react/prop-types, require-jsdoc */
  const Link = ({ children }) => (
    <div>
      {children}
    </div>
  );

  /* eslint-enable react/prop-types, require-jsdoc */
  return Link;
});

let mockedQuicklinks;
jest.mock('@shopgate/pwa-common/selectors/menu', () =&gt; ({
  getMenuById: () =&gt; mockedQuicklinks,
github shopgate / pwa / themes / theme-gmd / components / ProductGrid / components / Item / components / ItemFavoritesButton / spec.jsx View on Github external
import React from 'react';
import { shallow } from 'enzyme';
import { Provider } from 'react-redux';
import { createMockStore } from '@shopgate/pwa-common/store';
import reducers from 'Pages/reducers';
import ItemFavoritesButton from './index';

const store = createMockStore(reducers);
jest.mock('../../../../../View/context.js');

describe('', () =&gt; {
  it('should not render when its not a favorite', () =&gt; {
    const wrapper = shallow((
      
        
      
    ));
    expect(wrapper).toMatchSnapshot();
  });

  it('should render if its a favorite', () =&gt; {
    const wrapper = shallow((
github shopgate / pwa / themes / theme-gmd / pages / RootCategory / spec.jsx View on Github external
import React from 'react';
import { shallow } from 'enzyme';
import { Provider } from 'react-redux';
import { createMockStore } from '@shopgate/pwa-common/store';
import RootCategory from './index';

const store = createMockStore();
jest.mock('../../components/View/context.js');

describe('Pages: ', () =&gt; {
  it('should render', () =&gt; {
    const wrapper = shallow((
      
        
      
    ));
    expect(wrapper).toMatchSnapshot();
  });
});
github shopgate / pwa / themes / theme-gmd / pages / Favorites / subscriptions.spec.js View on Github external
import { UIEvents } from '@shopgate/pwa-core';
import { createMockStore } from '@shopgate/pwa-common/store';
import { REQUEST_REMOVE_FAVORITES } from '@shopgate/pwa-common-commerce/favorites/constants';
import subscriber from './subscriptions';

const store = createMockStore(() => {}, subscriber);

describe('Favorites Subscriptions', () => {
  it('should display a toast message when an item was deleted', (done) => {
    store.dispatch({ type: REQUEST_REMOVE_FAVORITES });
    setTimeout(() => {
      expect(UIEvents.emit).toHaveBeenCalled();
      done();
    }, 500);
  });
});
github shopgate / pwa / themes / theme-ios11 / pages / More / components / UserMenu / index.spec.jsx View on Github external
import React from 'react';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { createMockStore } from '@shopgate/pwa-common/store';
import { isUserLoginDisabled } from '@shopgate/pwa-common/selectors/user';
import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
import UserMenu from './index';

jest.mock('@shopgate/pwa-common/selectors/user', () =&gt; ({
  isUserLoginDisabled: jest.fn().mockReturnValue(false),
}));

const store = createMockStore();

describe('', () =&gt; {
  it('should render as expected when the user is logged in', () =&gt; {
    const logoutHandler = jest.fn();
    const wrapper = mount((
      
        
      ), mockRenderOptions);

    expect(wrapper).toMatchSnapshot();
    expect(wrapper.find('LoggedIn').exists()).toBe(true);
    expect(wrapper.find('MoreMenuItem').text()).toBe('navigation.logout');
    wrapper.find('MoreMenuItem').simulate('click');
    expect(logoutHandler).toHaveBeenCalledTimes(1);
  });
github shopgate / pwa / themes / theme-gmd / pages / WriteReview / subscriptions.spec.js View on Github external
import { getCurrentRoute } from '@shopgate/pwa-common/selectors/router';
import { LoadingProvider } from '@shopgate/pwa-common/providers';
import { createMockStore } from '@shopgate/pwa-common/store';
import requestSubmitReview from '@shopgate/pwa-common-commerce/reviews/action-creators/requestSubmitReview';
import subscriber from './subscriptions';
import reducers from '../reducers';

const store = createMockStore(reducers, subscriber);

jest.mock('@shopgate/engage/core', () => ({
  persistedReducers: {
    set: jest.fn(),
  },
  configuration: {
    set: jest.fn(),
  },
}));

jest.mock('@shopgate/pwa-common/selectors/router', () => ({
  getCurrentRoute: jest.fn(),
}));

describe('WriteReview Subscriptions', () => {
  const pathname = '/some/path';
github shopgate / pwa / libraries / commerce / product / streams / index.spec.js View on Github external
beforeEach(() => {
    store = createMockStore(combineReducers({
      product,
      router,
    }));
    ({ dispatch } = store);
  });
github shopgate / pwa / libraries / commerce / cart / streams / index.spec.js View on Github external
beforeEach(() => {
    jest.clearAllMocks();
    ({ dispatch } = createMockStore());
  });
github shopgate / pwa / libraries / tracking / streams / category.spec.js View on Github external
beforeEach(() => {
    jest.clearAllMocks();

    mockedRoutePattern = '';
    mockedCategoryId = null;
    ({ dispatch } = createMockStore(combineReducers({ category, product })));

    categoryIsReadySubscriber = jest.fn();
    categoryIsReady$.subscribe(categoryIsReadySubscriber);
  });
github shopgate / pwa / libraries / tracking / streams / pages.spec.js View on Github external
beforeEach(() => {
    jest.clearAllMocks();

    mockedPattern = '';
    ({ dispatch } = createMockStore(combineReducers({ user })));

    pagesAreReadySubscriber = jest.fn();
    pagesAreReady$.subscribe(pagesAreReadySubscriber);
  });