Spaces:
Running
Running
File size: 2,133 Bytes
f2bee8a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
import React from 'react';
import {mountWithIntl} from '../../helpers/intl-helpers.jsx';
import MonitorList from '../../../src/components/monitor-list/monitor-list.jsx';
import {OrderedMap} from 'immutable';
import configureStore from 'redux-mock-store';
import {Provider} from 'react-redux';
describe('MonitorListComponent', () => {
const store = configureStore()({scratchGui: {
monitorLayout: {
monitors: {},
savedMonitorPositions: {}
},
vm: {
runtime: {
requestUpdateMonitor: () => {},
getLabelForOpcode: () => ''
}
}
}});
const draggable = false;
const onMonitorChange = jest.fn();
const stageSize = {
width: 100,
height: 100,
widthDefault: 100,
heightDefault: 100
};
let monitors = OrderedMap({});
// Wrap this in a function so it gets test specific states and can be reused.
const getComponent = function () {
return (
<Provider store={store}>
<MonitorList
draggable={draggable}
monitors={monitors}
stageSize={stageSize}
onMonitorChange={onMonitorChange}
/>
</Provider>
);
};
test('it renders the correct step size for discrete sliders', () => {
monitors = OrderedMap({
id1: {
visible: true,
mode: 'slider',
isDiscrete: true
}
});
const wrapper = mountWithIntl(getComponent());
const input = wrapper.find('input');
expect(input.props().step).toBe(1);
});
test('it renders the correct step size for non-discrete sliders', () => {
monitors = OrderedMap({
id1: {
visible: true,
mode: 'slider',
isDiscrete: false
}
});
const wrapper = mountWithIntl(getComponent());
const input = wrapper.find('input');
expect(input.props().step).toBe(0.01);
});
});
|