"use strict";

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

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

var _enzyme = require("enzyme");

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

describe("components/Avatar", function () {
  it("should render default when no imageUrl is passed", function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_index["default"], null));
    expect(component.find(".oui-avatar").length).toBe(1);
  });
  it("should render an image when imageUrl is specified", function () {
    var imageUrl = "https://parkseed.com/images/xxl/52081-pk-p1.jpg";
    var component = (0, _enzyme.render)(_react["default"].createElement(_index["default"], {
      imageUrl: imageUrl
    }));
    var containerStyle = component.find(".oui-avatar").prop("style");
    expect(containerStyle).toHaveProperty("background-image", "url(".concat(imageUrl, ")"));
  });
  it("should render small size when size is passed", function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_index["default"], {
      size: "small"
    }));
    expect(component.find(".oui-avatar--small").length).toBe(1);
  });
  it("should render emulating border when isEmulating is true", function () {
    var component = (0, _enzyme.mount)(_react["default"].createElement(_index["default"], {
      size: "small",
      isEmulating: true
    }));
    expect(component.find(".color-admin--border").length).toBe(1);
  });
  describe("when given a className", function () {
    it("appends it to the avatar element", function () {
      var component = (0, _enzyme.mount)(_react["default"].createElement(_index["default"], {
        className: "extra-class"
      }));
      expect(component.first().prop("className").includes("extra-class")).toBe(true);
    });
  });
  describe("when given an unknown prop", function () {
    it("passes it to the avatar element", function () {
      // @ts-ignore: `unknownProps` is not part of any typed interface and therefore a good test value.
      var component = (0, _enzyme.mount)(_react["default"].createElement(_index["default"], {
        unknownProp: "some value"
      }));
      expect(component.first()).toHaveProp({
        unknownProp: "some value"
      });
    });
  });
});