Skip to content

Commit f519cf0

Browse files
committed
Merge pull request swisnl#264 from swisnl/hotfix-fix-autoamted-tests
Small change to fix automated testing
2 parents fb2a75d + 9d52b63 commit f519cf0

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/unit/test-events.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var menuRuntime = null;
66
module('contextMenu events');
77

88
// before each test
9-
QUnit.testStart(function createContextMenu() {
9+
function createContextMenu() {
1010
var $fixture = $("#qunit-fixture");
1111

1212
// ensure `#qunit-fixture` exists when testing with karma runner
@@ -36,10 +36,10 @@ QUnit.testStart(function createContextMenu() {
3636
"paste": {name: "Paste", icon: "paste"}
3737
}
3838
});
39-
});
39+
};
4040

4141
// after each test
42-
QUnit.testDone(function destroyContextMenuAndCleanup() {
42+
function destroyContextMenuAndCleanup() {
4343
$.contextMenu( 'destroy' );
4444

4545
// clean up `#qunit-fixture` when testing in karma runner
@@ -53,7 +53,7 @@ QUnit.testDone(function destroyContextMenuAndCleanup() {
5353
menuCloseCounter = 0;
5454
itemSelectedCounter = 0;
5555
menuRuntime = null;
56-
});
56+
};
5757

5858

5959

@@ -64,19 +64,24 @@ test('$.contextMenu object exists', function() {
6464

6565

6666
test('open contextMenu', function() {
67+
createContextMenu();
6768
$(".context-menu").contextMenu();
6869
equal(menuOpenCounter, 1, 'contextMenu was opened once');
70+
destroyContextMenuAndCleanup();
6971
});
7072

7173

7274
test('close contextMenu', function() {
75+
createContextMenu();
7376
$(".context-menu").contextMenu();
7477
$(".context-menu").contextMenu("hide");
7578
equal(menuCloseCounter, 1, 'contextMenu was closed once');
79+
destroyContextMenuAndCleanup();
7680
});
7781

7882

7983
test('navigate contextMenu items', function() {
84+
createContextMenu();
8085
var itemWasFocused = 0;
8186
var itemWasBlurred = 0;
8287

@@ -97,13 +102,16 @@ test('navigate contextMenu items', function() {
97102
menuRuntime.$menu.trigger("nextcommand"); // triggers contextmenu:blur & contextmenu:focus
98103
equal(itemWasFocused, 1, 'first menu item was blurred');
99104
equal(itemWasBlurred, 1, 'second menu item was focused');
105+
destroyContextMenuAndCleanup();
100106
});
101107

102108

103109
test('activate contextMenu item', function() {
110+
createContextMenu();
104111
$(".context-menu").contextMenu();
105112
menuRuntime.$menu.trigger("nextcommand");
106113
menuRuntime.$selected.trigger('mouseup');
107114

108115
equal(itemSelectedCounter, 1, 'selected menu item was clicked once');
116+
destroyContextMenuAndCleanup();
109117
});

0 commit comments

Comments
 (0)