From 28805cd55c9d8e0ba35225d07b2151cad6110462 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 3 Jun 2015 10:05:39 -0700 Subject: [PATCH] [Forms] Add test cases to DateTimeController Add test cases for behavioral changes to DateTimeController, added for WTD-1221. --- .../controllers/DateTimeControllerSpec.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/platform/forms/test/controllers/DateTimeControllerSpec.js b/platform/forms/test/controllers/DateTimeControllerSpec.js index e3e5c7b693..11c97ada07 100644 --- a/platform/forms/test/controllers/DateTimeControllerSpec.js +++ b/platform/forms/test/controllers/DateTimeControllerSpec.js @@ -57,6 +57,33 @@ define( expect(mockScope.ngModel.test).toEqual(1417215313000); }); + it("reports when form input is partially complete", function () { + // This is needed to flag the control's state as invalid + // when it is partially complete without having it treated + // as required. + mockScope.ngModel = {}; + mockScope.field = "test"; + mockScope.datetime.date = "2014-332"; + mockScope.datetime.hour = 22; + mockScope.datetime.min = 55; + // mockScope.datetime.sec = 13; + + mockScope.$watch.mostRecentCall.args[1](); + + expect(mockScope.partiallyComplete).toBeTruthy(); + }); + + it("reports 'undefined' for empty input", function () { + mockScope.ngModel = { test: 12345 }; + mockScope.field = "test"; + mockScope.$watch.mostRecentCall.args[1](); + // Clear all inputs + mockScope.datetime = {}; + mockScope.$watch.mostRecentCall.args[1](); + + // Should have cleared out the time stamp + expect(mockScope.ngModel.test).toBeUndefined(); + }); }); } ); \ No newline at end of file