From 5c1b280b27e085c0e285e24b8c42f112814993f1 Mon Sep 17 00:00:00 2001 From: Vanshika Date: Fri, 22 Dec 2023 17:46:10 +0530 Subject: [PATCH] test Signed-off-by: Vanshika --- .../src/pages/graph/QueryStatsView.test.tsx | 12 ++++++------ pkg/ui/react-app/src/pages/graph/QueryStatsView.tsx | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/ui/react-app/src/pages/graph/QueryStatsView.test.tsx b/pkg/ui/react-app/src/pages/graph/QueryStatsView.test.tsx index 3077687ecc..4df5fc37c3 100755 --- a/pkg/ui/react-app/src/pages/graph/QueryStatsView.test.tsx +++ b/pkg/ui/react-app/src/pages/graph/QueryStatsView.test.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { shallow } from 'enzyme'; +import { mount } from 'enzyme'; import QueryStatsView from './QueryStatsView'; describe('QueryStatsView', () => { @@ -10,11 +10,11 @@ describe('QueryStatsView', () => { resultSeries: 10000, traceID: 'e575f9d4eab63a90cdc3dc4ef1b8dda0', }; - const queryStatsView = shallow(); - expect(queryStatsView.prop('className')).toEqual('query-stats'); - expect(queryStatsView.children().prop('className')).toEqual('float-right'); - expect(queryStatsView.children().text()).toEqual( - `Load time: ${queryStatsProps.loadTime}ms   Resolution: ${queryStatsProps.resolution}s   Result series: ${queryStatsProps.resultSeries}   Trace ID: ${queryStatsProps.traceID}` + const queryStatsView = mount(); + expect(queryStatsView.find('.query-stats').prop('className')).toEqual('query-stats'); + expect(queryStatsView.find('.float-right').prop('className')).toEqual('float-right'); + expect(queryStatsView.find('.float-right').html()).toEqual( + `Load time: ${queryStatsProps.loadTime}ms   Resolution: ${queryStatsProps.resolution}s   Result series: ${queryStatsProps.resultSeries}   Trace ID: ${queryStatsProps.traceID}` ); }); }); diff --git a/pkg/ui/react-app/src/pages/graph/QueryStatsView.tsx b/pkg/ui/react-app/src/pages/graph/QueryStatsView.tsx index b64cf2f330..d3e9a7a5c4 100644 --- a/pkg/ui/react-app/src/pages/graph/QueryStatsView.tsx +++ b/pkg/ui/react-app/src/pages/graph/QueryStatsView.tsx @@ -10,7 +10,8 @@ export interface QueryStats { const QueryStatsView: FC = (props) => { const { loadTime, resolution, resultSeries, traceID } = props; const prev = `Load time: ${loadTime}ms   Resolution: ${resolution}s   Result series: ${resultSeries}`; - const str = traceID ? prev + `   TraceID: ${traceID}` : prev; + const str = traceID ? prev + `   Trace ID: ${traceID}` : prev; + return (