javascript-time-ago
Version:
Localized relative date/time formatting
26 lines (25 loc) • 2.26 kB
JavaScript
;
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var _FullDateFormatter = _interopRequireWildcard(require("./FullDateFormatter.js"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) { "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); } return f; })(e, t); }
describe('FullDateFormatter', function () {
it('should format full date', function () {
var formatter = new _FullDateFormatter["default"]('en');
expect(formatter.format(new Date(Date.UTC(2000, 0, 1)))).to.equal('Saturday, January 1, 2000 at 3:00:00 AM');
});
it('should format full date (`locales` argument)', function () {
var formatter = new _FullDateFormatter["default"](['en', 'ru']);
expect(formatter.format(new Date(Date.UTC(2000, 0, 1)))).to.equal('Saturday, January 1, 2000 at 3:00:00 AM');
});
it('should format full date (timestamp)', function () {
var formatter = new _FullDateFormatter["default"]('en');
expect(formatter.format(Date.UTC(2000, 0, 1))).to.equal('Saturday, January 1, 2000 at 3:00:00 AM');
});
it('should fallback to non-`Intl` formatter', function () {
var formatter = new _FullDateFormatter.FallbackDateFormatter('en');
// The output depends on the user's time zone.
// Example when running in Moscow: "Sat Jan 01 2000 03:00:00 GMT+0300 (Moscow Standard Time)".
expect(formatter.format(new Date(Date.UTC(2000, 1, 1)))).to.include(':00:00 GMT');
});
});
//# sourceMappingURL=FullDateFormatter.test.js.map