mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-01 17:57:36 +08:00
This updates karma to 5.2.3, karma-coverage to the officially published version 2.0.3 (we were previously relying on a git commit) and karma-sourcemap-loader to 0.3.8. DISABLE_THIRD_PARTY_CHECK=Update Karma R=aerotwist@chromium.org Change-Id: Iaa365379d7c2c6eb9145b1507be1a0a3ae812359 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2527043 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Commit-Queue: Paul Lewis <aerotwist@chromium.org> Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Paul Lewis <aerotwist@chromium.org>
62 lines
2.0 KiB
JavaScript
62 lines
2.0 KiB
JavaScript
'use strict';
|
|
|
|
require('should');
|
|
|
|
var dateFormat = require('../lib');
|
|
|
|
function createFixedDate() {
|
|
return new Date(2010, 0, 11, 14, 31, 30, 5);
|
|
}
|
|
|
|
describe('date_format', function() {
|
|
var date = createFixedDate();
|
|
|
|
it('should default to now when a date is not provided', function() {
|
|
dateFormat.asString(dateFormat.DATETIME_FORMAT).should.not.be.empty();
|
|
});
|
|
|
|
it('should be usable directly without calling asString', function() {
|
|
dateFormat(dateFormat.DATETIME_FORMAT, date).should.eql('11 01 2010 14:31:30.005');
|
|
});
|
|
|
|
it('should format a date as string using a pattern', function() {
|
|
dateFormat.asString(dateFormat.DATETIME_FORMAT, date).should.eql('11 01 2010 14:31:30.005');
|
|
});
|
|
|
|
it('should default to the ISO8601 format', function() {
|
|
dateFormat.asString(date).should.eql('2010-01-11T14:31:30.005');
|
|
});
|
|
|
|
it('should provide a ISO8601 with timezone offset format', function() {
|
|
var tzDate = createFixedDate();
|
|
tzDate.getTimezoneOffset = function () {
|
|
return -660;
|
|
};
|
|
|
|
// when tz offset is in the pattern, the date should be in local time
|
|
dateFormat.asString(dateFormat.ISO8601_WITH_TZ_OFFSET_FORMAT, tzDate)
|
|
.should.eql('2010-01-11T14:31:30.005+1100');
|
|
|
|
tzDate = createFixedDate();
|
|
tzDate.getTimezoneOffset = function () {
|
|
return 120;
|
|
};
|
|
|
|
dateFormat.asString(dateFormat.ISO8601_WITH_TZ_OFFSET_FORMAT, tzDate)
|
|
.should.eql('2010-01-11T14:31:30.005-0200');
|
|
});
|
|
|
|
it('should provide a just-the-time format', function() {
|
|
dateFormat.asString(dateFormat.ABSOLUTETIME_FORMAT, date).should.eql('14:31:30.005');
|
|
});
|
|
|
|
it('should provide a custom format', function() {
|
|
var customDate = createFixedDate();
|
|
customDate.getTimezoneOffset = function () {
|
|
return 120;
|
|
};
|
|
|
|
dateFormat.asString('O.SSS.ss.mm.hh.dd.MM.yy', customDate).should.eql('-0200.005.30.31.14.11.01.10');
|
|
});
|
|
});
|