Skip to content

Commit

Permalink
Fix peregrine mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbo committed Apr 16, 2019
1 parent 14addc8 commit 22b7e93
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions packages/venia-concept/__mocks__/@magento/peregrine.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,39 @@ import { BrowserPersistence } from './util/simplePersistence';

const peregrine = jest.requireActual('../../../peregrine/src');

const mockRequest = jest.fn();

// re-exports
const RestApi = {
Magento2: {
request: mockRequest
request: jest.fn()
}
};

const Util = {
BrowserPersistence: BrowserPersistence
};
const Util = { BrowserPersistence };

// hooks
const useApolloContext = jest.fn(peregrine.useApolloContext);
const useDocumentListener = jest.fn(peregrine.useDocumentListener);
const useDropdown = jest.fn(peregrine.useDropdown);
const useQueryResult = jest.fn(peregrine.useQueryResult);
const useValueFromSearchParams = jest.fn(peregrine.useValueFromSearchParams);

// components

/**
* the Price component from @magento/peregrine
* has browser-specific functionality and cannot
* currently by rendered in the test environment
*/
const Price = () => <div />;
const Price = jest.fn().mockReturnValue(<div />);

module.exports = {
...peregrine,
mockRequest,
Price,
RestApi,
Util,
Price
useApolloContext,
useDocumentListener,
useDropdown,
useQueryResult,
useValueFromSearchParams
};

0 comments on commit 22b7e93

Please # to comment.