mirror of
https://github.com/nasa/openmct.git
synced 2025-06-13 04:38:15 +00:00
[Timer] Fix regression in timer visual indication and add tests
This commit is contained in:
@ -52,9 +52,12 @@ define(
|
|||||||
self.textValue = formatter(timeDelta);
|
self.textValue = formatter(timeDelta);
|
||||||
self.signValue = timeDelta < 0 ? "-" :
|
self.signValue = timeDelta < 0 ? "-" :
|
||||||
timeDelta >= 1000 ? "+" : "";
|
timeDelta >= 1000 ? "+" : "";
|
||||||
|
self.signCssClass = timeDelta < 0 ? "icon-minus" :
|
||||||
|
timeDelta >= 1000 ? "icon-plus" : "";
|
||||||
} else {
|
} else {
|
||||||
self.textValue = "";
|
self.textValue = "";
|
||||||
self.signValue = "";
|
self.signValue = "";
|
||||||
|
self.signCssClass = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +218,15 @@ define(
|
|||||||
return this.signValue;
|
return this.signValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the sign (+ or -) of the current timer value, as
|
||||||
|
* a CSS class.
|
||||||
|
* @returns {string} sign of the current timer value
|
||||||
|
*/
|
||||||
|
TimerController.prototype.signClass = function () {
|
||||||
|
return this.signCssClass;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the text to display for the current timer value.
|
* Get the text to display for the current timer value.
|
||||||
* @returns {string} current timer value
|
* @returns {string} current timer value
|
||||||
|
@ -127,6 +127,7 @@ define(
|
|||||||
mockNow.andReturn(TEST_TIMESTAMP);
|
mockNow.andReturn(TEST_TIMESTAMP);
|
||||||
mockWindow.requestAnimationFrame.mostRecentCall.args[0]();
|
mockWindow.requestAnimationFrame.mostRecentCall.args[0]();
|
||||||
expect(controller.sign()).toEqual("");
|
expect(controller.sign()).toEqual("");
|
||||||
|
expect(controller.signClass()).toEqual("");
|
||||||
expect(controller.text()).toEqual("");
|
expect(controller.text()).toEqual("");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -139,16 +140,19 @@ define(
|
|||||||
mockNow.andReturn(TEST_TIMESTAMP + 121000);
|
mockNow.andReturn(TEST_TIMESTAMP + 121000);
|
||||||
mockWindow.requestAnimationFrame.mostRecentCall.args[0]();
|
mockWindow.requestAnimationFrame.mostRecentCall.args[0]();
|
||||||
expect(controller.sign()).toEqual("+");
|
expect(controller.sign()).toEqual("+");
|
||||||
|
expect(controller.signClass()).toEqual("icon-plus");
|
||||||
expect(controller.text()).toEqual("0D 00:02:01");
|
expect(controller.text()).toEqual("0D 00:02:01");
|
||||||
|
|
||||||
mockNow.andReturn(TEST_TIMESTAMP - 121000);
|
mockNow.andReturn(TEST_TIMESTAMP - 121000);
|
||||||
mockWindow.requestAnimationFrame.mostRecentCall.args[0]();
|
mockWindow.requestAnimationFrame.mostRecentCall.args[0]();
|
||||||
expect(controller.sign()).toEqual("-");
|
expect(controller.sign()).toEqual("-");
|
||||||
|
expect(controller.signClass()).toEqual("icon-minus");
|
||||||
expect(controller.text()).toEqual("0D 00:02:01");
|
expect(controller.text()).toEqual("0D 00:02:01");
|
||||||
|
|
||||||
mockNow.andReturn(TEST_TIMESTAMP);
|
mockNow.andReturn(TEST_TIMESTAMP);
|
||||||
mockWindow.requestAnimationFrame.mostRecentCall.args[0]();
|
mockWindow.requestAnimationFrame.mostRecentCall.args[0]();
|
||||||
expect(controller.sign()).toEqual("");
|
expect(controller.sign()).toEqual("");
|
||||||
|
expect(controller.signClass()).toEqual("");
|
||||||
expect(controller.text()).toEqual("0D 00:00:00");
|
expect(controller.text()).toEqual("0D 00:00:00");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user