/** * External dependencies */ import { render, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; /** * Internal dependencies */ import { StockPanel } from '../'; describe( 'StockPanel', () => { it( 'should the correct number of placeholders', () => { const { container } = render( ); expect( container.querySelectorAll( '.woocommerce-stock-activity-card.is-loading' ) ).toHaveLength( 3 ); } ); it( 'should request more products when one is updated', async () => { const createNotice = jest.fn(); const invalidateResolution = jest.fn(); const updateProductStock = jest.fn().mockResolvedValue( true ); const { getByRole } = render( ); userEvent.click( getByRole( 'button', { name: 'Update stock' } ) ); // Number input gets "spinbutton", apparently. userEvent.type( getByRole( 'spinbutton' ), '3' ); userEvent.click( getByRole( 'button', { name: 'Save' } ) ); await waitFor( () => { expect( invalidateResolution ).toHaveBeenCalled(); } ); } ); } );