"use strict";

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

var _reactDom = _interopRequireDefault(require("react-dom"));

var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));

var _Button = _interopRequireDefault(require("@instructure/ui-buttons/lib/components/Button"));

var _IconPin = _interopRequireDefault(require("@instructure/ui-icons/lib/Line/IconPin"));

var _IconPin2 = _interopRequireDefault(require("@instructure/ui-icons/lib/Solid/IconPin"));

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

describe('Pin', function () {
  var pinSessionItemStub = sinon.stub();
  var props = {
    pinSessionItem: pinSessionItemStub,
    isPinned: true,
    position: 1
  };
  var testbed = createTestbed(_index.default, props);
  describe('pin', function () {
    var pinSessionItemStub = sinon.stub();
    afterEach(function () {
      pinSessionItemStub.resetHistory();
    });
    context('pinning the item', function () {
      it('calls pinSessionItem', function () {
        testbed.render({
          pinSessionItem: pinSessionItemStub
        });

        var pinBtn = _reactDom.default.findDOMNode(testbed.findChildByType(_Button.default));

        _testUtils.default.Simulate.click(pinBtn);

        expect(pinSessionItemStub.called).to.be.true();
      });
      it('stops the click from propagating', function () {
        testbed.render({
          pinSessionItem: pinSessionItemStub
        });
        var stopPropagationStub = sinon.stub();

        var pinBtn = _reactDom.default.findDOMNode(testbed.findChildByType(_Button.default));

        _testUtils.default.Simulate.click(pinBtn, {
          stopPropagation: stopPropagationStub
        });

        expect(stopPropagationStub.called).to.be.true();
      });
    });
    context('isPinned is true', function () {
      it('shows the line icon', function () {
        testbed.render({
          isPinned: true
        });
        var solidPin = testbed.findChildrenByType(_IconPin2.default)[0];
        expect(solidPin).not.to.be.undefined();
      });
    });
    context('isPinned is false', function () {
      it('shows the line icon', function () {
        testbed.render({
          isPinned: false
        });
        var emptyPin = testbed.findChildrenByType(_IconPin.default)[0];
        expect(emptyPin).not.to.be.undefined();
      });
    });
  });
  describe('a11y tests', function () {
    it('should meet a11y standards', function (done) {
      testbed.render();
      testbed.checkA11yStandards(done);
    });
  });
});