Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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', () => ({
getMenuById: () => mockedQuicklinks,
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('', () => {
it('should not render when its not a favorite', () => {
const wrapper = shallow((
));
expect(wrapper).toMatchSnapshot();
});
it('should render if its a favorite', () => {
const wrapper = shallow((
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: ', () => {
it('should render', () => {
const wrapper = shallow((
));
expect(wrapper).toMatchSnapshot();
});
});
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);
});
});
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', () => ({
isUserLoginDisabled: jest.fn().mockReturnValue(false),
}));
const store = createMockStore();
describe('', () => {
it('should render as expected when the user is logged in', () => {
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);
});
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';
beforeEach(() => {
store = createMockStore(combineReducers({
product,
router,
}));
({ dispatch } = store);
});
beforeEach(() => {
jest.clearAllMocks();
({ dispatch } = createMockStore());
});
beforeEach(() => {
jest.clearAllMocks();
mockedRoutePattern = '';
mockedCategoryId = null;
({ dispatch } = createMockStore(combineReducers({ category, product })));
categoryIsReadySubscriber = jest.fn();
categoryIsReady$.subscribe(categoryIsReadySubscriber);
});
beforeEach(() => {
jest.clearAllMocks();
mockedPattern = '';
({ dispatch } = createMockStore(combineReducers({ user })));
pagesAreReadySubscriber = jest.fn();
pagesAreReady$.subscribe(pagesAreReadySubscriber);
});