PageHeader.test.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React from 'react';
  2. import PageHeader from './PageHeader';
  3. import { shallow } from 'enzyme';
  4. describe('PageHeader', () => {
  5. let wrapper;
  6. describe('when the nav tree has a node with a title', () => {
  7. beforeAll(() => {
  8. const nav = {
  9. main: {
  10. icon: 'fa fa-folder-open',
  11. id: 'node',
  12. subTitle: 'node subtitle',
  13. url: '',
  14. text: 'node',
  15. },
  16. node: {},
  17. };
  18. wrapper = shallow(<PageHeader model={nav as any} />);
  19. });
  20. it('should render the title', () => {
  21. const title = wrapper.find('.page-header__title');
  22. expect(title.text()).toBe('node');
  23. });
  24. });
  25. describe('when the nav tree has a node with breadcrumbs and a title', () => {
  26. beforeAll(() => {
  27. const nav = {
  28. main: {
  29. icon: 'fa fa-folder-open',
  30. id: 'child',
  31. subTitle: 'child subtitle',
  32. url: '',
  33. text: 'child',
  34. breadcrumbs: [{ title: 'Parent', url: 'parentUrl' }],
  35. },
  36. node: {},
  37. };
  38. wrapper = shallow(<PageHeader model={nav as any} />);
  39. });
  40. it('should render the title with breadcrumbs first and then title last', () => {
  41. const title = wrapper.find('.page-header__title');
  42. expect(title.text()).toBe('Parent / child');
  43. const parentLink = wrapper.find('.page-header__title > a.text-link');
  44. expect(parentLink.prop('href')).toBe('parentUrl');
  45. });
  46. });
  47. });