[Forms] Fill in specs

Fill in specs for scripts which support the mct-form
and mct-control directives. WTD-530.
This commit is contained in:
Victor Woeltjen
2014-11-28 15:33:40 -08:00
parent 29c5a7aaba
commit 1bfc21270b
5 changed files with 161 additions and 5 deletions

View File

@ -6,6 +6,35 @@ define(
"use strict";
describe("The date-time directive", function () {
var mockScope,
controller;
beforeEach(function () {
mockScope = jasmine.createSpyObj("$scope", [ "$watch" ]);
controller = new DateTimeController(mockScope);
});
it("watches for changes in fields", function () {
["date", "hour", "min", "sec"].forEach(function (fieldName) {
expect(mockScope.$watch).toHaveBeenCalledWith(
"datetime." + fieldName,
jasmine.any(Function)
);
});
});
it("converts date-time input into a timestamp", function () {
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.ngModel.test).toEqual(1417215313000);
});
});
}