"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _Loading = _interopRequireDefault(require("../Loading"));

var _enzyme = require("enzyme");

/**
 * Copyright IBM Corp. 2016, 2018
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */
describe('Loading', function () {
  describe('Renders as expected', function () {
    var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_Loading.default, {
      className: "extra-class"
    }));
    var overlay = wrapper.find('.wfp--loading-overlay');
    var loader = wrapper.find('.wfp--loading');
    var svg = loader.find('svg');
    it('should render with an overlay', function () {
      expect(overlay.length).toEqual(1);
    });
    it('should render with a loader', function () {
      expect(loader.length).toEqual(1);
    });
    it('shoud render an svg', function () {
      expect(svg.length).toEqual(1);
    });
    it('overlay has the expected class', function () {
      expect(overlay.hasClass('wfp--loading-overlay')).toEqual(true);
    });
    it('loader has the expected classes', function () {
      expect(loader.hasClass('wfp--loading')).toEqual(true);
    });
    it('svg has the correct class', function () {
      expect(svg.hasClass('wfp--loading__svg')).toEqual(true);
    });
    it('should add extra classes that are passed via className', function () {
      expect(loader.hasClass('extra-class')).toEqual(true);
    });
  });
  describe('Sets props and state as expected', function () {
    var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_Loading.default, {
      className: "extra-class"
    }));
    it('should remove and add wfp--loading--stop class', function () {
      wrapper.setProps({
        active: false
      });
      expect(wrapper.find('.wfp--loading').hasClass('wfp--loading--stop')).toEqual(true);
      wrapper.setProps({
        active: true
      });
      expect(wrapper.find('.wfp--loading').hasClass('wfp--loading--stop')).toEqual(false);
    });
    it('should not render overlay when withOverlay is set to false', function () {
      wrapper.setProps({
        withOverlay: false
      });
      var overlay = wrapper.find('.wfp--loading-overlay');
      expect(overlay.length).toEqual(0);
    });
  });
});