zipkin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From unknown ...@apache.org>
Subject [incubator-zipkin] 03/09: Add unit tests for MiniTimeline
Date Thu, 09 May 2019 04:52:47 GMT
This is an automated email from the ASF dual-hosted git repository.

(unknown) pushed a commit to branch mini-timeline
in repository https://gitbox.apache.org/repos/asf/incubator-zipkin.git

commit a2acd13f7b93a04f341dced4b62aa7ffc02c94b6
Author: tacigar <ig.lhound@gmail.com>
AuthorDate: Wed May 8 19:48:39 2019 +0900

    Add unit tests for MiniTimeline
---
 .../src/components/MiniTimeline/index.test.js      | 73 ++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/zipkin-lens/src/components/MiniTimeline/index.test.js b/zipkin-lens/src/components/MiniTimeline/index.test.js
new file mode 100644
index 0000000..b8da922
--- /dev/null
+++ b/zipkin-lens/src/components/MiniTimeline/index.test.js
@@ -0,0 +1,73 @@
+import React from 'react';
+import { shallow } from 'enzyme';
+
+import MiniTimeline from './index';
+
+describe('<MiniTimeline />', () => {
+  const commonProps = {
+    startTs: 0,
+    endTs: 10,
+    onStartAndEndTsChange: () => {},
+  };
+
+  const dummySpan = {
+    spanId: '1',
+    spanName: 'span',
+    parentId: '2',
+    childIds: [],
+    serviceName: 'service',
+    serviceNames: [],
+    timestamp: 0,
+    duration: 10,
+    durationStr: '10μs',
+    tags: [],
+    annotations: [],
+    errorType: 'none',
+    depth: 1,
+    width: 1,
+    left: 1,
+  };
+
+  it('should return null if the number of spans is less than 2', () => {
+    let props = {
+      ...commonProps,
+      traceSummary: {
+        traceId: '12345',
+        spans: [],
+        serviceNameAndSpanCounts: [],
+        duration: 10,
+        durationStr: '10μs',
+      },
+    };
+    let wrapper = shallow(<MiniTimeline {...props} />);
+    expect(wrapper.type()).toEqual(null);
+
+    props = {
+      ...commonProps,
+      traceSummary: {
+        traceId: '12345',
+        spans: [dummySpan],
+        serviceNameAndSpanCounts: [],
+        duration: 10,
+        durationStr: '10μs',
+      },
+    };
+    wrapper = shallow(<MiniTimeline {...props} />);
+    expect(wrapper.type()).toEqual(null);
+  });
+
+  it('should return mini timeline otherwise', () => {
+    const props = {
+      ...commonProps,
+      traceSummary: {
+        traceId: '12345',
+        spans: [dummySpan, dummySpan],
+        serviceNameAndSpanCounts: [],
+        duration: 10,
+        durationStr: '10μs',
+      },
+    };
+    const wrapper = shallow(<MiniTimeline {...props} />);
+    expect(wrapper.find('.mini-timeline').length).toBe(1);
+  });
+});


Mime
View raw message