11import $ from 'jquery' ;
22import MenuBase from 'ui/context_menu/ui.menu_base' ;
33
4+ import 'fluent_blue_light.css!' ;
5+
46QUnit . testStart ( function ( ) {
57 const markup =
68 '<div id="menu"></div>' ;
@@ -9,13 +11,13 @@ QUnit.testStart(function() {
911} ) ;
1012
1113const DX_MENU_BASE_CLASS = 'dx-menu-base' ;
12-
14+ const DX_MENU_ITEM_CLASS = 'dx-menu-item' ;
1315
1416function createMenu ( options ) {
1517 const element = $ ( '#menu' ) ;
1618 const instance = new MenuBase ( element , options ) ;
1719
18- return { instance : instance , element : element } ;
20+ return { instance, element } ;
1921}
2022
2123QUnit . module ( 'Menu markup' , ( ) => {
@@ -24,5 +26,81 @@ QUnit.module('Menu markup', () => {
2426
2527 assert . ok ( menuBase . element . hasClass ( DX_MENU_BASE_CLASS ) ) ;
2628 } ) ;
27- } ) ;
2829
30+ QUnit . module ( 'Disabled item cursor style (T1327513)' , ( ) => {
31+ QUnit . test ( 'enabled menu item should have pointer cursor' , function ( assert ) {
32+ const menuBase = createMenu ( {
33+ items : [
34+ { text : 'Item 1' } ,
35+ { text : 'Item 2' , disabled : true } ,
36+ ] ,
37+ } ) ;
38+
39+ const $enabledItem = menuBase . element . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 0 ) ;
40+ const cursor = $enabledItem . css ( 'cursor' ) ;
41+
42+ assert . strictEqual ( cursor , 'pointer' , 'enabled item has pointer cursor' ) ;
43+ } ) ;
44+
45+ QUnit . test ( 'disabled menu item should have default cursor' , function ( assert ) {
46+ const menuBase = createMenu ( {
47+ items : [
48+ { text : 'Item 1' } ,
49+ { text : 'Item 2' , disabled : true } ,
50+ ] ,
51+ } ) ;
52+
53+ const $disabledItem = menuBase . element . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 1 ) ;
54+ const cursor = $disabledItem . css ( 'cursor' ) ;
55+
56+ assert . strictEqual ( cursor , 'default' , 'disabled item has default cursor' ) ;
57+ } ) ;
58+
59+ QUnit . test ( 'item should have default cursor when disabled at runtime' , function ( assert ) {
60+ const menuBase = createMenu ( {
61+ items : [
62+ { text : 'Item 1' , disabled : false } ,
63+ { text : 'Item 2' , disabled : false } ,
64+ ] ,
65+ } ) ;
66+
67+ menuBase . instance . option ( 'items[1].disabled' , true ) ;
68+
69+ const $disabledItem = menuBase . element . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 1 ) ;
70+ const cursor = $disabledItem . css ( 'cursor' ) ;
71+
72+ assert . strictEqual ( cursor , 'default' , 'item has default cursor after disabling at runtime' ) ;
73+ } ) ;
74+
75+ QUnit . test ( 'items in disabled menu should have default cursor' , function ( assert ) {
76+ const menuBase = createMenu ( {
77+ disabled : true ,
78+ items : [
79+ { text : 'Item 1' } ,
80+ { text : 'Item 2' } ,
81+ ] ,
82+ } ) ;
83+ const $item = menuBase . element . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 0 ) ;
84+ const cursor = $item . css ( 'cursor' ) ;
85+ assert . strictEqual ( cursor , 'default' , 'items in disabled menu have default cursor' ) ;
86+ } ) ;
87+
88+ QUnit . test ( 'menu items with url should have correct cursor' , function ( assert ) {
89+ const menuBase = createMenu ( {
90+ items : [
91+ { text : 'Item 1' , url : 'https://example.com' } ,
92+ { text : 'Item 2' , url : 'https://example.com/disabled' , disabled : true } ,
93+ ] ,
94+ } ) ;
95+
96+ const $enabledItem = menuBase . element . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 0 ) ;
97+ const enabledItemCursor = $enabledItem . css ( 'cursor' ) ;
98+
99+ const $disabledItem = menuBase . element . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 1 ) ;
100+ const disabledItemCursor = $disabledItem . css ( 'cursor' ) ;
101+
102+ assert . strictEqual ( enabledItemCursor , 'pointer' , 'enabled item with url has pointer cursor' ) ;
103+ assert . strictEqual ( disabledItemCursor , 'default' , 'disabled item with url has default cursor' ) ;
104+ } ) ;
105+ } ) ;
106+ } ) ;
0 commit comments