From e80d094174069ef77d195ef91d0e2189f48152a5 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 27 Oct 2015 17:39:16 -0700 Subject: [PATCH] [Time Conductor] Add test cases ...to cover UTCTimeFormat. --- .../formats/test/UTCTimeFormatSpec.js | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/platform/commonUI/formats/test/UTCTimeFormatSpec.js b/platform/commonUI/formats/test/UTCTimeFormatSpec.js index 0f1efaddb3..57f84fed87 100644 --- a/platform/commonUI/formats/test/UTCTimeFormatSpec.js +++ b/platform/commonUI/formats/test/UTCTimeFormatSpec.js @@ -22,12 +22,35 @@ /*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( - ['../src/UTCTimeFormat'], - function (UTCTimeFormat) { + ['../src/UTCTimeFormat', 'moment'], + function (UTCTimeFormat, moment) { 'use strict'; describe("The UTCTimeFormat", function () { + var format; + beforeEach(function () { + format = new UTCTimeFormat(); + }); + + it("formats UTC timestamps", function () { + var timestamp = 12345670000, + formatted = format.format(timestamp); + expect(formatted).toEqual(jasmine.any(String)); + expect(moment.utc(formatted).valueOf()).toEqual(timestamp); + }); + + it("validates time inputs", function () { + expect(format.validate("1977-05-25 11:21:22")).toBeTruthy(); + expect(format.validate("garbage text")).toBeFalsy(); + }); + + it("parses valid input", function () { + var text = "1977-05-25 11:21:22", + parsed = format.parse(text); + expect(parsed).toEqual(jasmine.any(Number)); + expect(parsed).toEqual(moment.utc(text).valueOf()); + }); }); } );