From 5f54542ef46f945f5339193afd475d2163a5d210 Mon Sep 17 00:00:00 2001 From: Remi Date: Sun, 15 Nov 2020 16:18:38 +0100 Subject: [PATCH] fix(core): LinearGauge tooltip + test --- .../ProgressBars/LinearGauge.test.tsx | 37 +++++++++++++++++++ .../components/ProgressBars/LinearGauge.tsx | 14 ++++--- 2 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 packages/core/src/components/ProgressBars/LinearGauge.test.tsx diff --git a/packages/core/src/components/ProgressBars/LinearGauge.test.tsx b/packages/core/src/components/ProgressBars/LinearGauge.test.tsx new file mode 100644 index 0000000000..fc04b642fb --- /dev/null +++ b/packages/core/src/components/ProgressBars/LinearGauge.test.tsx @@ -0,0 +1,37 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React from 'react'; +import { renderInTestApp } from '@backstage/test-utils'; + +import { LinearGauge } from './LinearGauge'; + +describe('', () => { + it('renders without exploding', async () => { + const { getByTitle } = await renderInTestApp(); + expect(getByTitle('50%')).toBeInTheDocument(); + }); + + it('renders progress and title', async () => { + const { container } = await renderInTestApp(); + expect(container).toBeEmptyDOMElement(); + }); + + it('renders with 100 as max value', async () => { + const { getByTitle } = await renderInTestApp(); + expect(getByTitle('100%')).toBeInTheDocument(); + }); +}); diff --git a/packages/core/src/components/ProgressBars/LinearGauge.tsx b/packages/core/src/components/ProgressBars/LinearGauge.tsx index 2b8e77838d..a6aea59f19 100644 --- a/packages/core/src/components/ProgressBars/LinearGauge.tsx +++ b/packages/core/src/components/ProgressBars/LinearGauge.tsx @@ -40,12 +40,14 @@ export const LinearGauge: FC = ({ value }) => { const strokeColor = getProgressColor(theme.palette, percent, false, 100); return ( - + + + ); };