How to use the @magento/peregrine.useQuery.mockImplementation 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 / components / SearchBar / __tests__ / autocomplete.spec.js View on Github external
const runQuery = jest.fn();
const setLoading = jest.fn();
runQuery.cancel = jest.fn();

const queryState = {
    data: null,
    error: null,
    loading: false
};
const queryApi = {
    resetState,
    runQuery,
    setLoading
};

useQuery.mockImplementation(() => [queryState, queryApi]);

test('renders correctly', () => {
    const { root } = createTestInstance(
        <form>
            
        
    );

    expect(root.findByProps({ className: 'root_hidden' })).toBeTruthy();
    expect(root.findByProps({ className: 'message' })).toBeTruthy();
    expect(root.findByProps({ className: 'suggestions' })).toBeTruthy();
});

test('resets query state if not visible', () =&gt; {
    createTestInstance(
        <form></form></form>