From c34bbd3aa2b5a6af02416b353da8f82bbe09646e Mon Sep 17 00:00:00 2001 From: Joe Farro Date: Sun, 20 Aug 2017 05:43:28 -0400 Subject: [PATCH] WIP refactor trace, test maintenance --- src/components/App/index.test.js | 28 +++++++++++++++++++ .../DependencyGraph}/index.test.js | 17 ++++------- src/selectors/trace.test.js | 14 ++++------ 3 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 src/components/App/index.test.js rename src/{ => components/DependencyGraph}/index.test.js (64%) diff --git a/src/components/App/index.test.js b/src/components/App/index.test.js new file mode 100644 index 0000000000..622381b6e0 --- /dev/null +++ b/src/components/App/index.test.js @@ -0,0 +1,28 @@ +// Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import React from 'react'; +import { shallow } from 'enzyme'; + +import JaegerUIApp from './index'; + +it('JaegerUIApp does not explode', () => { + shallow(); +}); diff --git a/src/index.test.js b/src/components/DependencyGraph/index.test.js similarity index 64% rename from src/index.test.js rename to src/components/DependencyGraph/index.test.js index 6942e5b531..25047c9c9a 100644 --- a/src/index.test.js +++ b/src/components/DependencyGraph/index.test.js @@ -18,18 +18,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -import JaegerUIApp, { TracePage, SearchTracePage } from './index'; +import React from 'react'; +import { shallow } from 'enzyme'; -/* eslint-disable global-require, import/newline-after-import */ -it('JaegerUIApp should be exported as default', () => { - expect(JaegerUIApp).toBe(require('../src/components/App').default); -}); - -it('TracePage should be exported as as a named export', () => { - expect(TracePage).toBe(require('../src/components/TracePage').default); -}); +import DependencyGraphPage from './index'; -it('SearchTracePage should be exported as a named export', () => { - expect(SearchTracePage).toBe(require('../src/components/SearchTracePage').SearchTracePage); +it('DependencyGraphPage does not explode', () => { + shallow( {}} />); }); -/* eslint-enable global-require, import/newline-after-import */ diff --git a/src/selectors/trace.test.js b/src/selectors/trace.test.js index ea7aa0c9e4..8ab65ea37c 100644 --- a/src/selectors/trace.test.js +++ b/src/selectors/trace.test.js @@ -18,6 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +import _values from 'lodash/values'; import setsEqual from 'sets-equal'; import traceGenerator from '../../src/demo/trace-generators'; @@ -158,15 +159,10 @@ it('getSpanDepthForTrace() should determine the depth of a given span in the par }); it('getTraceServices() should return an unique array of all services in the trace', () => { - expect( - setsEqual( - new Set(traceSelectors.getTraceServices(generatedTrace)), - generatedTrace.spans.reduce( - (results, { processID }) => results.add(generatedTrace.processes[processID].serviceName), - new Set() - ) - ) - ).toBeTruthy(); + const svcs = [...traceSelectors.getTraceServices(generatedTrace)].sort(); + const set = new Set(_values(generatedTrace.processes).map(v => v.serviceName)); + const setSvcs = [...set.values()].sort(); + expect(svcs).toEqual(setSvcs); }); it('getTraceServiceCount() should return the length of the service list', () => {