/**
* External dependencies
*/
import { render, screen } from '@testing-library/react';
import { Layout } from '../layout';
// Rendering breaks tests.
jest.mock( 'homepage/stats-overview', () => jest.fn().mockReturnValue( null ) );
// We aren't testing the component here.
jest.mock( 'task-list', () => jest.fn().mockReturnValue( '[TaskList]' ) );
// We aren't testing the component here.
jest.mock( 'header/activity-panel/panels/inbox', () =>
jest.fn().mockReturnValue( '[InboxPanel]' )
);
// We aren't testing the component here.
jest.mock( 'quick-links', () => jest.fn().mockReturnValue( '[QuickLinks]' ) );
describe( 'Homepage Layout', () => {
it( 'should show TaskList placeholder when loading', () => {
const { container } = render(
);
const placeholder = container.querySelector(
'.woocommerce-task-card.is-loading'
);
expect( placeholder ).not.toBeNull();
} );
it( 'should show TaskList inline', async () => {
const { container } = render(
);
// Expect that we're rendering the "full" home screen (with columns).
const columns = container.querySelector(
'.woocommerce-homepage-column'
);
expect( columns ).not.toBeNull();
// Expect that the is there too.
const taskList = await screen.findByText( '[TaskList]' );
expect( taskList ).toBeDefined();
} );
it( 'should render TaskList alone when on task', async () => {
const { container } = render(
);
// Expect that we're NOT rendering the "full" home screen (with columns).
const columns = container.querySelector(
'.woocommerce-homepage-column'
);
expect( columns ).toBeNull();
// Expect that the is there though.
const taskList = await screen.findByText( '[TaskList]' );
expect( taskList ).toBeDefined();
} );
it( 'should not show TaskList when user has hidden', () => {
render(
);
const taskList = screen.queryByText( '[TaskList]' );
expect( taskList ).toBeNull();
} );
it( 'should not show TaskList when it is complete', () => {
render(
);
const taskList = screen.queryByText( '[TaskList]' );
expect( taskList ).toBeNull();
} );
it( 'should show QuickLinks when user has hidden TaskList', () => {
render(
);
const quickLinks = screen.queryByText( '[QuickLinks]' );
expect( quickLinks ).toBeDefined();
} );
it( 'should show QuickLinks when TaskList is complete', () => {
render(
);
const quickLinks = screen.queryByText( '[QuickLinks]' );
expect( quickLinks ).toBeDefined();
} );
} );