mirror of
https://github.com/nasa/openmct.git
synced 2025-05-21 17:57:39 +00:00
Merge remote-tracking branch 'github/master' into open1482c
Conflicts: platform/representation/src/actions/ContextMenuAction.js
This commit is contained in:
commit
f4ae86eb53
@ -31,7 +31,7 @@ define(
|
|||||||
|
|
||||||
var MENU_TEMPLATE = "<mct-representation key=\"'context-menu'\" " +
|
var MENU_TEMPLATE = "<mct-representation key=\"'context-menu'\" " +
|
||||||
"mct-object=\"domainObject\" " +
|
"mct-object=\"domainObject\" " +
|
||||||
"ng-class=\"menuClass\"" +
|
"ng-class=\"menuClass\" " +
|
||||||
"ng-style=\"menuStyle\">" +
|
"ng-style=\"menuStyle\">" +
|
||||||
"</mct-representation>",
|
"</mct-representation>",
|
||||||
dismissExistingMenu;
|
dismissExistingMenu;
|
||||||
@ -75,7 +75,7 @@ define(
|
|||||||
// Remove the context menu
|
// Remove the context menu
|
||||||
function dismiss() {
|
function dismiss() {
|
||||||
menu.remove();
|
menu.remove();
|
||||||
body.off("click", dismiss);
|
body.off("mousedown", dismiss);
|
||||||
dismissExistingMenu = undefined;
|
dismissExistingMenu = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ define(
|
|||||||
mockCompiledTemplate.andReturn(mockMenu);
|
mockCompiledTemplate.andReturn(mockMenu);
|
||||||
mockDocument.find.andReturn(mockBody);
|
mockDocument.find.andReturn(mockBody);
|
||||||
mockRootScope.$new.andReturn(mockScope);
|
mockRootScope.$new.andReturn(mockScope);
|
||||||
|
|
||||||
mockActionContext = {key: 'menu', domainObject: mockDomainObject, event: mockEvent};
|
mockActionContext = {key: 'menu', domainObject: mockDomainObject, event: mockEvent};
|
||||||
|
|
||||||
action = new ContextMenuAction(
|
action = new ContextMenuAction(
|
||||||
@ -118,9 +118,9 @@ define(
|
|||||||
it("removes a menu when body is clicked", function () {
|
it("removes a menu when body is clicked", function () {
|
||||||
// Show the menu
|
// Show the menu
|
||||||
action.perform();
|
action.perform();
|
||||||
|
|
||||||
// Verify precondition
|
// Verify precondition
|
||||||
expect(mockBody.off).not.toHaveBeenCalled();
|
expect(mockBody.remove).not.toHaveBeenCalled();
|
||||||
|
|
||||||
// Find and fire body's mousedown listener
|
// Find and fire body's mousedown listener
|
||||||
mockBody.on.calls.forEach(function (call) {
|
mockBody.on.calls.forEach(function (call) {
|
||||||
@ -133,8 +133,29 @@ define(
|
|||||||
expect(mockMenu.remove).toHaveBeenCalled();
|
expect(mockMenu.remove).toHaveBeenCalled();
|
||||||
|
|
||||||
// Listener should have been detached from body
|
// Listener should have been detached from body
|
||||||
expect(mockBody.off).toHaveBeenCalled();
|
expect(mockBody.off).toHaveBeenCalledWith(
|
||||||
|
'mousedown',
|
||||||
|
jasmine.any(Function)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("removes a menu when it is clicked", function () {
|
||||||
|
// Show the menu
|
||||||
|
action.perform();
|
||||||
|
|
||||||
|
// Verify precondition
|
||||||
|
expect(mockMenu.remove).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
// Find and fire body's mousedown listener
|
||||||
|
mockMenu.on.calls.forEach(function (call) {
|
||||||
|
if (call.args[0] === 'click') {
|
||||||
|
call.args[1]();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Menu should have been removed
|
||||||
|
expect(mockMenu.remove).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user