~holger-seelig/cobweb.js/trunk

« back to all changes in this revision

Viewing changes to cobweb.js/lib/jquery-contextMenu/test/integration/sub-menus.js

  • Committer: Holger Seelig
  • Date: 2017-08-22 04:53:24 UTC
  • Revision ID: holger.seelig@yahoo.de-20170822045324-4of4xxgt79669gbt
Switched to npm.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
var pwd = process.cwd();
2
 
var helper = require('../integration_test_helper.js');
3
 
 
4
 
var menuItem4 = '.context-menu-root li:nth-child(6)';
5
 
var submenu1 = '.context-menu-root li.context-menu-item:nth-child(6) > ul:nth-child(2)';
6
 
var submenu1Foobar = '.context-menu-root li.context-menu-item:nth-child(6) > ul:nth-child(2) > li:nth-child(1)';
7
 
var submenu1Item2 = '.context-menu-root li.context-menu-submenu:nth-child(2)';
8
 
var submenu1Subgroup2 = '.context-menu-root li.context-menu-item:nth-child(6) > ul:nth-child(2) > li:nth-child(2)';
9
 
var submenu1Subgroup2Charlie = '.context-menu-root li.context-menu-submenu:nth-child(2) > ul:nth-child(2) > li:nth-child(3)';
10
 
 
11
 
var returnKey = "\uE006\uE007"; // send <enter> key as well for phantomJS
12
 
var rightArrowKey = "\uE014";
13
 
var downArrowKey = "\uE015";
14
 
 
15
 
var selectFourthMenuItem = downArrowKey + downArrowKey + downArrowKey + downArrowKey;
16
 
var selectFirstSubmenuItem = selectFourthMenuItem + rightArrowKey;
17
 
var selectSecondSubmenuItem = selectFourthMenuItem + rightArrowKey + downArrowKey;
18
 
var selectThirdSubSubMenuItem = selectSecondSubmenuItem + rightArrowKey + downArrowKey + downArrowKey;
19
 
 
20
 
// this test uses custom HTML because PhantomJS
21
 
// has problems showing alert modal dialogs.
22
 
// We are testing callbacks against simple DOM
23
 
// manipulations instead.
24
 
module.exports = {
25
 
  'Sub-menu is visible when parent menu item is highlighted': function (test) {
26
 
    test
27
 
      .open('file://' + pwd + '/demo/sub-menus_test.html')
28
 
      .execute(helper.rightClick, '.context-menu-sub')
29
 
      .waitForElement('#context-menu-layer')
30
 
      .sendKeys('body', selectFourthMenuItem)
31
 
      .assert.attr(menuItem4, 'class').to.contain('hover')
32
 
      .assert.visible(submenu1, 'First sub-menu is visible')
33
 
      .done();
34
 
  },
35
 
 
36
 
  'Sub-menu item triggers callback when clicked': function (test) {
37
 
    test
38
 
      .open('file://' + pwd + '/demo/sub-menus_test.html')
39
 
      .execute(helper.rightClick, '.context-menu-sub')
40
 
      .waitForElement('#context-menu-layer')
41
 
      .sendKeys('body', selectFirstSubmenuItem)
42
 
      .sendKeys('body', returnKey)
43
 
      .assert.text('#msg', 'clicked: fold1-key1', '"Foo bar" sub-menu item triggers callback')
44
 
      .done();
45
 
  },
46
 
 
47
 
  'Sub-sub-menu is visible when parent menu item is highlighted': function (test) {
48
 
    test
49
 
      .open('file://' + pwd + '/demo/sub-menus_test.html')
50
 
      .execute(helper.rightClick, '.context-menu-sub')
51
 
      .waitForElement('#context-menu-layer')
52
 
      .sendKeys('body', selectSecondSubmenuItem)
53
 
      .assert.attr(submenu1Item2, 'class').to.contain('hover')
54
 
      .assert.visible(submenu1Subgroup2, 'Sub-sub-menu should be open and visible')
55
 
      .done();
56
 
  },
57
 
 
58
 
  'Sub-sub-menu item callback is triggered': function (test) {
59
 
    test
60
 
      .open('file://' + pwd + '/demo/sub-menus_test.html')
61
 
      .execute(helper.rightClick, '.context-menu-sub')
62
 
      .waitForElement('#context-menu-layer')  
63
 
      .sendKeys('body', selectThirdSubSubMenuItem)
64
 
      .sendKeys('body', returnKey)
65
 
      .assert.text('#msg', 'clicked: fold2-key3', '"charlie" Sub-sub-menu item triggers callback')
66
 
      .done();
67
 
  }
68
 
};