'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _enzyme = require('enzyme');

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _ = require('../');

var _2 = _interopRequireDefault(_);

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

var buildWrapper = function buildWrapper(props) {
  return (0, _enzyme.shallow)(_react2.default.createElement(_2.default, _extends({
    controls: jest.fn().mockReturnValue(_react2.default.createElement(
      'div',
      null,
      'Test Controls'
    )),
    onChangeStep: jest.fn(),
    steps: ['Step 1', 'Step 2', 'Step 3']
  }, props)));
};

describe('WizardFooter', function () {
  it('should render wizard with given content', function () {
    expect(buildWrapper()).toMatchSnapshot();
  });

  it('should render the given step as the current step', function () {
    var wrapper = buildWrapper({ currentStep: 1 });
    expect(wrapper).toMatchSnapshot();
  });

  describe('when the current step changes', function () {
    var wrapper = void 0;

    beforeEach(function () {
      wrapper = buildWrapper();

      var _wrapper$instance = wrapper.instance(),
          controls = _wrapper$instance.props.controls;

      var onChangeStep = controls.mock.calls[0][0].onChangeStep;

      onChangeStep(1);
    });

    it('should call "onChangeStep" prop with the new step', function () {
      var _wrapper$instance2 = wrapper.instance(),
          onChangeStep = _wrapper$instance2.props.onChangeStep;

      expect(onChangeStep).toHaveBeenCalledWith(1);
    });
  });
});