2020-11-06 01:21:05 +00:00
|
|
|
/**
|
|
|
|
* 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: <span>Custom panel 1</span>,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'custom-panel-2',
|
|
|
|
title: 'custom-panel-2',
|
|
|
|
count: 20000,
|
|
|
|
initialOpen: false,
|
|
|
|
panel: <span>Custom panel 2</span>,
|
|
|
|
},
|
|
|
|
] ),
|
|
|
|
};
|
|
|
|
} );
|
|
|
|
|
2020-11-06 16:50:24 +00:00
|
|
|
// Mock the orders and order statuses.
|
2020-11-06 01:21:05 +00:00
|
|
|
jest.mock( '../orders/utils', () => {
|
|
|
|
return {
|
2020-11-25 18:51:15 +00:00
|
|
|
getLowStockCount: jest.fn().mockImplementation( () => 0 ),
|
2020-11-06 01:21:05 +00:00
|
|
|
getUnreadOrders: jest.fn().mockImplementation( () => 100 ),
|
2020-11-06 16:50:24 +00:00
|
|
|
getOrderStatuses: jest.fn().mockImplementation( () => [ 'status' ] ),
|
2020-11-06 01:21:05 +00:00
|
|
|
};
|
|
|
|
} );
|
|
|
|
|
|
|
|
describe( 'ActivityPanel', () => {
|
|
|
|
it( 'should render a panel with two rows', () => {
|
|
|
|
render( <ActivityPanel /> );
|
|
|
|
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( <ActivityPanel /> );
|
|
|
|
expect( screen.queryByText( 'Custom panel 1' ) ).toBeInTheDocument();
|
|
|
|
expect(
|
|
|
|
screen.queryByText( 'Custom panel 2' )
|
|
|
|
).not.toBeInTheDocument();
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should render the count of unread items', () => {
|
|
|
|
render( <ActivityPanel /> );
|
|
|
|
expect( screen.queryByText( '10000' ) ).toBeInTheDocument();
|
|
|
|
expect( screen.queryByText( '20000' ) ).toBeInTheDocument();
|
|
|
|
} );
|
|
|
|
} );
|