Skip to content

Commit

Permalink
Merge pull request #264 from swisnl/hotfix-fix-autoamted-tests
Browse files Browse the repository at this point in the history
Small change to fix automated testing
  • Loading branch information
bbrala committed Aug 18, 2015
2 parents fb2a75d + 9d52b63 commit f519cf0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/unit/test-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var menuRuntime = null;
module('contextMenu events');

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

// ensure `#qunit-fixture` exists when testing with karma runner
Expand Down Expand Up @@ -36,10 +36,10 @@ QUnit.testStart(function createContextMenu() {
"paste": {name: "Paste", icon: "paste"}
}
});
});
};

// after each test
QUnit.testDone(function destroyContextMenuAndCleanup() {
function destroyContextMenuAndCleanup() {
$.contextMenu( 'destroy' );

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



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


test('open contextMenu', function() {
createContextMenu();
$(".context-menu").contextMenu();
equal(menuOpenCounter, 1, 'contextMenu was opened once');
destroyContextMenuAndCleanup();
});


test('close contextMenu', function() {
createContextMenu();
$(".context-menu").contextMenu();
$(".context-menu").contextMenu("hide");
equal(menuCloseCounter, 1, 'contextMenu was closed once');
destroyContextMenuAndCleanup();
});


test('navigate contextMenu items', function() {
createContextMenu();
var itemWasFocused = 0;
var itemWasBlurred = 0;

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


test('activate contextMenu item', function() {
createContextMenu();
$(".context-menu").contextMenu();
menuRuntime.$menu.trigger("nextcommand");
menuRuntime.$selected.trigger('mouseup');

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

0 comments on commit f519cf0

Please sign in to comment.