zipkin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From unknown ...@apache.org>
Subject [incubator-zipkin] 06/09: Add unit tests for MiniTimelineSlider
Date Thu, 09 May 2019 04:52:50 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 6bb92aec6a69a9e5712b7c019b51973485b5a3e8
Author: tacigar <ig.lhound@gmail.com>
AuthorDate: Thu May 9 12:51:29 2019 +0900

    Add unit tests for MiniTimelineSlider
---
 .../MiniTimeline/MiniTimelineSlider.test.js        | 53 ++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/zipkin-lens/src/components/MiniTimeline/MiniTimelineSlider.test.js b/zipkin-lens/src/components/MiniTimeline/MiniTimelineSlider.test.js
new file mode 100644
index 0000000..2e9fb25
--- /dev/null
+++ b/zipkin-lens/src/components/MiniTimeline/MiniTimelineSlider.test.js
@@ -0,0 +1,53 @@
+import React from 'react';
+import { shallow } from 'enzyme';
+import Slider from 'rc-slider';
+
+import MiniTimelineSlider from './MiniTimelineSlider';
+
+const { Range } = Slider;
+
+describe('<MiniTimelineSlider />', () => {
+  it('should change isDragging state before changing the range', () => {
+    const wrapper = shallow(
+      <MiniTimelineSlider
+        duration={10}
+        startTs={0}
+        endTs={10}
+        onStartAndEndTsChange={() => {}}
+      />,
+    );
+    wrapper.find(Range).prop('onBeforeChange')();
+    expect(wrapper.state('isDragging')).toEqual(true);
+  });
+
+  it('should change isDragging state after changing the range', () => {
+    const wrapper = shallow(
+      <MiniTimelineSlider
+        duration={10}
+        startTs={0}
+        endTs={10}
+        onStartAndEndTsChange={() => {}}
+      />,
+    );
+    wrapper.find(Range).prop('onBeforeChange')(); // isDragging === true
+    wrapper.find(Range).prop('onAfterChange')([2, 6]);
+    expect(wrapper.state('isDragging')).toEqual(false);
+  });
+
+  it('should call onStartAndEndTsChange after range change', () => {
+    const onStartAndEndTsChange = jest.fn();
+    const wrapper = shallow(
+      <MiniTimelineSlider
+        duration={10}
+        startTs={0}
+        endTs={10}
+        onStartAndEndTsChange={onStartAndEndTsChange}
+      />,
+    );
+    wrapper.find(Range).prop('onAfterChange')([2, 6]);
+    expect(onStartAndEndTsChange).toHaveBeenCalledWith(
+      2 / 10,
+      6 / 10,
+    );
+  });
+});


Mime
View raw message