"use strict";

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

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

var _enzyme = require("enzyme");

var _ = _interopRequireDefault(require("."));

describe('MetricsDateRange', function () {
  var node = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], null, "Hello, world."));
  it('displays the <MetricsDateRange> element', function () {
    expect(node.getDOMNode().classList).toContain('MetricsDateRange');
  });
  it('updates dates on click', function () {
    var $toggle = node.find('.Dropdown-toggle');
    var $optMonth = node.find('.MetricsDateRange-quickSet').at(1);
    $toggle.simulate('click');
    $optMonth.simulate('click');
    var text = node.find('.MetricsDateRange[type="button"]').first().text().trim();
    expect(text).toBe('week');
  });
  describe('paywalled MetricsDateRange', function () {
    var paywalledNode = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], {
      paywalled: true,
      timeAgo: 7
    }));
    it('should always initialize state to day if paywalled', function () {
      var text = paywalledNode.find('.MetricsDateRange[type="button"]').first().text().trim();
      expect(text).toBe('day');
    });
    it('should not allow state changes if paywalled', function () {
      var $toggle = paywalledNode.find('.Dropdown-toggle');
      var $optMonth = paywalledNode.find('.MetricsDateRange-quickSet--paywall').at(0);
      $toggle.simulate('click');
      $optMonth.simulate('click');
      var text = paywalledNode.find('.MetricsDateRange[type="button"]').first().text().trim();
      expect(text).toBe('day');
    });
  });
});