github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/components/PageTitle.spec.tsx (about)

     1  import React from 'react';
     2  import PageTitle, { AppNameContext } from './PageTitle';
     3  import { render, screen, waitFor } from '@testing-library/react';
     4  
     5  // Default is 1000, try a few more times since it was failing in ci
     6  const waitForOpts = {
     7    timeout: 5000,
     8  };
     9  
    10  describe('PageTitle', () => {
    11    describe("there's no app name in context", () => {
    12      it('defaults to Pyroscope', async () => {
    13        render(<PageTitle title={'mypage'} />);
    14  
    15        await waitFor(
    16          () => expect(document.title).toEqual('mypage | Pyroscope'),
    17          waitForOpts
    18        );
    19      });
    20    });
    21  
    22    describe("there's an app name in context", () => {
    23      it('suffixes the title with it', async () => {
    24        render(
    25          <AppNameContext.Provider value={'myapp'}>
    26            <PageTitle title={'mypage'} />
    27          </AppNameContext.Provider>
    28        );
    29  
    30        await waitFor(
    31          () => expect(document.title).toEqual('mypage | myapp'),
    32          waitForOpts
    33        );
    34      });
    35    });
    36  });