UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

95 lines (94 loc) 3.6 kB
/** * DevExtreme (cjs/__internal/grids/grid_core/focus/m_focus.integration.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 _utils = require("../__tests__/__mock__/helpers/utils"); (0, _globals.describe)("GridCore focus", () => { (0, _globals.beforeEach)(_utils.beforeTest); (0, _globals.afterEach)(_utils.afterTest); _globals.describe.each([ [true, "insert", 2], [true, "remove", 0], [true, "update", 2], [false, "insert", 2], [false, "remove", 0], [false, "update", 2] ])("when repaintChangesOnly=%s and performing %s operation", (repaintChangesOnly, operation, expectedFocusedRowIndex) => { (0, _globals.it)("should updates the focused row index correctly", async () => { const onFocusedRowChanged = _globals.jest.fn(); const { instance: instance } = await (0, _utils.createDataGrid)({ dataSource: { store: { type: "array", data: [{ id: 1, name: "Item 1" }, { id: 2, name: "Item 2" }, { id: 3, name: "Item 3" }], key: "id" }, reshapeOnPush: true, pushAggregationTimeout: 0 }, showBorders: true, focusedRowEnabled: true, focusedRowKey: 2, onFocusedRowChanged: onFocusedRowChanged, repaintChangesOnly: repaintChangesOnly, columns: [{ dataField: "id", width: 80 }, { dataField: "name", caption: "Name", sortOrder: "asc" }] }); const store = instance.getDataSource().store(); onFocusedRowChanged.mockClear(); switch (operation) { case "insert": store.push([{ type: "insert", index: 0, data: { name: "Item 0" } }]); break; case "remove": store.push([{ type: "remove", key: 1 }]); break; case "update": store.push([{ type: "update", key: 3, data: { id: 3, name: "A Item 3" } }]) } await (0, _utils.flushAsync)(); (0, _globals.expect)(onFocusedRowChanged.mock.calls.length).toBe(1); (0, _globals.expect)(instance.option("focusedRowKey")).toEqual(2); (0, _globals.expect)(instance.option("focusedRowIndex")).toEqual(expectedFocusedRowIndex) }) }) });