monitor-list.test.jsx 2.1 KB

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