Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('when there is a mcApiProxyTarget', () => {
const dispatch = jest.fn();
const action = sdkActions.get({
uri: '/foo',
mcApiProxyTarget: MC_API_PROXY_TARGETS.COMMERCETOOLS_PLATFORM,
});
const next = jest.fn();
const response = { body: { foo: 'bar' }, headers: {}, statusCode: 200 };
beforeEach(() => {
execute = jest.fn(() => Promise.resolve(response));
mocked(createClient).mockReturnValue({
execute,
});
return createMiddleware(middlewareOptions)({
dispatch,
getState: jest.fn(),
})(next)(action);
});
it('should call `client.execute` with uri with prefix', () => {
export const fetchStateMachines = requestOptions =>
sdkActions.get({
mcApiProxyTarget: MC_API_PROXY_TARGETS.COMMERCETOOLS_PLATFORM,
service: 'states',
options: requestOptions,
});
const createStateMachinesDetailSdkMockForId1 = () => ({
action: {
type: 'SDK',
payload: {
method: 'GET',
service: 'states',
options: { id: 'sm1' },
mcApiProxyTarget: MC_API_PROXY_TARGETS.COMMERCETOOLS_PLATFORM,
},
},
response: {
id: 'sm1',
key: 'sm-1',
type: 'LineItemState',
initial: true,
builtIn: true,
},
});
const createStateMachinesDetailSdkMockForId2 = () => ({
export const fetchStateMachine = id =>
sdkActions.get({
mcApiProxyTarget: MC_API_PROXY_TARGETS.COMMERCETOOLS_PLATFORM,
service: 'states',
options: { id },
});