From 487647524ae656d0fb288548ca267a7a1d7e79b4 Mon Sep 17 00:00:00 2001 From: Andrew Tran Date: Mon, 29 Nov 2021 11:17:57 -0600 Subject: [PATCH] update PodsTable tests Signed-off-by: Andrew Tran --- .../src/components/Pods/PodsTable.test.tsx | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/plugins/kubernetes/src/components/Pods/PodsTable.test.tsx b/plugins/kubernetes/src/components/Pods/PodsTable.test.tsx index 7c6c7e97f7..868b74bbc9 100644 --- a/plugins/kubernetes/src/components/Pods/PodsTable.test.tsx +++ b/plugins/kubernetes/src/components/Pods/PodsTable.test.tsx @@ -18,8 +18,25 @@ import React from 'react'; import { render } from '@testing-library/react'; import * as pod from './__fixtures__/pod.json'; import * as crashingPod from './__fixtures__/crashing-pod.json'; +import { TableColumn } from '@backstage/core-components'; import { wrapInTestApp } from '@backstage/test-utils'; +import { V1Pod } from '@kubernetes/client-node'; import { PodsTable } from './PodsTable'; +import { containersReady, totalRestarts } from '../../utils/pod'; + +const extraColumns: TableColumn[] = [ + { + title: 'containers ready', + align: 'center', + render: containersReady, + }, + { + title: 'total restarts', + align: 'center', + render: totalRestarts, + type: 'numeric', + }, +]; describe('PodsTable', () => { it('should render pod', async () => { @@ -27,6 +44,24 @@ describe('PodsTable', () => { wrapInTestApp(), ); + // titles + expect(getByText('name')).toBeInTheDocument(); + expect(getByText('phase')).toBeInTheDocument(); + expect(getByText('status')).toBeInTheDocument(); + + // values + expect(getByText('dice-roller-6c8646bfd-2m5hv')).toBeInTheDocument(); + expect(getByText('Running')).toBeInTheDocument(); + expect(getByText('OK')).toBeInTheDocument(); + }); + + it('should render pod with extra columns', async () => { + const { getByText } = render( + wrapInTestApp( + , + ), + ); + // titles expect(getByText('name')).toBeInTheDocument(); expect(getByText('phase')).toBeInTheDocument(); @@ -41,9 +76,12 @@ describe('PodsTable', () => { expect(getByText('0')).toBeInTheDocument(); expect(getByText('OK')).toBeInTheDocument(); }); - it('should render crashing pod', async () => { + + it('should render crashing pod with extra columns', async () => { const { getByText, getAllByText } = render( - wrapInTestApp(), + wrapInTestApp( + , + ), ); // titles