"use strict";

var _twitter = _interopRequireDefault(require("./twitter"));

var _JavascriptTimeAgo = _interopRequireDefault(require("../JavascriptTimeAgo"));

var _gradation = require("../gradation");

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

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

describe('"twitter" style', function () {
  it('should fallback from "tiny" to "narrow" for Twitter style for autogenerated locales', function () {
    var timeAgo = new _JavascriptTimeAgo.default('de');
    timeAgo.format(Date.now() - 3 * 60 * 60 * 1000, 'twitter').should.equal('vor 3 Std.');
  });
  it('should format Twitter style relative time (English)', function () {
    var timeAgo = new _JavascriptTimeAgo.default('en');
    var now = new Date(2016, 3, 10, 22, 59).getTime();

    var elapsed = function elapsed(time) {
      return timeAgo.format(now - time * 1000, _objectSpread({
        now: now
      }, _twitter.default));
    };

    elapsed(0).should.equal('');
    elapsed(44.9).should.equal('');
    elapsed(45.1).should.equal('1m');
    elapsed(1.49 * 60).should.equal('1m');
    elapsed(1.51 * 60).should.equal('2m');
    elapsed(2.49 * 60).should.equal('2m');
    elapsed(2.51 * 60).should.equal('3m'); // …

    elapsed(59.49 * 60).should.equal('59m');
    elapsed(59.51 * 60).should.equal('1h');
    elapsed(1.49 * 60 * 60).should.equal('1h');
    elapsed(1.51 * 60 * 60).should.equal('2h');
    elapsed(2.49 * 60 * 60).should.equal('2h');
    elapsed(2.51 * 60 * 60).should.equal('3h'); // …

    elapsed(23.49 * 60 * 60).should.equal('23h');
    elapsed(_gradation.day + 2 * 60 + 60 * 60).should.equal('Apr 9'); // …
    // "month" is an approximation.

    elapsed(_gradation.month * 3).should.equal('Jan 10');
    elapsed(_gradation.month * 4).should.equal('Dec 11, 2015');
    elapsed(_gradation.year).should.equal('Apr 11, 2015'); // Test future dates.
    // "month" is an approximation.

    elapsed(-1 * _gradation.month * 8).should.equal('Dec 10');
    elapsed(-1 * _gradation.month * 9).should.equal('Jan 9, 2017');
  });
  it('should format Twitter style relative time (Russian)', function () {
    var timeAgo = new _JavascriptTimeAgo.default('ru');
    var now = new Date(2016, 3, 10, 22, 59).getTime();

    var elapsed = function elapsed(time) {
      return timeAgo.format(now - time * 1000, _objectSpread({
        now: now
      }, _twitter.default));
    };

    elapsed(45.1).should.equal('1м');
    elapsed(59.51 * 60).should.equal('1ч');
    elapsed(_gradation.day + 62 * 60).should.equal('9 апр.');
    elapsed(_gradation.year).should.equal('11 апр. 2015 г.');
  });
  it('should format Twitter style relative time (Korean)', function () {
    var timeAgo = new _JavascriptTimeAgo.default('ko');
    var now = new Date(2016, 3, 10, 22, 59).getTime();

    var elapsed = function elapsed(time) {
      return timeAgo.format(now - time * 1000, _objectSpread({
        now: now
      }, _twitter.default));
    };

    elapsed(45.1).should.equal('1분');
    elapsed(59.51 * 60).should.equal('1시간'); // elapsed(day + 62 * 60).should.equal('9 апр.')
    // elapsed(year).should.equal('11 апр. 2015 г.')
  });
});
//# sourceMappingURL=twitter.test.js.map