@@ -6,7 +6,7 @@ var menuRuntime = null;
6
6
module ( 'contextMenu events' ) ;
7
7
8
8
// before each test
9
- QUnit . testStart ( function createContextMenu ( ) {
9
+ function createContextMenu ( ) {
10
10
var $fixture = $ ( "#qunit-fixture" ) ;
11
11
12
12
// ensure `#qunit-fixture` exists when testing with karma runner
@@ -36,10 +36,10 @@ QUnit.testStart(function createContextMenu() {
36
36
"paste" : { name : "Paste" , icon : "paste" }
37
37
}
38
38
} ) ;
39
- } ) ;
39
+ } ;
40
40
41
41
// after each test
42
- QUnit . testDone ( function destroyContextMenuAndCleanup ( ) {
42
+ function destroyContextMenuAndCleanup ( ) {
43
43
$ . contextMenu ( 'destroy' ) ;
44
44
45
45
// clean up `#qunit-fixture` when testing in karma runner
@@ -53,7 +53,7 @@ QUnit.testDone(function destroyContextMenuAndCleanup() {
53
53
menuCloseCounter = 0 ;
54
54
itemSelectedCounter = 0 ;
55
55
menuRuntime = null ;
56
- } ) ;
56
+ } ;
57
57
58
58
59
59
@@ -64,19 +64,24 @@ test('$.contextMenu object exists', function() {
64
64
65
65
66
66
test ( 'open contextMenu' , function ( ) {
67
+ createContextMenu ( ) ;
67
68
$ ( ".context-menu" ) . contextMenu ( ) ;
68
69
equal ( menuOpenCounter , 1 , 'contextMenu was opened once' ) ;
70
+ destroyContextMenuAndCleanup ( ) ;
69
71
} ) ;
70
72
71
73
72
74
test ( 'close contextMenu' , function ( ) {
75
+ createContextMenu ( ) ;
73
76
$ ( ".context-menu" ) . contextMenu ( ) ;
74
77
$ ( ".context-menu" ) . contextMenu ( "hide" ) ;
75
78
equal ( menuCloseCounter , 1 , 'contextMenu was closed once' ) ;
79
+ destroyContextMenuAndCleanup ( ) ;
76
80
} ) ;
77
81
78
82
79
83
test ( 'navigate contextMenu items' , function ( ) {
84
+ createContextMenu ( ) ;
80
85
var itemWasFocused = 0 ;
81
86
var itemWasBlurred = 0 ;
82
87
@@ -97,13 +102,16 @@ test('navigate contextMenu items', function() {
97
102
menuRuntime . $menu . trigger ( "nextcommand" ) ; // triggers contextmenu:blur & contextmenu:focus
98
103
equal ( itemWasFocused , 1 , 'first menu item was blurred' ) ;
99
104
equal ( itemWasBlurred , 1 , 'second menu item was focused' ) ;
105
+ destroyContextMenuAndCleanup ( ) ;
100
106
} ) ;
101
107
102
108
103
109
test ( 'activate contextMenu item' , function ( ) {
110
+ createContextMenu ( ) ;
104
111
$ ( ".context-menu" ) . contextMenu ( ) ;
105
112
menuRuntime . $menu . trigger ( "nextcommand" ) ;
106
113
menuRuntime . $selected . trigger ( 'mouseup' ) ;
107
114
108
115
equal ( itemSelectedCounter , 1 , 'selected menu item was clicked once' ) ;
116
+ destroyContextMenuAndCleanup ( ) ;
109
117
} ) ;
0 commit comments