"use strict";

var _react = _interopRequireDefault(require("react"));

var _enzyme = _interopRequireWildcard(require("enzyme"));

var _enzymeAdapterReact = _interopRequireDefault(require("enzyme-adapter-react-16"));

var _index = require("../index");

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

_enzyme.default.configure({
  adapter: new _enzymeAdapterReact.default()
});

describe("PercentSlider", function () {
  describe("range input", function () {
    it("should render value with the in slider", function () {
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_index.PercentSlider, {
        value: 50,
        id: "test"
      }));
      expect(wrapper.find('input[type="range"][value="50"]')).toHaveLength(1);
      var sliderDisplay = wrapper.find('.percentage-display');
      expect(sliderDisplay.text()).toEqual("50");
    });
    it("should change value", function () {
      var setValue = jest.fn();
      var wrapper = (0, _enzyme.mount)(_react.default.createElement(_index.PercentSlider, {
        value: 0,
        onChange: setValue
      }));
      var rangeInput = wrapper.find('input[type="range"]');
      rangeInput.simulate('change', {
        target: {
          name: 'value',
          value: 70
        }
      });
      expect(setValue).lastCalledWith(70);
    });
  });
});