Signed-off-by: Andrew Johnson <ajohnson@gocardless.com>
This commit is contained in:
Andrew Johnson
2021-04-16 01:02:41 +01:00
parent af95852d2e
commit 523371d8a9
2 changed files with 14 additions and 15 deletions
@@ -26,7 +26,11 @@ import {
import { fireEvent } from '@testing-library/react';
import { msw, renderInTestApp } from '@backstage/test-utils';
import { GithubDeploymentsApiClient, githubDeploymentsApiRef } from '../api';
import {
GithubDeployment,
GithubDeploymentsApiClient,
githubDeploymentsApiRef,
} from '../api';
import { githubDeploymentsPlugin } from '../plugin';
import { GithubDeploymentsCard } from './GithubDeploymentsCard';
@@ -40,6 +44,7 @@ import {
import { setupServer } from 'msw/node';
import { graphql } from 'msw';
import { GithubDeploymentsTable } from './GithubDeploymentsTable';
import { Box } from '@material-ui/core';
jest.mock('@backstage/plugin-catalog-react', () => ({
useEntity: () => {
@@ -173,12 +178,16 @@ describe('github-deployments', () => {
return parsedPayload?.target || 'unknown';
};
const extraColumn = {
title: 'Target',
render: (row: GithubDeployment): JSX.Element => (
<Box>{renderTargetFromPayload(row.payload)}</Box>
),
};
const columns = [
...GithubDeploymentsTable.defaultDeploymentColumns,
GithubDeploymentsTable.columns.createPayloadColumn(
'Target',
renderTargetFromPayload,
),
extraColumn,
];
const rendered = await renderInTestApp(
@@ -88,13 +88,3 @@ export function createLastUpdatedColumn(): TableColumn<GithubDeployment> {
),
};
}
export function createCustomColumn(
title: string,
render: (payload: GithubDeployment) => JSX.Element,
): TableColumn<GithubDeployment> {
return {
title: title,
render: (deployment: GithubDeployment) => render(deployment),
};
}