|
@@ -1,13 +1,19 @@
|
|
|
import React from 'react';
|
|
import React from 'react';
|
|
|
import { shallow } from 'enzyme';
|
|
import { shallow } from 'enzyme';
|
|
|
import Thresholds from './Thresholds';
|
|
import Thresholds from './Thresholds';
|
|
|
-import { OptionsProps } from './module';
|
|
|
|
|
|
|
+import { defaultProps, OptionsProps } from './module';
|
|
|
import { PanelOptionsProps } from '../../../types';
|
|
import { PanelOptionsProps } from '../../../types';
|
|
|
|
|
|
|
|
const setup = (propOverrides?: object) => {
|
|
const setup = (propOverrides?: object) => {
|
|
|
const props: PanelOptionsProps<OptionsProps> = {
|
|
const props: PanelOptionsProps<OptionsProps> = {
|
|
|
onChange: jest.fn(),
|
|
onChange: jest.fn(),
|
|
|
- options: {} as OptionsProps,
|
|
|
|
|
|
|
+ options: {
|
|
|
|
|
+ ...defaultProps.options,
|
|
|
|
|
+ thresholds: [
|
|
|
|
|
+ { index: 0, label: 'Min', value: 0, canRemove: false, color: 'rgba(50, 172, 45, 0.97)' },
|
|
|
|
|
+ { index: 1, label: 'Max', value: 100, canRemove: false },
|
|
|
|
|
+ ],
|
|
|
|
|
+ },
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
Object.assign(props, propOverrides);
|
|
Object.assign(props, propOverrides);
|
|
@@ -15,12 +21,6 @@ const setup = (propOverrides?: object) => {
|
|
|
return shallow(<Thresholds {...props} />).instance() as Thresholds;
|
|
return shallow(<Thresholds {...props} />).instance() as Thresholds;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const thresholds = [
|
|
|
|
|
- { index: 0, label: 'Min', value: 0, canRemove: false, color: 'rgba(50, 172, 45, 0.97)' },
|
|
|
|
|
- { index: 1, label: '', value: 50, canRemove: true, color: 'rgba(237, 129, 40, 0.89)' },
|
|
|
|
|
- { index: 2, label: 'Max', value: 100, canRemove: false },
|
|
|
|
|
-];
|
|
|
|
|
-
|
|
|
|
|
describe('Add threshold', () => {
|
|
describe('Add threshold', () => {
|
|
|
it('should add threshold between min and max', () => {
|
|
it('should add threshold between min and max', () => {
|
|
|
const instance = setup();
|
|
const instance = setup();
|
|
@@ -36,7 +36,14 @@ describe('Add threshold', () => {
|
|
|
|
|
|
|
|
it('should add threshold between min and added threshold', () => {
|
|
it('should add threshold between min and added threshold', () => {
|
|
|
const instance = setup({
|
|
const instance = setup({
|
|
|
- options: { thresholds: thresholds },
|
|
|
|
|
|
|
+ options: {
|
|
|
|
|
+ ...defaultProps.options,
|
|
|
|
|
+ thresholds: [
|
|
|
|
|
+ { index: 0, label: 'Min', value: 0, canRemove: false, color: 'rgba(50, 172, 45, 0.97)' },
|
|
|
|
|
+ { index: 1, label: '', value: 50, canRemove: true, color: 'rgba(237, 129, 40, 0.89)' },
|
|
|
|
|
+ { index: 2, label: 'Max', value: 100, canRemove: false },
|
|
|
|
|
+ ],
|
|
|
|
|
+ },
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
instance.onAddThreshold(1);
|
|
instance.onAddThreshold(1);
|