11import $ from 'jquery' ;
22import MenuBase from 'ui/context_menu/ui.menu_base' ;
3+ import { getWindow } from 'core/utils/window' ;
4+
5+ import 'fluent_blue_light.css!' ;
36
47QUnit . testStart ( function ( ) {
58 const markup =
@@ -9,13 +12,15 @@ QUnit.testStart(function() {
912} ) ;
1013
1114const DX_MENU_BASE_CLASS = 'dx-menu-base' ;
15+ const DX_MENU_ITEM_CLASS = 'dx-menu-item' ;
1216
17+ const window = getWindow ( ) ;
1318
1419function createMenu ( options ) {
1520 const element = $ ( '#menu' ) ;
1621 const instance = new MenuBase ( element , options ) ;
1722
18- return { instance : instance , element : element } ;
23+ return { instance, element } ;
1924}
2025
2126QUnit . module ( 'Menu markup' , ( ) => {
@@ -24,5 +29,81 @@ QUnit.module('Menu markup', () => {
2429
2530 assert . ok ( menuBase . element . hasClass ( DX_MENU_BASE_CLASS ) ) ;
2631 } ) ;
27- } ) ;
2832
33+ QUnit . module ( 'Disabled item cursor style (T1327513)' , ( ) => {
34+ QUnit . test ( 'enabled menu item should have pointer cursor' , function ( assert ) {
35+ const menuBase = createMenu ( {
36+ items : [
37+ { text : 'Item 1' } ,
38+ { text : 'Item 2' , disabled : true } ,
39+ ] ,
40+ } ) ;
41+
42+ const $enabledItem = menuBase . element . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 0 ) ;
43+ const cursor = window . getComputedStyle ( $enabledItem . get ( 0 ) ) . cursor ;
44+
45+ assert . strictEqual ( cursor , 'pointer' , 'enabled item has pointer cursor' ) ;
46+ } ) ;
47+
48+ QUnit . test ( 'disabled menu item should have default cursor' , function ( assert ) {
49+ const menuBase = createMenu ( {
50+ items : [
51+ { text : 'Item 1' } ,
52+ { text : 'Item 2' , disabled : true } ,
53+ ] ,
54+ } ) ;
55+
56+ const $disabledItem = menuBase . element . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 1 ) ;
57+ const cursor = window . getComputedStyle ( $disabledItem . get ( 0 ) ) . cursor ;
58+
59+ assert . strictEqual ( cursor , 'default' , 'disabled item has default cursor' ) ;
60+ } ) ;
61+
62+ QUnit . test ( 'item should have default cursor when disabled at runtime' , function ( assert ) {
63+ const menuBase = createMenu ( {
64+ items : [
65+ { text : 'Item 1' , disabled : false } ,
66+ { text : 'Item 2' , disabled : false } ,
67+ ] ,
68+ } ) ;
69+
70+ menuBase . instance . option ( 'items[1].disabled' , true ) ;
71+
72+ const $disabledItem = menuBase . element . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 1 ) ;
73+ const cursor = window . getComputedStyle ( $disabledItem . get ( 0 ) ) . cursor ;
74+
75+ assert . strictEqual ( cursor , 'default' , 'item has default cursor after disabling at runtime' ) ;
76+ } ) ;
77+
78+ QUnit . test ( 'items in disabled menu should have default cursor' , function ( assert ) {
79+ const menuBase = createMenu ( {
80+ disabled : true ,
81+ items : [
82+ { text : 'Item 1' } ,
83+ { text : 'Item 2' } ,
84+ ] ,
85+ } ) ;
86+ const $item = menuBase . element . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 0 ) ;
87+ const cursor = window . getComputedStyle ( $item . get ( 0 ) ) . cursor ;
88+ assert . strictEqual ( cursor , 'default' , 'items in disabled menu have default cursor' ) ;
89+ } ) ;
90+
91+ QUnit . test ( 'menu items with url should have correct cursor' , function ( assert ) {
92+ const menuBase = createMenu ( {
93+ items : [
94+ { text : 'Item 1' , url : 'https://example.com' } ,
95+ { text : 'Item 2' , url : 'https://example.com/disabled' , disabled : true } ,
96+ ] ,
97+ } ) ;
98+
99+ const $enabledItem = menuBase . element . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 0 ) ;
100+ const enabledItemCursor = window . getComputedStyle ( $enabledItem . get ( 0 ) ) . cursor ;
101+
102+ const $disabledItem = menuBase . element . find ( `.${ DX_MENU_ITEM_CLASS } ` ) . eq ( 1 ) ;
103+ const disabledItemCursor = window . getComputedStyle ( $disabledItem . get ( 0 ) ) . cursor ;
104+
105+ assert . strictEqual ( enabledItemCursor , 'pointer' , 'enabled item with url has pointer cursor' ) ;
106+ assert . strictEqual ( disabledItemCursor , 'default' , 'disabled item with url has default cursor' ) ;
107+ } ) ;
108+ } ) ;
109+ } ) ;
0 commit comments