Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 316fc60

Browse files
committed
Add HTML version of removeMenu() and unit tests
1 parent 156a7e6 commit 316fc60

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

src/command/Menus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ define(function (require, exports, module) {
888888
}
889889

890890
if (_isHTMLMenu(id)) {
891-
console.log("**TO BE IMPLEMENTED**");
891+
$(_getHTMLMenu(id)).remove();
892892
} else {
893893
brackets.app.removeMenu(id, function (err) {
894894
if (err) {

test/spec/Menu-test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,45 @@ define(function (require, exports, module) {
619619
});
620620

621621

622+
describe("Remove Menu", function () {
623+
624+
function menuDOM(menuId) {
625+
return testWindow.$("#" + menuId);
626+
}
627+
628+
it("should add then remove new menu to menu bar with a menu id", function () {
629+
runs(function () {
630+
var menuId = "Menu-test";
631+
Menus.addMenu("Custom", menuId);
632+
var $menu = menuDOM(menuId);
633+
expect($menu.length).toBe(1);
634+
635+
Menus.removeMenu(menuId);
636+
$menu = menuDOM(menuId);
637+
expect($menu.length).toBe(0);
638+
});
639+
});
640+
641+
it("should gracefully handle someone trying to remove a menu that doesn't exist", function () {
642+
runs(function () {
643+
var menuId = "Menu-test";
644+
645+
Menus.removeMenu(menuId);
646+
expect(Menus).toBeTruthy(); // Verify that we got this far...
647+
});
648+
});
649+
650+
it("should gracefully handle someone trying to remove a menu without supply the id", function () {
651+
runs(function () {
652+
var menuId = "Menu-test";
653+
654+
Menus.removeMenu();
655+
expect(Menus).toBeTruthy(); // Verify that we got this far...
656+
});
657+
});
658+
});
659+
660+
622661
describe("Menu Item synchronizing", function () {
623662

624663
it("should have same state as command", function () {

0 commit comments

Comments
 (0)