"use strict";

var React = _interopRequireWildcard(require("react"));

var _enzyme = require("enzyme");

var _progressSteps = _interopRequireDefault(require("../progress-steps.js"));

var _step = _interopRequireDefault(require("../step.js"));

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

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; } }

/*
Copyright (c) 2018 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
var example;
describe('ProgressSteps', function () {
  beforeEach(function () {
    var steps = [];

    for (var x = 0; x < 5; x++) {
      steps.push(React.createElement(_step.default, {
        key: x
      }, "Step ", x));
    }

    example = (0, _enzyme.shallow)(React.createElement(_progressSteps.default, {
      current: 3
    }, steps));
  });
  it('applies isLast prop to child if element is last child', function () {
    example.children().forEach(function (element, index) {
      var isLast = index === 4;
      expect(element).toHaveProp('isLast', isLast);
    });
  });
  it('applies isCompleted prop to child if element is rendered before the provided index', function () {
    example.children().forEach(function (element, index) {
      var isCompleted = index === 0 || index === 1 || index === 2;
      expect(element).toHaveProp('isCompleted', isCompleted);
    });
  });
  it('applies isActive prop to child if element is rendered at the provided index', function () {
    example.children().forEach(function (element, index) {
      var isActive = index === 3;
      expect(element).toHaveProp('isActive', isActive);
    });
  });
  it('applies step prop to child for the current index', function () {
    example.children().forEach(function (element, index) {
      var step = index + 1;
      expect(element).toHaveProp('step', step);
    });
  });
});