From 6fb8abbbb66cf2049989e2fc60e3281a685a024d Mon Sep 17 00:00:00 2001 From: GitStart <1501599+gitstart@users.noreply.github.com> Date: Mon, 19 Sep 2022 13:02:33 +0100 Subject: [PATCH] Convert packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/TickLabels.test.js to RTL (#55284) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: gitstart Co-authored-by: Nitesh Singh Co-authored-by: Rafael Toledo <87545086+Toledodev@users.noreply.github.com> Co-authored-by: Murilo Amaral <87545137+MuriloAmarals@users.noreply.github.com> Co-authored-by: Matheus Benini Ferreira <88898100+MatheusBeniniF@users.noreply.github.com> Co-authored-by: Rubens Rafael <70234898+RubensRafael@users.noreply.github.com> Co-authored-by: Toledodev Co-authored-by: JĂșlio Piubello da Silva Cabral --- .betterer.results | 3 --- .../SpanGraph/TickLabels.test.js | 22 +++++++++---------- .../TracePageHeader/SpanGraph/TickLabels.tsx | 2 +- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.betterer.results b/.betterer.results index d881ab0ce7f..80e2045db11 100644 --- a/.betterer.results +++ b/.betterer.results @@ -23,9 +23,6 @@ exports[`no enzyme tests`] = { "packages/grafana-ui/src/slate-plugins/suggestions.test.tsx:2682912140": [ [0, 18, 13, "RegExp match", "2409514259"] ], - "packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/TickLabels.test.js:2931161174": [ - [14, 19, 13, "RegExp match", "2409514259"] - ], "packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/ViewingLayer.test.js:1676554632": [ [14, 19, 13, "RegExp match", "2409514259"] ], diff --git a/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/TickLabels.test.js b/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/TickLabels.test.js index 595b5da7586..31b8d3dd0bd 100644 --- a/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/TickLabels.test.js +++ b/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/TickLabels.test.js @@ -11,8 +11,7 @@ // 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 { shallow } from 'enzyme'; +import { render, screen } from '@testing-library/react'; import React from 'react'; import TickLabels from './TickLabels'; @@ -23,37 +22,36 @@ describe('', () => { duration: 5000, }; - let wrapper; let ticks; beforeEach(() => { - wrapper = shallow(); - ticks = wrapper.find('[data-test="tick"]'); + render(); + ticks = screen.getAllByTestId('tick'); }); it('renders the right number of ticks', () => { - expect(ticks.length).toBe(defaultProps.numTicks + 1); + expect(ticks).toHaveLength(defaultProps.numTicks + 1); }); it('places the first tick on the left', () => { - const firstTick = ticks.first(); - expect(firstTick.prop('style')).toEqual({ left: '0%' }); + const firstTick = ticks[0]; + expect(firstTick).toHaveStyle(`left: 0%;`); }); it('places the last tick on the right', () => { - const lastTick = ticks.last(); - expect(lastTick.prop('style')).toEqual({ right: '0%' }); + const lastTick = ticks[ticks.length - 1]; + expect(lastTick).toHaveStyle(`right: 0%;`); }); it('places middle ticks at proper intervals', () => { const positions = ['25%', '50%', '75%']; positions.forEach((pos, i) => { const tick = ticks.at(i + 1); - expect(tick.prop('style')).toEqual({ left: pos }); + expect(tick).toHaveStyle(`left: ${pos};`); }); }); it("doesn't explode if no trace is present", () => { - expect(() => shallow()).not.toThrow(); + expect(() => render()).not.toThrow(); }); }); diff --git a/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/TickLabels.tsx b/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/TickLabels.tsx index 6a81881a257..132efa0f9a1 100644 --- a/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/TickLabels.tsx +++ b/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/TickLabels.tsx @@ -50,7 +50,7 @@ export default function TickLabels(props: TickLabelsProps) { const portion = i / numTicks; const style = portion === 1 ? { right: '0%' } : { left: `${portion * 100}%` }; ticks.push( -
+
{formatDuration(duration * portion)}
);