"use strict";

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

var _enzyme = require("enzyme");

var _CivicStoryCard = _interopRequireDefault(require("./CivicStoryCard"));

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

describe("CivicStoryCard", function () {
  var _title$slug = {
    title: "Test Story Card Title",
    slug: "card1"
  },
      title = _title$slug.title,
      slug = _title$slug.slug;
  describe("common properties", function () {
    var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_CivicStoryCard["default"], {
      slug: slug,
      title: title
    }));
    it("should render the title as an h2", function () {
      var h2 = wrapper.find("h2");
      expect(h2.text()).to.contain(title);
    });
    it("should include a StoryFooter that references this CivicStoryCard", function () {
      var footer = wrapper.find("StoryFooter");
      expect(footer.props().slug).to.equal(slug);
    });
  });
  describe("loading state", function () {
    var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_CivicStoryCard["default"], {
      loading: true
    }, _react["default"].createElement("h1", null, "blah")));
    it("should not render children", function () {
      expect(wrapper.find("h1").length).to.eql(0);
    });
  });
  describe("error state", function () {
    var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_CivicStoryCard["default"], {
      error: "Could not load data"
    }, _react["default"].createElement("h1", null, "blah")));
    it("should render loading message", function () {
      expect(wrapper.text().indexOf("Could not load data")).to.eql(0);
    });
    it("should not render children", function () {
      expect(wrapper.find("h1").length).to.eql(0);
    });
  });
});