mirror of
https://github.com/grafana/grafana.git
synced 2025-09-23 18:52:33 +08:00
Convert packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/TickLabels.test.js to RTL (#55284)
Co-authored-by: gitstart <gitstart@users.noreply.github.com> Co-authored-by: Nitesh Singh <nitesh.singh@gitstart.dev> 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 <rafael.toledo@engenharia.ufjf.br> Co-authored-by: Júlio Piubello da Silva Cabral <julio.piubello@gitstart.dev>
This commit is contained in:
@ -23,9 +23,6 @@ exports[`no enzyme tests`] = {
|
|||||||
"packages/grafana-ui/src/slate-plugins/suggestions.test.tsx:2682912140": [
|
"packages/grafana-ui/src/slate-plugins/suggestions.test.tsx:2682912140": [
|
||||||
[0, 18, 13, "RegExp match", "2409514259"]
|
[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": [
|
"packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/ViewingLayer.test.js:1676554632": [
|
||||||
[14, 19, 13, "RegExp match", "2409514259"]
|
[14, 19, 13, "RegExp match", "2409514259"]
|
||||||
],
|
],
|
||||||
|
@ -11,8 +11,7 @@
|
|||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
import { shallow } from 'enzyme';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import TickLabels from './TickLabels';
|
import TickLabels from './TickLabels';
|
||||||
@ -23,37 +22,36 @@ describe('<TickLabels>', () => {
|
|||||||
duration: 5000,
|
duration: 5000,
|
||||||
};
|
};
|
||||||
|
|
||||||
let wrapper;
|
|
||||||
let ticks;
|
let ticks;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
wrapper = shallow(<TickLabels {...defaultProps} />);
|
render(<TickLabels {...defaultProps} />);
|
||||||
ticks = wrapper.find('[data-test="tick"]');
|
ticks = screen.getAllByTestId('tick');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders the right number of ticks', () => {
|
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', () => {
|
it('places the first tick on the left', () => {
|
||||||
const firstTick = ticks.first();
|
const firstTick = ticks[0];
|
||||||
expect(firstTick.prop('style')).toEqual({ left: '0%' });
|
expect(firstTick).toHaveStyle(`left: 0%;`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('places the last tick on the right', () => {
|
it('places the last tick on the right', () => {
|
||||||
const lastTick = ticks.last();
|
const lastTick = ticks[ticks.length - 1];
|
||||||
expect(lastTick.prop('style')).toEqual({ right: '0%' });
|
expect(lastTick).toHaveStyle(`right: 0%;`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('places middle ticks at proper intervals', () => {
|
it('places middle ticks at proper intervals', () => {
|
||||||
const positions = ['25%', '50%', '75%'];
|
const positions = ['25%', '50%', '75%'];
|
||||||
positions.forEach((pos, i) => {
|
positions.forEach((pos, i) => {
|
||||||
const tick = ticks.at(i + 1);
|
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", () => {
|
it("doesn't explode if no trace is present", () => {
|
||||||
expect(() => shallow(<TickLabels {...defaultProps} trace={null} />)).not.toThrow();
|
expect(() => render(<TickLabels {...defaultProps} trace={null} />)).not.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -50,7 +50,7 @@ export default function TickLabels(props: TickLabelsProps) {
|
|||||||
const portion = i / numTicks;
|
const portion = i / numTicks;
|
||||||
const style = portion === 1 ? { right: '0%' } : { left: `${portion * 100}%` };
|
const style = portion === 1 ? { right: '0%' } : { left: `${portion * 100}%` };
|
||||||
ticks.push(
|
ticks.push(
|
||||||
<div key={portion} className={styles.TickLabelsLabel} style={style} data-test="tick">
|
<div key={portion} className={styles.TickLabelsLabel} style={style} data-testid="tick">
|
||||||
{formatDuration(duration * portion)}
|
{formatDuration(duration * portion)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user