From 51d97b432cda29c22cc71e62f7695af155ff061f Mon Sep 17 00:00:00 2001 From: Niklas Granander Date: Thu, 8 Jul 2021 14:28:40 +0200 Subject: [PATCH] Test tooltip of cell Signed-off-by: Niklas Granander --- .../StatusMatrixComponent.test.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.test.tsx b/plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.test.tsx index 17532489a8..c5217b4fa9 100644 --- a/plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.test.tsx +++ b/plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.test.tsx @@ -14,20 +14,23 @@ * limitations under the License. */ import React from 'react'; -import { StatusMatrixComponent } from './StatusMatrixComponent'; import { renderInTestApp } from '@backstage/test-utils'; -import { XCMetricsApi, xcmetricsApiRef } from '../../api'; import { ApiProvider, ApiRegistry } from '@backstage/core-app-api'; +import userEvent from '@testing-library/user-event'; +import { StatusMatrixComponent } from './StatusMatrixComponent'; +import { XCMetricsApi, xcmetricsApiRef } from '../../api'; +import { formatStatus } from '../../utils'; describe('StatusMatrixComponent', () => { it('should render', async () => { + const mockStatus = 'succeeded'; const mockApi: jest.Mocked = { getBuilds: jest.fn().mockResolvedValue([ { id: 1, startTimestamp: '2020-11-02T16:38:40Z', duration: 123.45, - buildStatus: 'succeeded', + buildStatus: mockStatus, }, ]), }; @@ -38,6 +41,12 @@ describe('StatusMatrixComponent', () => { , ); - expect(rendered.getByTestId(1)).toBeInTheDocument(); + const cell = rendered.getByTestId(1); + expect(cell).toBeInTheDocument(); + + userEvent.hover(cell); + expect( + await rendered.findByText(formatStatus(mockStatus)), + ).toBeInTheDocument(); }); });