mirror of
https://github.com/nasa/openmct.git
synced 2025-01-21 03:55:31 +00:00
[Time Conductor] Test choices via picker
...to ensure that they trigger blur events. Also, test changes via text entry to ensure that they don't (the template is responsible for this.)
This commit is contained in:
parent
7d4e7a0925
commit
271b5d1a73
@ -71,8 +71,8 @@ define(
|
||||
if (value !== $scope.ngModel[$scope.field]) {
|
||||
$scope.ngModel[$scope.field] = value;
|
||||
updateFromModel(value);
|
||||
if ($scope.structure && $scope.structure.submit) {
|
||||
$scope.structure.submit();
|
||||
if ($scope.ngBlur) {
|
||||
$scope.ngBlur();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,21 +67,13 @@ define(
|
||||
mockScope.ngModel = { testField: 12321 };
|
||||
mockScope.field = "testField";
|
||||
mockScope.structure = { format: "someFormat" };
|
||||
mockScope.ngBlur = jasmine.createSpy('blur');
|
||||
|
||||
controller = new DateTimeFieldController(
|
||||
mockScope,
|
||||
mockFormatService
|
||||
);
|
||||
});
|
||||
|
||||
it("updates models from user-entered text", function () {
|
||||
var newText = "1977-05-25 17:30:00";
|
||||
|
||||
mockScope.textValue = newText;
|
||||
fireWatch("textValue", newText);
|
||||
expect(mockScope.ngModel.testField)
|
||||
.toEqual(mockFormat.parse(newText));
|
||||
expect(mockScope.textInvalid).toBeFalsy();
|
||||
fireWatch("ngModel[field]", mockScope.ngModel.testField);
|
||||
});
|
||||
|
||||
it("updates text from model values", function () {
|
||||
@ -91,6 +83,44 @@ define(
|
||||
expect(mockScope.textValue).toEqual("1977-05-25 17:30:00");
|
||||
});
|
||||
|
||||
describe("when valid text is entered", function () {
|
||||
var newText;
|
||||
|
||||
beforeEach(function () {
|
||||
newText = "1977-05-25 17:30:00";
|
||||
mockScope.textValue = newText;
|
||||
fireWatch("textValue", newText);
|
||||
});
|
||||
|
||||
it("updates models from user-entered text", function () {
|
||||
expect(mockScope.ngModel.testField)
|
||||
.toEqual(mockFormat.parse(newText));
|
||||
expect(mockScope.textInvalid).toBeFalsy();
|
||||
});
|
||||
|
||||
it("does not indicate a blur event", function () {
|
||||
expect(mockScope.ngBlur).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when a date is chosen via the date picker", function () {
|
||||
var newValue;
|
||||
|
||||
beforeEach(function () {
|
||||
newValue = 12345654321;
|
||||
mockScope.pickerModel.value = newValue;
|
||||
fireWatch("pickerModel.value", newValue);
|
||||
});
|
||||
|
||||
it("updates models", function () {
|
||||
expect(mockScope.ngModel.testField).toEqual(newValue);
|
||||
});
|
||||
|
||||
it("fires a blur event", function () {
|
||||
expect(mockScope.ngBlur).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it("exposes toggle state for date-time picker", function () {
|
||||
expect(mockScope.picker.active).toBe(false);
|
||||
});
|
||||
@ -148,6 +178,10 @@ define(
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
describe("when values are changed via the date picker", function () {
|
||||
|
||||
});
|
||||
|
||||
describe("using the obtained format", function () {
|
||||
var testValue = 1234321,
|
||||
testText = "some text";
|
||||
|
Loading…
Reference in New Issue
Block a user