mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 09:52:04 +00:00
[Style] Fix style bugs introduced in #1374
This commit is contained in:
parent
c2253f5010
commit
fe8398017c
@ -64,7 +64,8 @@ define(
|
|||||||
// input is asynchronous.
|
// input is asynchronous.
|
||||||
var deferred = this.$q.defer(),
|
var deferred = this.$q.defer(),
|
||||||
self = this,
|
self = this,
|
||||||
overlay;
|
overlay,
|
||||||
|
handleEscKeydown;
|
||||||
|
|
||||||
// Confirm function; this will be passed in to the
|
// Confirm function; this will be passed in to the
|
||||||
// overlay-dialog template and associated with a
|
// overlay-dialog template and associated with a
|
||||||
@ -84,11 +85,11 @@ define(
|
|||||||
self.dismissOverlay(overlay);
|
self.dismissOverlay(overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleEscKeydown(event){
|
handleEscKeydown = function (event) {
|
||||||
if (event.keyCode === 27) {
|
if (event.keyCode === 27) {
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Add confirm/cancel callbacks
|
// Add confirm/cancel callbacks
|
||||||
model.confirm = confirm;
|
model.confirm = confirm;
|
||||||
|
@ -62,10 +62,7 @@ define(
|
|||||||
"$document",
|
"$document",
|
||||||
["find"]
|
["find"]
|
||||||
);
|
);
|
||||||
mockBody = angular.element(document.createElement('body'));
|
mockBody = jasmine.createSpyObj('body', ['on', 'off']);
|
||||||
spyOn(mockBody, 'on').andCallThrough();
|
|
||||||
spyOn(mockBody, 'off').andCallThrough();
|
|
||||||
|
|
||||||
mockDocument.find.andReturn(mockBody);
|
mockDocument.find.andReturn(mockBody);
|
||||||
|
|
||||||
mockDeferred.promise = "mock promise";
|
mockDeferred.promise = "mock promise";
|
||||||
@ -144,35 +141,33 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("adds a keydown event listener to the body", function () {
|
it("adds a keydown event listener to the body", function () {
|
||||||
dialogService.getUserInput({}, {});
|
dialogService.getUserInput({}, {});
|
||||||
expect(mockDocument.find).toHaveBeenCalledWith("body");
|
expect(mockDocument.find).toHaveBeenCalledWith("body");
|
||||||
expect(mockBody.on).toHaveBeenCalledWith("keydown", jasmine.any(Function));
|
expect(mockBody.on).toHaveBeenCalledWith("keydown", jasmine.any(Function));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("destroys the event listener when the dialog is cancelled", function () {
|
it("destroys the event listener when the dialog is cancelled", function () {
|
||||||
dialogService.getUserInput({}, {});
|
dialogService.getUserInput({}, {});
|
||||||
mockOverlayService.createOverlay.mostRecentCall.args[1].cancel();
|
mockOverlayService.createOverlay.mostRecentCall.args[1].cancel();
|
||||||
expect(mockBody.off).toHaveBeenCalledWith("keydown", jasmine.any(Function));
|
expect(mockBody.off).toHaveBeenCalledWith("keydown", jasmine.any(Function));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("cancels the dialog when an escape keydown event is triggered", function () {
|
it("cancels the dialog when an escape keydown event is triggered", function () {
|
||||||
dialogService.getUserInput({}, {});
|
dialogService.getUserInput({}, {});
|
||||||
mockBody.triggerHandler({
|
mockBody.on.mostRecentCall.args[1]({
|
||||||
type: 'keydown',
|
keyCode: 27
|
||||||
keyCode: 27
|
});
|
||||||
});
|
expect(mockDeferred.reject).toHaveBeenCalled();
|
||||||
expect(mockDeferred.reject).toHaveBeenCalled();
|
expect(mockDeferred.resolve).not.toHaveBeenCalled();
|
||||||
expect(mockDeferred.resolve).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("ignores non escape keydown events", function () {
|
it("ignores non escape keydown events", function () {
|
||||||
dialogService.getUserInput({}, {});
|
dialogService.getUserInput({}, {});
|
||||||
mockBody.triggerHandler({
|
mockBody.on.mostRecentCall.args[1]({
|
||||||
type: 'keydown',
|
keyCode: 13
|
||||||
keyCode: 13
|
});
|
||||||
});
|
expect(mockDeferred.reject).not.toHaveBeenCalled();
|
||||||
expect(mockDeferred.reject).not.toHaveBeenCalled();
|
expect(mockDeferred.resolve).not.toHaveBeenCalled();
|
||||||
expect(mockDeferred.resolve).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("the blocking message dialog", function () {
|
describe("the blocking message dialog", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user