if a trace is not provided', () => {
- wrapper = shallow(
);
- expect(wrapper.matchesElement(
)).toBeTruthy();
+ it('returns an empty div if a trace is not provided', () => {
+ const { container } = render(
);
+ expect(container.firstChild).toBeEmptyDOMElement();
});
- it('passes the number of ticks to render to components', () => {
- const tickHeader = wrapper.find(TickLabels);
- const viewingLayer = wrapper.find(ViewingLayer);
- expect(tickHeader.prop('numTicks')).toBeGreaterThan(1);
- expect(viewingLayer.prop('numTicks')).toBeGreaterThan(1);
- expect(tickHeader.prop('numTicks')).toBe(viewingLayer.prop('numTicks'));
+ it('renders
with the correct numnber of ticks', async () => {
+ const tickLabelsDiv = screen.getByTestId('TickLabels');
+ expect(getAllByTestId(tickLabelsDiv, 'tick').length).toBe(TIMELINE_TICK_INTERVAL + 1);
});
- it('passes items to CanvasSpanGraph', () => {
- const canvasGraph = wrapper.find(CanvasSpanGraph).first();
- const items = trace?.spans.map((span) => ({
- valueOffset: span.relativeStartTime,
- valueWidth: span.duration,
- serviceName: span.process.serviceName,
- }));
- expect(canvasGraph.prop('items')).toEqual(items);
- });
-
- it('does not regenerate CanvasSpanGraph without new trace', () => {
- const canvasGraph = wrapper.find(CanvasSpanGraph).first();
- const items = canvasGraph.prop('items');
-
- wrapper.instance().forceUpdate();
-
- const newCanvasGraph = wrapper.find(CanvasSpanGraph).first();
- const newItems = newCanvasGraph.prop('items');
-
- expect(newItems).toBe(items);
+ it('renders
with the correct value next to each tick', () => {
+ render(
);
+ expect(screen.getByText(/0.2/)).toBeTruthy();
+ expect(screen.getByText(/0.4/)).toBeTruthy();
+ expect(screen.getByText(/0.6/)).toBeTruthy();
+ expect(screen.getByText(/0.8/)).toBeTruthy();
});
});
diff --git a/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/index.tsx b/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/index.tsx
index 8133aaaa8e9..3a1a0275e72 100644
--- a/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/index.tsx
+++ b/packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/index.tsx
@@ -25,7 +25,7 @@ import TickLabels from './TickLabels';
import ViewingLayer from './ViewingLayer';
const DEFAULT_HEIGHT = 60;
-const TIMELINE_TICK_INTERVAL = 4;
+export const TIMELINE_TICK_INTERVAL = 4;
export type SpanGraphProps = {
height?: number;