Skip to content

Commit 3203487

Browse files
committed
fix
1 parent 2d25a36 commit 3203487

2 files changed

Lines changed: 83 additions & 81 deletions

File tree

packages/devextreme/testing/tests/DevExpress.ui.widgets/menuBase.markup.tests.js

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import $ from 'jquery';
22
import MenuBase from 'ui/context_menu/ui.menu_base';
3+
import { getWindow } from 'core/utils/window';
4+
5+
import 'fluent_blue_light.css!';
36

47
QUnit.testStart(function() {
58
const markup =
@@ -9,13 +12,15 @@ QUnit.testStart(function() {
912
});
1013

1114
const DX_MENU_BASE_CLASS = 'dx-menu-base';
15+
const DX_MENU_ITEM_CLASS = 'dx-menu-item';
1216

17+
const window = getWindow();
1318

1419
function 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

2126
QUnit.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+
});

packages/devextreme/testing/tests/DevExpress.ui.widgets/menuBase.tests.js

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import MenuBase from 'ui/context_menu/ui.menu_base';
55
import keyboardMock from '../../helpers/keyboardMock.js';
66
import ariaAccessibilityTestHelper from '../../helpers/ariaAccessibilityTestHelper.js';
77

8-
import 'fluent_blue_light.css!';
9-
108
QUnit.testStart(function() {
119
const markup =
1210
`<style nonce="qunit-test">
@@ -1302,80 +1300,3 @@ QUnit.module('Aria accessibility', {
13021300
});
13031301
});
13041302
});
1305-
1306-
QUnit.module('Disabled item cursor style (T1327513)', () => {
1307-
QUnit.test('enabled menu item should have pointer cursor', function(assert) {
1308-
const menuBase = createMenu({
1309-
items: [
1310-
{ text: 'Item 1' },
1311-
{ text: 'Item 2', disabled: true },
1312-
],
1313-
});
1314-
1315-
const $enabledItem = menuBase.element.find(`.${DX_MENU_ITEM_CLASS}`).eq(0);
1316-
const cursor = window.getComputedStyle($enabledItem.get(0)).cursor;
1317-
1318-
assert.strictEqual(cursor, 'pointer', 'enabled item has pointer cursor');
1319-
});
1320-
1321-
QUnit.test('disabled menu item should have default cursor', function(assert) {
1322-
const menuBase = createMenu({
1323-
items: [
1324-
{ text: 'Item 1' },
1325-
{ text: 'Item 2', disabled: true },
1326-
],
1327-
});
1328-
1329-
const $disabledItem = menuBase.element.find(`.${DX_MENU_ITEM_CLASS}`).eq(1);
1330-
const cursor = window.getComputedStyle($disabledItem.get(0)).cursor;
1331-
1332-
assert.strictEqual(cursor, 'default', 'disabled item has default cursor');
1333-
});
1334-
1335-
QUnit.test('item should have default cursor when disabled at runtime', function(assert) {
1336-
const menuBase = createMenu({
1337-
items: [
1338-
{ text: 'Item 1', disabled: false },
1339-
{ text: 'Item 2', disabled: false },
1340-
],
1341-
});
1342-
1343-
menuBase.instance.option('items[1].disabled', true);
1344-
1345-
const $disabledItem = menuBase.element.find(`.${DX_MENU_ITEM_CLASS}`).eq(1);
1346-
const cursor = window.getComputedStyle($disabledItem.get(0)).cursor;
1347-
1348-
assert.strictEqual(cursor, 'default', 'item has default cursor after disabling at runtime');
1349-
});
1350-
1351-
QUnit.test('items in disabled menu should have default cursor', function(assert) {
1352-
const menuBase = createMenu({
1353-
disabled: true,
1354-
items: [
1355-
{ text: 'Item 1' },
1356-
{ text: 'Item 2' },
1357-
],
1358-
});
1359-
const $item = menuBase.element.find(`.${DX_MENU_ITEM_CLASS}`).eq(0);
1360-
const cursor = window.getComputedStyle($item.get(0)).cursor;
1361-
assert.strictEqual(cursor, 'default', 'items in disabled menu have default cursor');
1362-
});
1363-
1364-
QUnit.test('menu items with url should have correct cursor', function(assert) {
1365-
const menuBase = createMenu({
1366-
items: [
1367-
{ text: 'Item 1', url: 'https://example.com' },
1368-
{ text: 'Item 2', url: 'https://example.com/disabled', disabled: true },
1369-
],
1370-
});
1371-
1372-
const $enabledItem = menuBase.element.find(`.${DX_MENU_ITEM_CLASS}`).eq(0);
1373-
const enabledItemCursor = window.getComputedStyle($enabledItem.get(0)).cursor;
1374-
1375-
const $disabledItem = menuBase.element.find(`.${DX_MENU_ITEM_CLASS}`).eq(1);
1376-
const disabledItemCursor = window.getComputedStyle($disabledItem.get(0)).cursor;
1377-
1378-
assert.strictEqual(enabledItemCursor, 'pointer', 'enabled item with url has pointer cursor');
1379-
assert.strictEqual(disabledItemCursor, 'default', 'disabled item with url has default cursor');
1380-
});
1381-
});

0 commit comments

Comments
 (0)