From aa743710081bf3c444f4bb27d3e6463db86954d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Tue, 7 Jun 2022 17:40:04 +0200 Subject: [PATCH] Chore: Convert ReferenceLink.test.js to RTL (#50338) --- .betterer.results | 3 -- ...nceLink.test.js => ReferenceLink.test.tsx} | 33 +++++++++++++------ 2 files changed, 23 insertions(+), 13 deletions(-) rename packages/jaeger-ui-components/src/url/{ReferenceLink.test.js => ReferenceLink.test.tsx} (55%) diff --git a/.betterer.results b/.betterer.results index 4da356b24ab..4146be12bc7 100644 --- a/.betterer.results +++ b/.betterer.results @@ -92,9 +92,6 @@ exports[`no enzyme tests`] = { "packages/jaeger-ui-components/src/TraceTimelineViewer/index.test.js:276996587": [ [14, 19, 13, "RegExp match", "2409514259"] ], - "packages/jaeger-ui-components/src/url/ReferenceLink.test.js:261377050": [ - [14, 26, 13, "RegExp match", "2409514259"] - ], "public/app/core/components/PageActionBar/PageActionBar.test.tsx:1251504193": [ [0, 19, 13, "RegExp match", "2409514259"] ], diff --git a/packages/jaeger-ui-components/src/url/ReferenceLink.test.js b/packages/jaeger-ui-components/src/url/ReferenceLink.test.tsx similarity index 55% rename from packages/jaeger-ui-components/src/url/ReferenceLink.test.js rename to packages/jaeger-ui-components/src/url/ReferenceLink.test.tsx index 2d8e76a009b..cfc9fbc78ff 100644 --- a/packages/jaeger-ui-components/src/url/ReferenceLink.test.js +++ b/packages/jaeger-ui-components/src/url/ReferenceLink.test.tsx @@ -1,4 +1,4 @@ -// Copyright (c) 2019 The Jaeger Authors. +// Copyright (c) 2019 Uber Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,30 +12,43 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { shallow, mount } from 'enzyme'; +import { render, screen } from '@testing-library/react'; import React from 'react'; +import { LinkModel } from '@grafana/data'; + +import { TraceSpanReference } from '../types/trace'; + import ReferenceLink from './ReferenceLink'; describe(ReferenceLink, () => { const createFocusSpanLinkMock = jest.fn((traceId, spanId) => { - return { + const model: LinkModel = { href: `${traceId}-${spanId}`, + title: 'link', + origin: 'origin', + target: '_blank', }; + return model; }); - const ref = { + const ref: TraceSpanReference = { refType: 'FOLLOWS_FROM', traceID: 'trace1', spanID: 'span1', }; - describe('rendering', () => { - it('renders reference with correct href', () => { - const component = shallow(); - const link = component.find('a'); - expect(link.length).toBe(1); - expect(link.prop('href')).toBe('trace1-span1'); + describe('rendering', () => { + it('renders reference with correct href', async () => { + render( + + link + + ); + + const link = await screen.findByText('link'); + expect(link).toBeInTheDocument(); + expect(link).toHaveAttribute('href', 'trace1-span1'); }); }); });