How to use the @magento/peregrine.RestApi.Magento2 function in @magento/peregrine

To help you get started, we’ve selected a few @magento/peregrine 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 Jordaneisenburger / fallback-studio / src / pwa-studio / packages / venia-concept / src / actions / directory / __tests__ / asyncActions.spec.js View on Github external
import { RestApi } from '@magento/peregrine';

import { dispatch, getState } from '../../../store';
import actions from '../actions';
import { getCountries } from '../asyncActions';

jest.mock('../../../store');

const thunkArgs = [dispatch, getState];
const { request } = RestApi.Magento2;

afterEach(() => {
    dispatch.mockClear();
    request.mockClear();
});

test('getCountries() to return a thunk', () => {
    expect(getCountries()).toBeInstanceOf(Function);
});

test('getCountries thunk returns undefined', async () => {
    const thunk = getCountries();

    await expect(thunk(...thunkArgs)).resolves.toBeUndefined();
});