2019-03-02 15:51:08 +08:00
|
|
|
import React from 'react';
|
2019-03-04 14:54:28 +08:00
|
|
|
import { mount, render } from 'enzyme';
|
2019-03-02 15:51:08 +08:00
|
|
|
import PageHeader from '..';
|
|
|
|
|
|
|
|
describe('PageHeader', () => {
|
|
|
|
it('pageHeader should not contain back it back', () => {
|
|
|
|
const routes = [
|
|
|
|
{
|
|
|
|
path: 'index',
|
|
|
|
breadcrumbName: 'First-level Menu',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'first',
|
|
|
|
breadcrumbName: 'Second-level Menu',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'second',
|
|
|
|
breadcrumbName: 'Third-level Menu',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
const wrapper = mount(<PageHeader title="Page Title" breadcrumb={{ routes }} />);
|
|
|
|
expect(wrapper.find('.ant-page-header-back-icon')).toHaveLength(0);
|
|
|
|
});
|
2019-03-04 14:54:28 +08:00
|
|
|
it('pageHeader should no contain back it back', () => {
|
2019-03-02 15:51:08 +08:00
|
|
|
const wrapper = mount(<PageHeader title="Page Title" backIcon={false} />);
|
|
|
|
expect(wrapper.find('.ant-page-header-back-icon')).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('pageHeader should contain back it back', () => {
|
|
|
|
const callback = jest.fn(() => true);
|
|
|
|
const wrapper = mount(<PageHeader title="Page Title" onBack={callback} />);
|
|
|
|
expect(wrapper.find('.ant-page-header-back-icon')).toHaveLength(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('pageHeader onBack transfer', () => {
|
|
|
|
const callback = jest.fn(() => true);
|
|
|
|
const wrapper = mount(<PageHeader title="Page Title" onBack={callback} />);
|
|
|
|
wrapper.find('.ant-page-header-back-icon').simulate('click');
|
|
|
|
expect(callback).toBeCalled();
|
|
|
|
});
|
2019-03-04 14:54:28 +08:00
|
|
|
|
|
|
|
it('pageHeader should support className', () => {
|
|
|
|
const wrapper = render(
|
|
|
|
<PageHeader title="Page Title" className="not-works" backIcon={false} />,
|
|
|
|
);
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
2019-03-02 15:51:08 +08:00
|
|
|
});
|