From 2296e943d7ed90a1eeba8733cbd3100c6ac7561f Mon Sep 17 00:00:00 2001 From: Jev Zelenkov Date: Sat, 8 Nov 2014 00:38:19 +0100 Subject: [PATCH] adding even more integration tests --- demo/custom-command_test.html | 169 +++++++++++++++++++++++++++++ test/integration/custom-command.js | 42 +++++++ test/integration/input.js | 39 +++++++ 3 files changed, 250 insertions(+) create mode 100755 demo/custom-command_test.html create mode 100644 test/integration/custom-command.js create mode 100644 test/integration/input.js diff --git a/demo/custom-command_test.html b/demo/custom-command_test.html new file mode 100755 index 00000000..fc7c204b --- /dev/null +++ b/demo/custom-command_test.html @@ -0,0 +1,169 @@ + + + + + + Custom Command Types Demo - jQuery contextMenu Plugin + + + + + + + + + + + + + + + + Fork me on GitHub +
+

jQuery contextMenu

+ + + +

Demo: Custom Command Types

+

jQuery.contextMenu allows you to create your own <comand>s and leverage the simple UI handling.

+
+ +
+ +

Example code: Custom Command Types

+ + +

Example CSS: Custom Command Types

+ + +

Example HTML: Custom Command Types

+ + +

jQuery Context Menu Demo Gallery

+ +
+
+ + \ No newline at end of file diff --git a/test/integration/custom-command.js b/test/integration/custom-command.js new file mode 100644 index 00000000..b4d2dbc6 --- /dev/null +++ b/test/integration/custom-command.js @@ -0,0 +1,42 @@ +var pwd = process.cwd(); +var helper = require('../integration_test_helper.js'); + +// this test uses custom HTML because PhantomJS +// has problems showing alert modal dialogs. +// We are testing callbacks against simple DOM +// manipulations instead. +module.exports = { + 'Click custom comand menu item triggers menu callback': function (test) { + test + .open('file://' + pwd + '/demo/custom-command_test.html') + .execute(helper.rightClick, '.context-menu-custom') + .waitForElement('#context-menu-layer') + .assert.numberOfElements('.context-menu-root>li') + .is(3, '3 context menu items are shown') + .click('.context-menu-root li.labels') + .assert.text('#msg').to.contain('clicked: label', 'contextMenu callback was triggered') + .done(); + }, + + 'Click custom comand menu item label triggers custom action - red': function (test) { + test + .open('file://' + pwd + '/demo/custom-command_test.html') + .execute(helper.rightClick, '.context-menu-custom') + .waitForElement('#context-menu-layer') + .wait(100) + .click('.context-menu-root li.labels .label1') + .assert.text('#msg', 'clicked: label | text: label 1', 'custom action was triggered') + .done(); + }, + + 'Click custom comand menu item label triggers custom action - blue': function (test) { + test + .open('file://' + pwd + '/demo/custom-command_test.html') + .execute(helper.rightClick, '.context-menu-custom') + .waitForElement('#context-menu-layer') + .wait(100) + .click('.context-menu-root li.labels .label3') + .assert.text('#msg', 'clicked: label | text: label 3', 'custom action was triggered') + .done(); + } +}; diff --git a/test/integration/input.js b/test/integration/input.js new file mode 100644 index 00000000..14c110c5 --- /dev/null +++ b/test/integration/input.js @@ -0,0 +1,39 @@ +var pwd = process.cwd(); +var helper = require('../integration_test_helper.js'); +var text_1 = '.context-menu-root input[name="context-menu-input-name"]'; +var text_area_1 = '.context-menu-root textarea[name="context-menu-input-area1"]'; +var text_area_2 = '.context-menu-root textarea[name="context-menu-input-area2"]'; + +module.exports = { + 'HTML5 input-based menu is shown correctly': function (test) { + test + .open('file://' + pwd + '/demo/input.html') + .execute(helper.rightClick, '.context-menu-one') + .waitForElement('#context-menu-layer') + .assert.visible('.context-menu-root', 'Menu is present') + .assert.exists('.context-menu-root', 'It opens context menu') + .assert.numberOfElements('.context-menu-root li') + .is(14, '14 context menu items are shown') + .assert.numberOfElements('.context-menu-root input') + .is(6, '6 HTML input items are shown') + .assert.width('.context-menu-root').is.gt(100) + .done(); + }, + + 'HTML5 input-based menu stores state when closed': function (test) { + test + .open('file://' + pwd + '/demo/input.html') + .execute(helper.rightClick, '.context-menu-one') + .waitForElement('#context-menu-layer') + .type(text_1, 'lorem ipsum') + .type(text_area_1, 'test area with height') + .type(text_area_2, 'shots go off') + .execute(helper.closeMenu, '.context-menu-one') + .execute(helper.rightClick, '.context-menu-one') + .waitForElement('#context-menu-layer') + .assert.val(text_1, 'lorem ipsum', 'Input text should contain entered text') + .assert.val(text_area_1, 'test area with height', 'Text area 1 should contain entered text') + .assert.val(text_area_2, 'shots go off', 'Text area 2 should contain entered text') + .done(); + } +};