UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

127 lines (124 loc) 5.36 kB
/** * DevExtreme (cjs/__internal/grids/new/grid_core/accessibility/utils.test.js) * Version: 25.2.5 * Build date: Fri Feb 20 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; var _globals = require("@jest/globals"); var _jestEach = _interopRequireDefault(require("jest-each")); var utils = _interopRequireWildcard(require("./utils")); function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) { var r = new WeakMap, n = new WeakMap } return (_interopRequireWildcard = function(e, t) { if (!t && e && e.__esModule) { return e } var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) { return f } if (o = t ? n : r) { if (o.has(e)) { return o.get(e) } o.set(e, f) } for (const t in e) { "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]) } return f })(e, t) } function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e } }(0, _globals.describe)("Accessibility", (() => { (0, _globals.describe)("Utils", (() => { (0, _globals.describe)("getCardRoleDescription", (() => { (0, _jestEach.default)` isEditable | expectedResult ${true} | ${"Editable card"} ${false} | ${"Card"} `.it("should take into account if a card is editable", (_ref => { let { isEditable: isEditable, expectedResult: expectedResult } = _ref; const result = utils.getCardRoleDescription(isEditable); (0, _globals.expect)(result).toEqual(expectedResult) })) })); (0, _globals.describe)("getCardStateDescription", (() => { (0, _jestEach.default)` position | expectedResult ${{rowIndex:0,columnIndex:0}} | ${"Row 1, column 1"} ${{rowIndex:4,columnIndex:5}} | ${"Row 5, column 6"} `.it("should take into account card' position", (_ref2 => { let { position: position, expectedResult: expectedResult } = _ref2; const result = utils.getCardStateDescription(position); (0, _globals.expect)(result).toEqual(expectedResult) })); (0, _jestEach.default)` position |isSelectable |isSelected | expectedResult ${{rowIndex:0,columnIndex:0}} |${false} |${true} | ${"Row 1, column 1"} ${{rowIndex:0,columnIndex:0}} |${true} |${false} | ${"Row 1, column 1, Not selected"} ${{rowIndex:0,columnIndex:0}} |${true} |${true} | ${"Row 1, column 1, Selected"} `.it("should take into account selected state", (_ref3 => { let { position: position, isSelectable: isSelectable, isSelected: isSelected, expectedResult: expectedResult } = _ref3; const result = utils.getCardStateDescription(position, isSelectable, isSelected); (0, _globals.expect)(result).toEqual(expectedResult) })) })); (0, _globals.describe)("getCardDescriptiveLabel", (() => { (0, _jestEach.default)` hasCover | coverId | contentId | expectedResult ${true} | ${"coverId"} |${"contentId"} |${"coverId contentId"} ${false} | ${"coverId"} |${"contentId"} |${"contentId"} `.it("should take into account if a card has a cover", (_ref4 => { let { hasCover: hasCover, coverId: coverId, contentId: contentId, expectedResult: expectedResult } = _ref4; const result = utils.getCardDescriptiveLabel(hasCover, coverId, contentId); (0, _globals.expect)(result).toEqual(expectedResult) })) })); (0, _globals.describe)("getPosition", (() => { (0, _jestEach.default)` idx | columnCount | expectedResult ${0} |${1} | ${{rowIndex:0,columnIndex:0}} ${3} |${5} | ${{rowIndex:0,columnIndex:3}} ${10} |${3} | ${{rowIndex:3,columnIndex:1}} ${7} |${4} | ${{rowIndex:1,columnIndex:3}} `.it("should take into account if a card has a cover", (_ref5 => { let { idx: idx, columnCount: columnCount, expectedResult: expectedResult } = _ref5; const result = utils.getPosition(idx, columnCount); (0, _globals.expect)(result).toEqual(expectedResult) })) })) })) }));