Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Convert ReferenceLink.test.js to RTL #50338

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .betterer.results
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
],
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👌

href: `${traceId}-${spanId}`,
title: 'link',
origin: 'origin',
target: '_blank',
};
return model;
});

const ref = {
const ref: TraceSpanReference = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👌

refType: 'FOLLOWS_FROM',
traceID: 'trace1',
spanID: 'span1',
};

describe('rendering', () => {
it('renders reference with correct href', () => {
const component = shallow(<ReferenceLink reference={ref} createFocusSpanLink={createFocusSpanLinkMock} />);
it('renders reference with correct href', async () => {
render(
<ReferenceLink reference={ref} createFocusSpanLink={createFocusSpanLinkMock}>
link
</ReferenceLink>
);

const link = component.find('a');
expect(link.length).toBe(1);
expect(link.prop('href')).toBe('trace1-span1');
const link = await screen.findByText('link');
expect(link).toBeInTheDocument();
expect(link).toHaveAttribute('href', 'trace1-span1');
});
});
});