mirror of
https://github.com/nasa/openmct.git
synced 2025-06-12 20:28:14 +00:00
[Time Conductor] Add test cases
Add test cases to TimeRangeController; testing existing functionality in the context of nasa/openmctweb#151
This commit is contained in:
@ -26,6 +26,11 @@ define(
|
|||||||
function (TimeRangeController) {
|
function (TimeRangeController) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var SEC = 1000,
|
||||||
|
MIN = 60 * SEC,
|
||||||
|
HOUR = 60 * MIN,
|
||||||
|
DAY = 24 * HOUR;
|
||||||
|
|
||||||
describe("The TimeRangeController", function () {
|
describe("The TimeRangeController", function () {
|
||||||
var mockScope,
|
var mockScope,
|
||||||
mockNow,
|
mockNow,
|
||||||
@ -61,6 +66,65 @@ define(
|
|||||||
.toHaveBeenCalledWith("ngModel", jasmine.any(Function));
|
.toHaveBeenCalledWith("ngModel", jasmine.any(Function));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("when dragged", function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
mockScope.ngModel = {
|
||||||
|
outer: {
|
||||||
|
start: DAY * 1000,
|
||||||
|
end: DAY * 1001
|
||||||
|
},
|
||||||
|
inner: {
|
||||||
|
start: DAY * 1000 + HOUR * 3,
|
||||||
|
end: DAY * 1001 - HOUR * 3
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mockScope.spanWidth = 1000;
|
||||||
|
fireWatch("spanWidth", mockScope.spanWidth);
|
||||||
|
fireWatchCollection("ngModel", mockScope.ngModel);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("updates the start time for left drags", function () {
|
||||||
|
mockScope.startLeftDrag();
|
||||||
|
mockScope.leftDrag(250);
|
||||||
|
expect(mockScope.ngModel.inner.start)
|
||||||
|
.toEqual(DAY * 1000 + HOUR * 9);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("updates the end time for right drags", function () {
|
||||||
|
mockScope.startRightDrag();
|
||||||
|
mockScope.rightDrag(-250);
|
||||||
|
expect(mockScope.ngModel.inner.end)
|
||||||
|
.toEqual(DAY * 1000 + HOUR * 15);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("updates both start and end for middle drags", function () {
|
||||||
|
mockScope.startMiddleDrag();
|
||||||
|
mockScope.middleDrag(-125);
|
||||||
|
expect(mockScope.ngModel.inner).toEqual({
|
||||||
|
start: DAY * 1000,
|
||||||
|
end: DAY * 1000 + HOUR * 18
|
||||||
|
});
|
||||||
|
mockScope.middleDrag(250);
|
||||||
|
expect(mockScope.ngModel.inner).toEqual({
|
||||||
|
start: DAY * 1000 + HOUR * 6,
|
||||||
|
end: DAY * 1001
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
it("enforces a minimum inner span", function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it("enforces a minimum outer span", function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it("enforces a minimum inner span when outer span changes", function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user