/**
* External dependencies
*/
import { render, screen } from '@testing-library/react';
/**
* Internal dependencies
*/
import { ActivityPanel } from '../';
// Mock the panels.
jest.mock( '../panels', () => {
return {
getAllPanels: jest.fn().mockImplementation( () => [
{
id: 'custom-panel-1',
title: 'custom-panel-1',
count: 10000,
initialOpen: true,
panel: Custom panel 1,
collapsible: true,
},
{
id: 'custom-panel-2',
title: 'custom-panel-2',
count: 20000,
initialOpen: false,
panel: Custom panel 2,
collapsible: true,
},
] ),
};
} );
// Mock the orders and order statuses.
jest.mock( '../orders/utils', () => {
return {
getLowStockCount: jest.fn().mockImplementation( () => 0 ),
getUnreadOrders: jest.fn().mockImplementation( () => 100 ),
getOrderStatuses: jest.fn().mockImplementation( () => [ 'status' ] ),
};
} );
describe( 'ActivityPanel', () => {
it( 'should render a panel with two rows', () => {
render( );
expect( screen.getByText( 'custom-panel-1' ) ).not.toBeNull();
expect( screen.getByText( 'custom-panel-2' ) ).not.toBeNull();
} );
it( 'should render one visible panel and one hidden panel', () => {
render( );
expect( screen.queryByText( 'Custom panel 1' ) ).toBeInTheDocument();
expect(
screen.queryByText( 'Custom panel 2' )
).not.toBeInTheDocument();
} );
it( 'should render the count of unread items', () => {
render( );
expect( screen.queryByText( '10000' ) ).toBeInTheDocument();
expect( screen.queryByText( '20000' ) ).toBeInTheDocument();
} );
} );