|
|
@ -14,13 +14,13 @@ |
|
|
|
|
|
|
|
|
|
|
|
import { shallow } from 'enzyme'; |
|
|
|
import { shallow } from 'enzyme'; |
|
|
|
import React from 'react'; |
|
|
|
import React from 'react'; |
|
|
|
|
|
|
|
import { createTheme } from '@grafana/data'; |
|
|
|
|
|
|
|
|
|
|
|
import GraphTicks from './GraphTicks'; |
|
|
|
import GraphTicks from './GraphTicks'; |
|
|
|
import Scrubber from './Scrubber'; |
|
|
|
import Scrubber from './Scrubber'; |
|
|
|
import ViewingLayer, { dragTypes, getStyles } from './ViewingLayer'; |
|
|
|
import ViewingLayer, { dragTypes, getStyles } from './ViewingLayer'; |
|
|
|
import { EUpdateTypes } from '../../utils/DraggableManager'; |
|
|
|
import { EUpdateTypes } from '../../utils/DraggableManager'; |
|
|
|
import { polyfill as polyfillAnimationFrame } from '../../utils/test/requestAnimationFrame'; |
|
|
|
import { polyfill as polyfillAnimationFrame } from '../../utils/test/requestAnimationFrame'; |
|
|
|
import { defaultTheme } from '../../Theme'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getViewRange(viewStart, viewEnd) { |
|
|
|
function getViewRange(viewStart, viewEnd) { |
|
|
|
return { |
|
|
|
return { |
|
|
@ -45,7 +45,6 @@ describe('<SpanGraph>', () => { |
|
|
|
viewRange: getViewRange(0, 1), |
|
|
|
viewRange: getViewRange(0, 1), |
|
|
|
}; |
|
|
|
}; |
|
|
|
wrapper = shallow(<ViewingLayer {...props} />) |
|
|
|
wrapper = shallow(<ViewingLayer {...props} />) |
|
|
|
.dive() |
|
|
|
|
|
|
|
.dive() |
|
|
|
.dive() |
|
|
|
.dive(); |
|
|
|
.dive(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -54,7 +53,6 @@ describe('<SpanGraph>', () => { |
|
|
|
beforeEach(() => { |
|
|
|
beforeEach(() => { |
|
|
|
props = { ...props, viewRange: getViewRange(0.1, 0.9) }; |
|
|
|
props = { ...props, viewRange: getViewRange(0.1, 0.9) }; |
|
|
|
wrapper = shallow(<ViewingLayer {...props} />) |
|
|
|
wrapper = shallow(<ViewingLayer {...props} />) |
|
|
|
.dive() |
|
|
|
|
|
|
|
.dive() |
|
|
|
.dive() |
|
|
|
.dive(); |
|
|
|
.dive(); |
|
|
|
wrapper.instance()._setRoot({ |
|
|
|
wrapper.instance()._setRoot({ |
|
|
@ -130,7 +128,6 @@ describe('<SpanGraph>', () => { |
|
|
|
const time = { ...props.viewRange.time, reframe: { anchor } }; |
|
|
|
const time = { ...props.viewRange.time, reframe: { anchor } }; |
|
|
|
props = { ...props, viewRange: { time } }; |
|
|
|
props = { ...props, viewRange: { time } }; |
|
|
|
wrapper = shallow(<ViewingLayer {...props} />) |
|
|
|
wrapper = shallow(<ViewingLayer {...props} />) |
|
|
|
.dive() |
|
|
|
|
|
|
|
.dive() |
|
|
|
.dive() |
|
|
|
.dive(); |
|
|
|
.dive(); |
|
|
|
wrapper.instance()._handleReframeDragUpdate({ value }); |
|
|
|
wrapper.instance()._handleReframeDragUpdate({ value }); |
|
|
@ -160,7 +157,6 @@ describe('<SpanGraph>', () => { |
|
|
|
const time = { ...props.viewRange.time, reframe: { anchor } }; |
|
|
|
const time = { ...props.viewRange.time, reframe: { anchor } }; |
|
|
|
props = { ...props, viewRange: { time } }; |
|
|
|
props = { ...props, viewRange: { time } }; |
|
|
|
wrapper = shallow(<ViewingLayer {...props} />) |
|
|
|
wrapper = shallow(<ViewingLayer {...props} />) |
|
|
|
.dive() |
|
|
|
|
|
|
|
.dive() |
|
|
|
.dive() |
|
|
|
.dive(); |
|
|
|
.dive(); |
|
|
|
wrapper.instance()._handleReframeDragEnd({ manager, value }); |
|
|
|
wrapper.instance()._handleReframeDragEnd({ manager, value }); |
|
|
@ -176,7 +172,6 @@ describe('<SpanGraph>', () => { |
|
|
|
const time = { ...props.viewRange.time, reframe: { anchor } }; |
|
|
|
const time = { ...props.viewRange.time, reframe: { anchor } }; |
|
|
|
props = { ...props, viewRange: { time } }; |
|
|
|
props = { ...props, viewRange: { time } }; |
|
|
|
wrapper = shallow(<ViewingLayer {...props} />) |
|
|
|
wrapper = shallow(<ViewingLayer {...props} />) |
|
|
|
.dive() |
|
|
|
|
|
|
|
.dive() |
|
|
|
.dive() |
|
|
|
.dive(); |
|
|
|
.dive(); |
|
|
|
wrapper.instance()._handleReframeDragEnd({ manager, value }); |
|
|
|
wrapper.instance()._handleReframeDragEnd({ manager, value }); |
|
|
@ -274,28 +269,28 @@ describe('<SpanGraph>', () => { |
|
|
|
|
|
|
|
|
|
|
|
describe('.ViewingLayer--resetZoom', () => { |
|
|
|
describe('.ViewingLayer--resetZoom', () => { |
|
|
|
it('should not render .ViewingLayer--resetZoom if props.viewRange.time.current = [0,1]', () => { |
|
|
|
it('should not render .ViewingLayer--resetZoom if props.viewRange.time.current = [0,1]', () => { |
|
|
|
expect(wrapper.find(`.${getStyles(defaultTheme).ViewingLayerResetZoom}`).length).toBe(0); |
|
|
|
expect(wrapper.find(`.${getStyles(createTheme()).ViewingLayerResetZoom}`).length).toBe(0); |
|
|
|
wrapper.setProps({ viewRange: { time: { current: [0, 1] } } }); |
|
|
|
wrapper.setProps({ viewRange: { time: { current: [0, 1] } } }); |
|
|
|
expect(wrapper.find(`.${getStyles(defaultTheme).ViewingLayerResetZoom}`).length).toBe(0); |
|
|
|
expect(wrapper.find(`.${getStyles(createTheme()).ViewingLayerResetZoom}`).length).toBe(0); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should render ViewingLayer--resetZoom if props.viewRange.time.current[0] !== 0', () => { |
|
|
|
it('should render ViewingLayer--resetZoom if props.viewRange.time.current[0] !== 0', () => { |
|
|
|
// If the test fails on the following expect statement, this may be a false negative
|
|
|
|
// If the test fails on the following expect statement, this may be a false negative
|
|
|
|
expect(wrapper.find(`.${getStyles(defaultTheme).ViewingLayerResetZoom}`).length).toBe(0); |
|
|
|
expect(wrapper.find(`.${getStyles(createTheme()).ViewingLayerResetZoom}`).length).toBe(0); |
|
|
|
wrapper.setProps({ viewRange: { time: { current: [0.1, 1] } } }); |
|
|
|
wrapper.setProps({ viewRange: { time: { current: [0.1, 1] } } }); |
|
|
|
expect(wrapper.find(`.${getStyles(defaultTheme).ViewingLayerResetZoom}`).length).toBe(1); |
|
|
|
expect(wrapper.find(`.${getStyles(createTheme()).ViewingLayerResetZoom}`).length).toBe(1); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should render ViewingLayer--resetZoom if props.viewRange.time.current[1] !== 1', () => { |
|
|
|
it('should render ViewingLayer--resetZoom if props.viewRange.time.current[1] !== 1', () => { |
|
|
|
// If the test fails on the following expect statement, this may be a false negative
|
|
|
|
// If the test fails on the following expect statement, this may be a false negative
|
|
|
|
expect(wrapper.find(`.${getStyles(defaultTheme).ViewingLayerResetZoom}`).length).toBe(0); |
|
|
|
expect(wrapper.find(`.${getStyles(createTheme()).ViewingLayerResetZoom}`).length).toBe(0); |
|
|
|
wrapper.setProps({ viewRange: { time: { current: [0, 0.9] } } }); |
|
|
|
wrapper.setProps({ viewRange: { time: { current: [0, 0.9] } } }); |
|
|
|
expect(wrapper.find(`.${getStyles(defaultTheme).ViewingLayerResetZoom}`).length).toBe(1); |
|
|
|
expect(wrapper.find(`.${getStyles(createTheme()).ViewingLayerResetZoom}`).length).toBe(1); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should call props.updateViewRangeTime when clicked', () => { |
|
|
|
it('should call props.updateViewRangeTime when clicked', () => { |
|
|
|
wrapper.setProps({ viewRange: { time: { current: [0.1, 0.9] } } }); |
|
|
|
wrapper.setProps({ viewRange: { time: { current: [0.1, 0.9] } } }); |
|
|
|
const resetZoomButton = wrapper.find(`.${getStyles(defaultTheme).ViewingLayerResetZoom}`); |
|
|
|
const resetZoomButton = wrapper.find(`.${getStyles(createTheme()).ViewingLayerResetZoom}`); |
|
|
|
// If the test fails on the following expect statement, this may be a false negative caused
|
|
|
|
// If the test fails on the following expect statement, this may be a false negative caused
|
|
|
|
// by a regression to rendering.
|
|
|
|
// by a regression to rendering.
|
|
|
|
expect(resetZoomButton.length).toBe(1); |
|
|
|
expect(resetZoomButton.length).toBe(1); |
|
|
@ -313,11 +308,10 @@ describe('<SpanGraph>', () => { |
|
|
|
it('renders a filtering box if leftBound exists', () => { |
|
|
|
it('renders a filtering box if leftBound exists', () => { |
|
|
|
const _props = { ...props, viewRange: getViewRange(0.2, 1) }; |
|
|
|
const _props = { ...props, viewRange: getViewRange(0.2, 1) }; |
|
|
|
wrapper = shallow(<ViewingLayer {..._props} />) |
|
|
|
wrapper = shallow(<ViewingLayer {..._props} />) |
|
|
|
.dive() |
|
|
|
|
|
|
|
.dive() |
|
|
|
.dive() |
|
|
|
.dive(); |
|
|
|
.dive(); |
|
|
|
|
|
|
|
|
|
|
|
const leftBox = wrapper.find(`.${getStyles(defaultTheme).ViewingLayerInactive}`); |
|
|
|
const leftBox = wrapper.find(`.${getStyles(createTheme()).ViewingLayerInactive}`); |
|
|
|
expect(leftBox.length).toBe(1); |
|
|
|
expect(leftBox.length).toBe(1); |
|
|
|
const width = Number(leftBox.prop('width').slice(0, -1)); |
|
|
|
const width = Number(leftBox.prop('width').slice(0, -1)); |
|
|
|
const x = leftBox.prop('x'); |
|
|
|
const x = leftBox.prop('x'); |
|
|
@ -328,11 +322,10 @@ describe('<SpanGraph>', () => { |
|
|
|
it('renders a filtering box if rightBound exists', () => { |
|
|
|
it('renders a filtering box if rightBound exists', () => { |
|
|
|
const _props = { ...props, viewRange: getViewRange(0, 0.8) }; |
|
|
|
const _props = { ...props, viewRange: getViewRange(0, 0.8) }; |
|
|
|
wrapper = shallow(<ViewingLayer {..._props} />) |
|
|
|
wrapper = shallow(<ViewingLayer {..._props} />) |
|
|
|
.dive() |
|
|
|
|
|
|
|
.dive() |
|
|
|
.dive() |
|
|
|
.dive(); |
|
|
|
.dive(); |
|
|
|
|
|
|
|
|
|
|
|
const rightBox = wrapper.find(`.${getStyles(defaultTheme).ViewingLayerInactive}`); |
|
|
|
const rightBox = wrapper.find(`.${getStyles(createTheme()).ViewingLayerInactive}`); |
|
|
|
expect(rightBox.length).toBe(1); |
|
|
|
expect(rightBox.length).toBe(1); |
|
|
|
const width = Number(rightBox.prop('width').slice(0, -1)); |
|
|
|
const width = Number(rightBox.prop('width').slice(0, -1)); |
|
|
|
const x = Number(rightBox.prop('x').slice(0, -1)); |
|
|
|
const x = Number(rightBox.prop('x').slice(0, -1)); |
|
|
|