github.com/freiheit-com/kuberpult@v1.24.2-0.20240328135542-315d5630abe6/services/frontend-service/src/ui/Pages/Releases/ReleasesPage.test.tsx (about)

     1  /*This file is part of kuberpult.
     2  
     3  Kuberpult is free software: you can redistribute it and/or modify
     4  it under the terms of the Expat(MIT) License as published by
     5  the Free Software Foundation.
     6  
     7  Kuberpult is distributed in the hope that it will be useful,
     8  but WITHOUT ANY WARRANTY; without even the implied warranty of
     9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    10  MIT License for more details.
    11  
    12  You should have received a copy of the MIT License
    13  along with kuberpult. If not, see <https://directory.fsf.org/wiki/License:Expat>.
    14  
    15  Copyright 2023 freiheit.com*/
    16  import { render } from '@testing-library/react';
    17  import { MemoryRouter } from 'react-router-dom';
    18  import { ReleasesPage } from './ReleasesPage';
    19  import { fakeLoadEverything } from '../../../setupTests';
    20  
    21  describe('LocksPage', () => {
    22      const getNode = (): JSX.Element | any => (
    23          <MemoryRouter>
    24              <ReleasesPage />
    25          </MemoryRouter>
    26      );
    27      const getWrapper = () => render(getNode());
    28  
    29      interface dataEnvT {
    30          name: string;
    31          loaded: boolean;
    32          expectedNumMainContent: number;
    33          expectedNumSpinner: number;
    34      }
    35  
    36      const sampleEnvData: dataEnvT[] = [
    37          {
    38              name: 'renders main',
    39              loaded: true,
    40              expectedNumMainContent: 1,
    41              expectedNumSpinner: 0,
    42          },
    43          {
    44              name: 'renders spinner',
    45              loaded: false,
    46              expectedNumMainContent: 0,
    47              expectedNumSpinner: 1,
    48          },
    49      ];
    50  
    51      describe.each(sampleEnvData)(`Renders ReleasesPage`, (testcase) => {
    52          it(testcase.name, () => {
    53              fakeLoadEverything(testcase.loaded);
    54              const { container } = getWrapper();
    55              expect(container.getElementsByClassName('main-content')).toHaveLength(testcase.expectedNumMainContent);
    56              expect(container.getElementsByClassName('spinner')).toHaveLength(testcase.expectedNumSpinner);
    57          });
    58      });
    59  });