sentryDocumentTitle.spec.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {render} from 'sentry-test/reactTestingLibrary';
  2. import SentryDocumentTitle from './sentryDocumentTitle';
  3. describe('SentryDocumentTitle', () => {
  4. it('sets the docuemnt title', () => {
  5. render(<SentryDocumentTitle title="This is a test" />);
  6. expect(document.title).toBe('This is a test — Sentry');
  7. });
  8. it('adds a organization slug', () => {
  9. render(<SentryDocumentTitle orgSlug="org" title="This is a test" />);
  10. expect(document.title).toBe('This is a test — org — Sentry');
  11. });
  12. it('adds a project slug', () => {
  13. render(<SentryDocumentTitle projectSlug="project" title="This is a test" />);
  14. expect(document.title).toBe('This is a test — project — Sentry');
  15. });
  16. it('adds a organization and project slug', () => {
  17. render(
  18. <SentryDocumentTitle orgSlug="org" projectSlug="project" title="This is a test" />
  19. );
  20. expect(document.title).toBe('This is a test — org — project — Sentry');
  21. });
  22. it('sets the title without suffix', () => {
  23. render(<SentryDocumentTitle title="This is a test" noSuffix />);
  24. expect(document.title).toBe('This is a test');
  25. });
  26. it('reverts to the parent title', () => {
  27. const {rerender} = render(
  28. <SentryDocumentTitle title="This is a test">
  29. <SentryDocumentTitle title="child title">Content</SentryDocumentTitle>
  30. </SentryDocumentTitle>
  31. );
  32. expect(document.title).toBe('child title — Sentry');
  33. rerender(
  34. <SentryDocumentTitle title="This is a test">new Content</SentryDocumentTitle>
  35. );
  36. expect(document.title).toBe('This is a test — Sentry');
  37. });
  38. });