UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

144 lines (143 loc) 5.94 kB
/** * DevExtreme (cjs/__internal/grids/new/grid_core/selection/options.test.js) * Version: 25.2.7 * Build date: Tue May 05 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 _di = require("../di.test_utils"); var _items_controller = require("../items_controller/items_controller"); var _controller = require("../toolbar/controller"); var _controller2 = require("./controller"); const setup = function() { let config = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; const context = (0, _di.getContext)(Object.assign({ selection: { mode: "single" } }, config)); return { selectionController: context.get(_controller2.SelectionController), itemsController: context.get(_items_controller.ItemsController), toolbarController: context.get(_controller.ToolbarController) } }; (0, _globals.describe)("Options", () => { (0, _globals.describe)("selectedCardKeys", () => { (0, _globals.describe)("when given", () => { (0, _globals.it)("should set the select state of the item", () => { const { itemsController: itemsController } = setup({ keyExpr: "id", dataSource: [{ id: 1, value: "test" }], selectedCardKeys: [1] }); (0, _globals.expect)(itemsController.items).toMatchSnapshot() }) }) }); (0, _globals.describe)("selection", () => { (0, _globals.describe)("mode", () => { (0, _globals.describe)("when it is 'none'", () => { (0, _globals.it)("selection should not work", () => { const { itemsController: itemsController, selectionController: selectionController } = setup({ keyExpr: "id", dataSource: [{ id: 1, value: "test" }], selection: { mode: "none" } }); selectionController.selectCards([1]); (0, _globals.expect)(itemsController.items).toMatchSnapshot() }) }); (0, _globals.describe)("when it is 'none' and the selectedCardKeys is specified", () => { (0, _globals.it)("selection should not apply", () => { const { itemsController: itemsController } = setup({ keyExpr: "id", dataSource: [{ id: 1, value: "test" }], selectedCardKeys: [1], selection: { mode: "none" } }); (0, _globals.expect)(itemsController.items).toMatchSnapshot() }) }) }); (0, _globals.describe)("allowSelectAll", () => { (0, _globals.describe)("when it is true and selection mode is 'multiple'", () => { (0, _globals.it)("selection should not work", () => { const { toolbarController: toolbarController } = setup({ keyExpr: "id", dataSource: [{ id: 1, value: "test" }], selection: { mode: "multiple", allowSelectAll: true } }); (0, _globals.expect)(toolbarController.items.peek()).toMatchSnapshot() }) }); (0, _globals.describe)("when it is false and selection mode is 'multiple'", () => { (0, _globals.it)("selection should not work", () => { const { toolbarController: toolbarController } = setup({ keyExpr: "id", dataSource: [{ id: 1, value: "test" }], selection: { mode: "multiple", allowSelectAll: false } }); (0, _globals.expect)(toolbarController.items.peek()).toMatchSnapshot() }) }); (0, _globals.describe)("when it is true and selection mode isn't 'multiple'", () => { (0, _globals.it)("selection should not work", () => { const { toolbarController: toolbarController } = setup({ keyExpr: "id", dataSource: [{ id: 1, value: "test" }], selection: { mode: "single", allowSelectAll: true } }); (0, _globals.expect)(toolbarController.items.peek()).toMatchSnapshot() }) }) }) }) });