From febe90b23893a9dc1416bfbd3c9b28ca9834256c Mon Sep 17 00:00:00 2001 From: Aliullov Vlad <91639107+GoodDayForSurf@users.noreply.github.com> Date: Fri, 14 Aug 2026 10:40:31 +0200 Subject: [PATCH 1/4] Migrate QUnit tests from SystemJs (#34564) --- .github/workflows/qunit_tests.yml | 2 +- packages/devextreme/docker-ci.sh | 3 +- .../grids/grid_core/views/m_grid_view.ts | 3 +- .../grids/grid_core/views/m_rows_view.ts | 6 +- packages/devextreme/package.json | 5 - packages/devextreme/project.json | 158 +++-- .../devextreme/testing/helpers/chartMocks.js | 4 +- .../helpers/data.errorHandlingHelper.js | 27 +- .../testing/helpers/dataGridMocks.js | 72 ++- .../esm-shims/fluent_blue_light.css.js | 5 + .../testing/helpers/esm-shims/gantt.css.js | 3 + .../helpers/esm-shims/injectStylesheet.js | 57 ++ .../testing/helpers/esm-shims/jquery.js | 17 + .../helpers/esm-shims/jspdf_autotable.js | 37 ++ .../testing/helpers/esm-shims/knockout.js | 12 + .../esm-shims/material_blue_light.css.js | 5 + .../helpers/esm-shims/mutable_facade.js | 50 ++ .../testing/helpers/esm-shims/themes.js | 48 ++ .../testing/helpers/esm-shims/tslib.js | 41 ++ .../helpers/esm-shims/zod-to-json-schema.js | 8 + .../testing/helpers/esm-shims/zod.js | 35 ++ .../testing/helpers/executeAsyncMock.js | 40 +- .../testing/helpers/includeThemesLinks.js | 11 +- .../testing/helpers/keyboardMock.js | 22 +- .../testing/helpers/memoryLeaksHelper.js | 23 +- .../devextreme/testing/helpers/mockModule.js | 19 +- .../testing/helpers/nativePointerMock.js | 19 +- .../devextreme/testing/helpers/noDiagram.js | 2 +- .../devextreme/testing/helpers/noGantt.js | 2 +- .../devextreme/testing/helpers/noJQuery.js | 2 +- .../devextreme/testing/helpers/pointerMock.js | 24 +- .../testing/helpers/positionFixtures.js | 18 +- .../testing/helpers/publicModulesHelper.js | 18 +- .../helpers/quillDependencies/noQuill.js | 3 +- .../testing/helpers/qunitExtensions.js | 2 +- .../testing/helpers/stubs/zodStub.js | 53 -- .../helpers/stubs/zodToJsonSchemaStub.js | 21 - .../devextreme/testing/helpers/trackerMock.js | 15 +- .../testing/helpers/treeListMocks.js | 70 ++- .../devextreme/testing/helpers/vizMocks.js | 14 +- .../testing/helpers/xmlHttpRequestMock.js | 2 +- packages/devextreme/testing/runner/README.md | 103 +++ packages/devextreme/testing/runner/index.ts | 6 +- .../testing/runner/lib/autoMutableFacade.ts | 588 ++++++++++++++++++ .../testing/runner/lib/cjsInterop.ts | 580 +++++++++++++++++ .../testing/runner/lib/importMap.ts | 432 +++++++++++++ .../testing/runner/lib/mutableModuleGroups.ts | 121 ++++ .../devextreme/testing/runner/lib/pages.ts | 198 ++---- .../devextreme/testing/runner/lib/static.ts | 546 ++++++++++++++-- .../runner/templates/run-suite.template.html | 123 ++-- .../devextreme/testing/systemjs-builder.js | 272 -------- .../tests/DevExpress.aspnet/aspnet.tests.js | 63 +- .../tests/DevExpress.common/charts.tests.js | 31 +- .../DevExpress.core/config_bundled.tests.js | 16 +- .../tests/DevExpress.jquery/bundled.tests.js | 17 +- .../tests/DevExpress.jquery/template.tests.js | 6 - .../localization.globalize.tests.js | 27 +- .../adaptiveColumns.tests.js | 25 +- .../htmlEditorParts/importQuill.tests.js | 29 +- .../tableResizingModule.tests.js | 4 +- .../htmlEditorParts/toolbarModule.tests.js | 1 + .../desktopTooltip.tests.js | 1 + .../diagramParts/importDiagram.tests.js | 26 +- .../ganttParts/importGantt.tests.js | 27 +- .../tests/DevExpress.ui/themes.tests.js | 2 +- .../chart.integration.tests.js | 12 +- .../chart.part7.tests.js | 4 +- .../DevExpress.viz.core/axisDrawing.tests.js | 4 +- .../DevExpress.viz.gauges/barGauge.tests.js | 12 +- .../tests/Memory Leaks/vizWidgets.tests.js | 4 +- packages/nx-infra-plugin/AGENTS.md | 21 + pnpm-lock.yaml | 30 - 72 files changed, 3249 insertions(+), 1060 deletions(-) create mode 100644 packages/devextreme/testing/helpers/esm-shims/fluent_blue_light.css.js create mode 100644 packages/devextreme/testing/helpers/esm-shims/gantt.css.js create mode 100644 packages/devextreme/testing/helpers/esm-shims/injectStylesheet.js create mode 100644 packages/devextreme/testing/helpers/esm-shims/jquery.js create mode 100644 packages/devextreme/testing/helpers/esm-shims/jspdf_autotable.js create mode 100644 packages/devextreme/testing/helpers/esm-shims/knockout.js create mode 100644 packages/devextreme/testing/helpers/esm-shims/material_blue_light.css.js create mode 100644 packages/devextreme/testing/helpers/esm-shims/mutable_facade.js create mode 100644 packages/devextreme/testing/helpers/esm-shims/themes.js create mode 100644 packages/devextreme/testing/helpers/esm-shims/tslib.js create mode 100644 packages/devextreme/testing/helpers/esm-shims/zod-to-json-schema.js create mode 100644 packages/devextreme/testing/helpers/esm-shims/zod.js delete mode 100644 packages/devextreme/testing/helpers/stubs/zodStub.js delete mode 100644 packages/devextreme/testing/helpers/stubs/zodToJsonSchemaStub.js create mode 100644 packages/devextreme/testing/runner/README.md create mode 100644 packages/devextreme/testing/runner/lib/autoMutableFacade.ts create mode 100644 packages/devextreme/testing/runner/lib/cjsInterop.ts create mode 100644 packages/devextreme/testing/runner/lib/importMap.ts create mode 100644 packages/devextreme/testing/runner/lib/mutableModuleGroups.ts delete mode 100644 packages/devextreme/testing/systemjs-builder.js diff --git a/.github/workflows/qunit_tests.yml b/.github/workflows/qunit_tests.yml index 86d0994d64ce..2ae2c013fc1d 100644 --- a/.github/workflows/qunit_tests.yml +++ b/.github/workflows/qunit_tests.yml @@ -111,7 +111,7 @@ jobs: shell: bash env: DEVEXTREME_TEST_CI: "true" - run: pnpm exec nx build:systemjs + run: pnpm exec nx build:dev - name: Zip artifacts working-directory: ./packages/devextreme diff --git a/packages/devextreme/docker-ci.sh b/packages/devextreme/docker-ci.sh index 28f51484ee3c..4944b701684c 100755 --- a/packages/devextreme/docker-ci.sh +++ b/packages/devextreme/docker-ci.sh @@ -40,7 +40,8 @@ function run_test { function run_test_impl { local port=`node -e "console.log(require('./ports.json').qunit)"` - local url="http://0.0.0.0:$port/run?notimers=true" + # Use 127.0.0.1, not 0.0.0.0 — Chrome cannot fetch modules from 0.0.0.0. + local url="http://127.0.0.1:$port/run?notimers=true" local runner_pid local runner_result=0 diff --git a/packages/devextreme/js/__internal/grids/grid_core/views/m_grid_view.ts b/packages/devextreme/js/__internal/grids/grid_core/views/m_grid_view.ts index 4e3ad735a89e..a069f831b981 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/views/m_grid_view.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/views/m_grid_view.ts @@ -11,6 +11,7 @@ import { Deferred, when } from '@js/core/utils/deferred'; import { each } from '@js/core/utils/iterator'; import { getBoundingRect } from '@js/core/utils/position'; import { getHeight, getWidth } from '@js/core/utils/size'; +import { setHeight } from '@js/core/utils/style'; import { isDefined, isNumeric, isString } from '@js/core/utils/type'; import { getWindow, hasWindow } from '@js/core/utils/window'; import * as accessibility from '@js/ui/shared/accessibility'; @@ -826,7 +827,7 @@ export class ResizingController extends modules.ViewController { // IE11 if (maxHeightHappened && !isMaxHeightApplied) { - $(groupElement).css('height', maxHeight); + setHeight($(groupElement), maxHeight); } if (!dataController.isLoaded()) { diff --git a/packages/devextreme/js/__internal/grids/grid_core/views/m_rows_view.ts b/packages/devextreme/js/__internal/grids/grid_core/views/m_rows_view.ts index e943108ee08a..134a5a1d2bad 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/views/m_rows_view.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/views/m_rows_view.ts @@ -538,7 +538,7 @@ export class RowsView extends ColumnsView { $cell = that._createCell({ column: columns[i], rowType: 'freeSpace', columnIndex: i, columns, }); - isNumeric(height) && $cell.css('height', height); + isNumeric(height) && setHeight($cell, height); $row.append($cell); } @@ -1037,7 +1037,7 @@ export class RowsView extends ColumnsView { if (showFreeSpaceRow) { deferRender(() => { - freeSpaceRowElements.css('height', resultHeight); + setHeight(freeSpaceRowElements, resultHeight); isFreeSpaceRowVisible = true; freeSpaceRowElements.show(); }); @@ -1046,7 +1046,7 @@ export class RowsView extends ColumnsView { }); } } else { - freeSpaceRowElements.css('height', 0); + setHeight(freeSpaceRowElements, 0); freeSpaceRowElements.show(); this._updateLastRowBorder(true); } diff --git a/packages/devextreme/package.json b/packages/devextreme/package.json index 3ab3e909e6ba..1e11e1e80a2e 100644 --- a/packages/devextreme/package.json +++ b/packages/devextreme/package.json @@ -130,11 +130,6 @@ "minimist": "1.2.8", "qunit": "2.25.0", "sinon": "18.0.1", - "systemjs": "0.19.41", - "systemjs-plugin-babel": "0.0.25", - "systemjs-plugin-css": "0.1.37", - "systemjs-plugin-json": "0.3.0", - "systemjs-plugin-text": "0.0.11", "terser-webpack-plugin": "5.3.17", "ts-jest": "29.1.2", "tsc-alias": "1.8.16", diff --git a/packages/devextreme/project.json b/packages/devextreme/project.json index 19efa18de2d0..7a92022c8bb3 100644 --- a/packages/devextreme/project.json +++ b/packages/devextreme/project.json @@ -152,6 +152,20 @@ "{projectRoot}/artifacts/npm/devextreme-internal/bundles/dx.custom.config.js" ] }, + "copy:qunit:dx-custom": { + "executor": "devextreme-nx-infra-plugin:copy-files", + "options": { + "files": [ + { + "from": "./build/bundle-templates/dx.custom.js", + "to": "./artifacts/transpiled-esm-npm/bundles/dx.custom.js" + } + ] + }, + "dependsOn": ["build:devextreme-bundler-config"], + "inputs": ["{projectRoot}/build/bundle-templates/dx.custom.js"], + "outputs": ["{projectRoot}/artifacts/transpiled-esm-npm/bundles/dx.custom.js"] + }, "build:devextreme-bundler-config:watch": { "executor": "devextreme-nx-infra-plugin:concatenate-files", "cache": false, @@ -322,6 +336,11 @@ { "from": "./js/viz/vector_map.utils/_settings.json", "to": "./viz/vector_map.utils/_settings.json" } ] }, + "configurations": { + "qunit": { + "removeDebug": false + } + }, "inputs": [ "jsSourcesProduction", "jsAssetsProduction" @@ -410,6 +429,11 @@ ".jsx": ".js" } }, + "configurations": { + "qunit": { + "removeDebug": false + } + }, "inputs": [ "internalTsArtifacts" ], @@ -417,6 +441,72 @@ "{projectRoot}/artifacts/transpiled-esm-npm/esm/__internal" ] }, + "build:npm:esm:watch": { + "executor": "devextreme-nx-infra-plugin:babel-transform", + "cache": false, + "options": { + "babelConfigPath": "./build/transpile-config.js", + "configKey": "esm", + "sourcePattern": "./js/**/*.{js,jsx}", + "excludePatterns": [ + "./js/**/*.d.ts", + "./js/__internal/**/*" + ], + "outDir": "./artifacts/transpiled-esm-npm/esm", + "removeDebug": true, + "watch": true, + "copyAssets": [ + { "from": "./js/localization/messages", "to": "./localization/messages" }, + { "from": "./js/viz/vector_map.utils/_settings.json", "to": "./viz/vector_map.utils/_settings.json" } + ] + }, + "configurations": { + "qunit": { + "removeDebug": false + } + } + }, + "build:npm:esm:internal:watch": { + "executor": "devextreme-nx-infra-plugin:babel-transform", + "cache": false, + "options": { + "babelConfigPath": "./build/transpile-config.js", + "configKey": "esm", + "sourcePattern": "./artifacts/dist_ts/__internal/**/*.{js,jsx}", + "outDir": "./artifacts/transpiled-esm-npm/esm/__internal", + "removeDebug": true, + "watch": true, + "renameExtensions": { + ".jsx": ".js" + } + }, + "configurations": { + "qunit": { + "removeDebug": false + } + } + }, + "build:qunit-esm": { + "executor": "nx:run-commands", + "options": { + "cwd": "{projectRoot}", + "parallel": true, + "commands": [ + "pnpm nx run devextreme:build:npm:esm -c qunit", + "pnpm nx run devextreme:build:npm:esm:internal -c qunit" + ] + }, + "dependsOn": [ + "build:ts:internal" + ], + "outputs": [ + "{projectRoot}/artifacts/transpiled-esm-npm/esm" + ], + "cache": true, + "metadata": { + "description": "ESM artifacts for QUnit native import-map loader (?loader=esm)." + } + }, "build:npm:cjs:internal": { "executor": "devextreme-nx-infra-plugin:babel-transform", "options": { @@ -530,14 +620,12 @@ "pnpm nx build:devextreme-bundler-config devextreme", "pnpm nx build:devextreme-bundler-config devextreme -c prod", "pnpm nx build:ts:internal devextreme", - "pnpm nx run-many --targets=build:cjs,build:cjs:internal,build:cjs:bundles --projects=devextreme --parallel", - "pnpm nx run-many --targets=build:cjs,build:cjs:internal,build:cjs:bundles --projects=devextreme --parallel -c production", - "pnpm nx run-many --targets=build:npm:cjs,build:npm:cjs:internal --projects=devextreme --parallel", + "pnpm nx run-many --targets=build:npm:esm,build:npm:esm:internal --projects=devextreme --parallel -c qunit", + "pnpm nx copy:qunit:dx-custom devextreme", "pnpm nx clean:dist-ts devextreme" ], "outputs": [ - "{projectRoot}/artifacts/transpiled", - "{projectRoot}/artifacts/transpiled-renovation-npm", + "{projectRoot}/artifacts/transpiled-esm-npm", "{projectRoot}/build/bundle-templates/dx.custom.js", "{projectRoot}/artifacts/npm/devextreme/bundles/dx.custom.config.js" ] @@ -570,10 +658,8 @@ "options": { "commands": [ "pnpm nx build:ts:internal:watch devextreme", - "pnpm nx build:cjs:watch devextreme", - "pnpm nx build:cjs:watch devextreme -c production", - "pnpm nx build:cjs:internal:watch devextreme", - "pnpm nx build:cjs:internal:watch devextreme -c production" + "pnpm nx build:npm:esm:watch devextreme -c qunit", + "pnpm nx build:npm:esm:internal:watch devextreme -c qunit" ], "cwd": "{projectRoot}", "parallel": true @@ -1729,7 +1815,7 @@ "pnpm nx clean:artifacts devextreme", "pnpm nx build:localization devextreme", "pnpm nx build:transpile devextreme -c ci", - "pnpm nx run-many --targets=bundle:debug,build:vectormap,copy:vendor --projects=devextreme --parallel" + "pnpm nx run-many --targets=build:vectormap,copy:vendor --projects=devextreme --parallel" ], "parallel": false }, @@ -1755,58 +1841,9 @@ ], "cache": true, "metadata": { - "description": "Dev/CI test build. Skips prod bundles, aspnet, declarations, npm, and license checks." + "description": "Dev/CI QUnit build (native ESM import-map). Skips all CJS transpile/bundle steps, npm CJS dual-mode, prod bundles, aspnet, declarations, npm packing, and license checks." } }, - "build:systemjs": { - "executor": "nx:run-commands", - "options": { - "cwd": "{projectRoot}", - "parallel": true, - "commands": [ - "node testing/systemjs-builder.js --transpile=modules", - "node testing/systemjs-builder.js --transpile=testing", - "node testing/systemjs-builder.js --transpile=css", - "node testing/systemjs-builder.js --transpile=js-vendors" - ] - }, - "dependsOn": [ - "build:dev" - ], - "inputs": [ - "internalPackageEnv", - { - "env": "DEVEXTREME_TEST_CI" - }, - { - "dependentTasksOutputFiles": "packages/devextreme/artifacts/transpiled/**/*" - }, - { - "dependentTasksOutputFiles": "packages/devextreme/artifacts/css/dx.light.css" - }, - { - "dependentTasksOutputFiles": "packages/devextreme/artifacts/css/dx.material.blue.light.css" - }, - { - "dependentTasksOutputFiles": "packages/devextreme/artifacts/css/dx.fluent.blue.light.css" - }, - { - "dependentTasksOutputFiles": "packages/devextreme/artifacts/css/dx-gantt.css" - }, - "{projectRoot}/testing/content/**/*", - "{projectRoot}/testing/helpers/**/*", - "{projectRoot}/testing/tests/**/*", - "{projectRoot}/testing/systemjs-builder.js", - "{workspaceRoot}/pnpm-lock.yaml" - ], - "outputs": [ - "{projectRoot}/artifacts/transpiled-systemjs", - "{projectRoot}/artifacts/transpiled-testing", - "{projectRoot}/artifacts/css-systemjs", - "{projectRoot}/artifacts/js-systemjs" - ], - "cache": true - }, "dev": { "executor": "nx:run-commands", "cache": false, @@ -1827,7 +1864,6 @@ "commands": [ "pnpm nx build:transpile:watch devextreme", "pnpm nx build:devextreme-bundler-config:watch devextreme", - "pnpm nx bundle:watch devextreme", "pnpm nx test-env devextreme" ] } diff --git a/packages/devextreme/testing/helpers/chartMocks.js b/packages/devextreme/testing/helpers/chartMocks.js index 5e7a2ba7c4d5..f7acef832d79 100644 --- a/packages/devextreme/testing/helpers/chartMocks.js +++ b/packages/devextreme/testing/helpers/chartMocks.js @@ -16,6 +16,8 @@ import { } from './vizMocks.js'; import { Range } from 'viz/translators/range'; +const mutableSeriesFamilyModule = seriesFamilyModule.default ?? seriesFamilyModule; + const LoadingIndicatorOrig = loadingIndicatorModule.LoadingIndicator; const firstCategory = 'First'; @@ -394,7 +396,7 @@ export const resetMockFactory = function resetMockFactory() { }; export const setupSeriesFamily = function() { - seriesFamilyModule.SeriesFamily = function(options) { + mutableSeriesFamilyModule.SeriesFamily = function(options) { return new MockSeriesFamily(options); }; }; diff --git a/packages/devextreme/testing/helpers/data.errorHandlingHelper.js b/packages/devextreme/testing/helpers/data.errorHandlingHelper.js index 9e4d4d445357..329c36b0f3cb 100644 --- a/packages/devextreme/testing/helpers/data.errorHandlingHelper.js +++ b/packages/devextreme/testing/helpers/data.errorHandlingHelper.js @@ -1,16 +1,8 @@ -(function(root, factory) { - root.DevExpress = root.DevExpress || {}; - root.DevExpress.data = root.DevExpress.data || {}; - root.DevExpress.data.testing = root.DevExpress.data.testing || {}; - - if(typeof define === 'function' && define.amd) { - define(function(require, exports, module) { - root.DevExpress.data.testing.ErrorHandlingHelper = module.exports = factory(require('jquery'), require('core/class'), require('common/data/errors')); - }); - } else { - root.DevExpress.data.testing.ErrorHandlingHelper = factory(window.jQuery, DevExpress.Class, DevExpress.data); - } -}(window, function($, Class, errorsModule) { +import $ from 'jquery'; +import Class from 'core/class'; +import * as errorsModule from 'common/data/errors'; + +const __moduleExports = (function($, Class, errorsModule) { return Class.inherit({ ctor: function() { @@ -76,4 +68,11 @@ }); } }); -})); +})($, Class, errorsModule); + +window.DevExpress = window.DevExpress || {}; +window.DevExpress.data = window.DevExpress.data || {}; +window.DevExpress.data.testing = window.DevExpress.data.testing || {}; +window.DevExpress.data.testing.ErrorHandlingHelper = __moduleExports; + +export default __moduleExports; diff --git a/packages/devextreme/testing/helpers/dataGridMocks.js b/packages/devextreme/testing/helpers/dataGridMocks.js index 966f4ccb369a..418f18963e79 100644 --- a/packages/devextreme/testing/helpers/dataGridMocks.js +++ b/packages/devextreme/testing/helpers/dataGridMocks.js @@ -1,32 +1,46 @@ -let gridBaseMock; +import $ from 'jquery'; +import gridCoreModule from '__internal/grids/data_grid/m_core'; +import columnResizingReorderingModule from '__internal/grids/data_grid/module_not_extended/columns_resizing_reordering'; +import domUtilsModule from '__internal/core/utils/m_dom'; +import commonUtilsModule from '__internal/core/utils/m_common'; +import typeUtilsModule from '__internal/core/utils/m_type'; +import ArrayStoreModule from 'common/data/array_store'; +import gridBaseMockModule from './gridBaseMocks.js'; -/* global jQuery */ -if(typeof define === 'function' && define.amd) { - define(function(require, exports, module) { - gridBaseMock = require('./gridBaseMocks.js'); +const gridBaseMock = gridBaseMockModule.default ?? gridBaseMockModule; +const gridCore = gridCoreModule.default ?? gridCoreModule; +const columnResizingReordering = columnResizingReorderingModule.default ?? columnResizingReorderingModule; +const domUtils = domUtilsModule.default ?? domUtilsModule; +const commonUtils = commonUtilsModule.default ?? commonUtilsModule; +const typeUtils = typeUtilsModule.default ?? typeUtilsModule; +const ArrayStore = ArrayStoreModule.default ?? ArrayStoreModule; - window.dataGridMocks = module.exports = gridBaseMock( - require('jquery'), - require('__internal/grids/data_grid/m_core').default, - require('__internal/grids/data_grid/module_not_extended/columns_resizing_reordering').default, - require('__internal/core/utils/m_dom'), - require('__internal/core/utils/m_common'), - require('__internal/core/utils/m_type'), - require('common/data/array_store'), - 'DataGrid' - ); - }); -} else { - gridBaseMock = DevExpress.require('./gridBaseMocks.js'); +const dataGridMocks = gridBaseMock( + $, + gridCore, + columnResizingReordering, + domUtils, + commonUtils, + typeUtils, + ArrayStore, + 'DataGrid' +); - jQuery.extend(window, gridBaseMock( - jQuery, - DevExpress.require('__internal/grids/data_grid/m_core'), - DevExpress.require('__internal/grids/data_grid/module_not_extended/columns_resizing_reordering'), - DevExpress.require('__internal/core/utils/m_dom'), - DevExpress.require('__internal/core/utils/m_common'), - DevExpress.require('__internal/core/utils/m_type'), - DevExpress.require('common/data/array_store'), - 'DataGrid' - )); -} +window.dataGridMocks = dataGridMocks; + +export const setupDataGridModules = dataGridMocks.setupDataGridModules; +export const MockDataController = dataGridMocks.MockDataController; +export const MockEditingController = dataGridMocks.MockEditingController; +export const MockSelectionController = dataGridMocks.MockSelectionController; +export const MockColumnsController = dataGridMocks.MockColumnsController; +export const MockTablePositionViewController = dataGridMocks.MockTablePositionViewController; +export const MockGridDataSource = dataGridMocks.MockGridDataSource; +export const getCells = dataGridMocks.getCells; +export const MockColumnsSeparatorView = dataGridMocks.MockColumnsSeparatorView; +export const MockTrackerView = dataGridMocks.MockTrackerView; +export const MockDraggingPanel = dataGridMocks.MockDraggingPanel; +export const TestDraggingHeader = dataGridMocks.TestDraggingHeader; +export const generateItems = dataGridMocks.generateItems; +export const generateNestedData = dataGridMocks.generateNestedData; + +export default dataGridMocks; diff --git a/packages/devextreme/testing/helpers/esm-shims/fluent_blue_light.css.js b/packages/devextreme/testing/helpers/esm-shims/fluent_blue_light.css.js new file mode 100644 index 000000000000..28ba858f51a8 --- /dev/null +++ b/packages/devextreme/testing/helpers/esm-shims/fluent_blue_light.css.js @@ -0,0 +1,5 @@ +import { injectStylesheet } from './injectStylesheet.js'; + +await injectStylesheet('/packages/devextreme/artifacts/css/dx.fluent.blue.light.css', { + themeName: 'fluent.blue.light', +}); diff --git a/packages/devextreme/testing/helpers/esm-shims/gantt.css.js b/packages/devextreme/testing/helpers/esm-shims/gantt.css.js new file mode 100644 index 000000000000..e247d21d5527 --- /dev/null +++ b/packages/devextreme/testing/helpers/esm-shims/gantt.css.js @@ -0,0 +1,3 @@ +import { injectStylesheet } from './injectStylesheet.js'; + +await injectStylesheet('/packages/devextreme/artifacts/css/dx-gantt.css'); diff --git a/packages/devextreme/testing/helpers/esm-shims/injectStylesheet.js b/packages/devextreme/testing/helpers/esm-shims/injectStylesheet.js new file mode 100644 index 000000000000..55eacd3c7014 --- /dev/null +++ b/packages/devextreme/testing/helpers/esm-shims/injectStylesheet.js @@ -0,0 +1,57 @@ +/** + * Injects a stylesheet once for ESM import-map QUnit mode + * (`*.css!` suite imports resolve here). + * + * Only appends ``. + * Do not add dx-theme-* classes on body — that belongs to themes.attachCssClasses + * on `.dx-viewport` and would change typography/layout. + * + * Returns a Promise so importers can `await` load — otherwise tests that + * assert computed styles race the async fetch. + * + * @param {string} href + * @param {{ themeName?: string }} [options] + * themeName — optional `data-theme` (fluent.blue.light / generic.light / …) + */ +export function injectStylesheet(href, options = {}) { + const existing = document.querySelector(`link[data-dx-esm-css="${href}"]`); + if(existing) { + return waitForStylesheet(existing, href); + } + + const link = document.createElement('link'); + link.rel = 'stylesheet'; + link.href = href; + link.setAttribute('data-dx-esm-css', href); + if(options.themeName) { + link.setAttribute('data-theme', options.themeName); + } + document.head.appendChild(link); + return waitForStylesheet(link, href); +} + +function waitForStylesheet(link, href) { + if(link.sheet || link.dataset.dxEsmCssLoaded === '1') { + return Promise.resolve(); + } + + return new Promise((resolve, reject) => { + const onLoad = () => { + link.dataset.dxEsmCssLoaded = '1'; + resolve(); + }; + const onError = () => { + reject(new Error(`Failed to load stylesheet: ${href}`)); + }; + + link.addEventListener('load', onLoad, { once: true }); + link.addEventListener('error', onError, { once: true }); + + // Cached stylesheets may already be applied before listeners attach + if(link.sheet) { + link.removeEventListener('load', onLoad); + link.removeEventListener('error', onError); + onLoad(); + } + }); +} diff --git a/packages/devextreme/testing/helpers/esm-shims/jquery.js b/packages/devextreme/testing/helpers/esm-shims/jquery.js new file mode 100644 index 000000000000..a6a3df9f758a --- /dev/null +++ b/packages/devextreme/testing/helpers/esm-shims/jquery.js @@ -0,0 +1,17 @@ +/** + * ESM jquery shim for QUnit import-map loader. + * jQuery is loaded via classic script tag before modules run; + * run-suite calls `jQuery.noConflict()` which clears `window.$`. + * Re-attach `$` so suites that use the global alias (without importing + * jquery) keep working. + */ +const $ = window.jQuery; + +if(!$ || typeof $.fn === 'undefined') { + throw new Error('ESM jquery shim: window.jQuery is not available'); +} + +window.$ = $; + +export default $; +export { $ }; diff --git a/packages/devextreme/testing/helpers/esm-shims/jspdf_autotable.js b/packages/devextreme/testing/helpers/esm-shims/jspdf_autotable.js new file mode 100644 index 000000000000..cbd2e5ff587b --- /dev/null +++ b/packages/devextreme/testing/helpers/esm-shims/jspdf_autotable.js @@ -0,0 +1,37 @@ +/** + * jspdf-autotable side-effect import under native ESM. + * The vendor build attaches itself through a CJS require call, which is + * unavailable in the browser — call applyPlugin explicitly instead. + * + * Note: the `.mjs` build exports `autoTable` only as default + * (`export { …, autoTable as default }`), not as a named export. + */ +import { jsPDF } from 'jspdf'; +/* eslint-disable import/named -- vendor ESM re-exports include default + named applyPlugin */ +import autoTable, { + Cell, + CellHookData, + Column, + Row, + Table, + __createTable, + __drawTable, + applyPlugin, +} from '../../../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.mjs'; +/* eslint-enable import/named */ + +const JsPdfCtor = typeof jsPDF === 'function' ? jsPDF : jsPDF.jsPDF; +applyPlugin(JsPdfCtor); + +export { + Cell, + CellHookData, + Column, + Row, + Table, + __createTable, + __drawTable, + applyPlugin, + autoTable, +}; +export default autoTable; diff --git a/packages/devextreme/testing/helpers/esm-shims/knockout.js b/packages/devextreme/testing/helpers/esm-shims/knockout.js new file mode 100644 index 000000000000..b1f45f77edec --- /dev/null +++ b/packages/devextreme/testing/helpers/esm-shims/knockout.js @@ -0,0 +1,12 @@ +/** + * ESM knockout shim for QUnit import-map loader. + * Knockout is loaded via classic script tag before modules run. + */ +const ko = window.ko; + +if(!ko) { + throw new Error('ESM knockout shim: window.ko is not available'); +} + +export default ko; +export { ko }; diff --git a/packages/devextreme/testing/helpers/esm-shims/material_blue_light.css.js b/packages/devextreme/testing/helpers/esm-shims/material_blue_light.css.js new file mode 100644 index 000000000000..0c9ff647951b --- /dev/null +++ b/packages/devextreme/testing/helpers/esm-shims/material_blue_light.css.js @@ -0,0 +1,5 @@ +import { injectStylesheet } from './injectStylesheet.js'; + +await injectStylesheet('/packages/devextreme/artifacts/css/dx.material.blue.light.css', { + themeName: 'material.blue.light', +}); diff --git a/packages/devextreme/testing/helpers/esm-shims/mutable_facade.js b/packages/devextreme/testing/helpers/esm-shims/mutable_facade.js new file mode 100644 index 000000000000..8cc00339e1b3 --- /dev/null +++ b/packages/devextreme/testing/helpers/esm-shims/mutable_facade.js @@ -0,0 +1,50 @@ +/** + * Shared helpers for mutable ESM facades used by QUnit stubbing. + */ +export function wrapCtor(api, name) { + const ExportWrapper = function(...args) { + const Impl = api[name]; + if(new.target) { + return new Impl(...args); + } + return Impl.apply(this, args); + }; + Object.defineProperty(ExportWrapper, 'name', { value: name, configurable: true }); + // Point at the live implementation prototype so stubClass(import { X }) + // sees real methods (e.g. vizMocks Tooltip/Title/ExportMenu). + // Also inherit statics (Class.inherit / redefine / parent / …) so + // `BaseThemeManager.inherit(...)` keeps working under the facade. + const Impl = api[name]; + if(typeof Impl === 'function') { + Object.setPrototypeOf(ExportWrapper, Impl); + if(Impl.prototype) { + ExportWrapper.prototype = Impl.prototype; + } + } + return ExportWrapper; +} + +/** + * @param {object} original + * @param {string} globalKey + * @param {Record} [debugSets] map DEBUG_set_* → api property name + */ +export function createMutableApi(original, globalKey, debugSets = {}) { + if(globalThis[globalKey]) { + return globalThis[globalKey]; + } + + const api = { ...original }; + Object.entries(debugSets).forEach(([debugName, propName]) => { + const originalDebugSet = api[debugName]; + api[debugName] = (value) => { + api[propName] = value; + if(typeof originalDebugSet === 'function') { + originalDebugSet(value); + } + }; + }); + + globalThis[globalKey] = api; + return api; +} diff --git a/packages/devextreme/testing/helpers/esm-shims/themes.js b/packages/devextreme/testing/helpers/esm-shims/themes.js new file mode 100644 index 000000000000..3aa9ec10dfa9 --- /dev/null +++ b/packages/devextreme/testing/helpers/esm-shims/themes.js @@ -0,0 +1,48 @@ +/** + * Mutable facade for ui/themes — QUnit stubs replace api.isMaterial / isFluent / + * isMaterialBased / isGeneric / current on the default export object. + * + * Named exports always forward to the current api.* implementation so + * library `import { isMaterial }` keeps working after stubs. + * + * api is stored on globalThis so import-map and static-redirect URLs + * (cache-buster differences) still share one stubbable object. + */ +import * as original from '../../../artifacts/transpiled-esm-npm/esm/__internal/ui/themes.js?dx-original=1'; + +const GLOBAL_KEY = '__dxMutableUiThemes'; + +const api = globalThis[GLOBAL_KEY] ?? (globalThis[GLOBAL_KEY] = { + ...original, + // Keep composition live so stubbing isMaterial / isFluent affects isMaterialBased. + isMaterialBased(themeName) { + return api.isMaterial(themeName) || api.isFluent(themeName); + }, +}); + +function wrapExport(name) { + return function(...args) { + return api[name](...args); + }; +} + +export const setDefaultTimeout = wrapExport('setDefaultTimeout'); +export const init = wrapExport('init'); +export const initialized = wrapExport('initialized'); +export const resetTheme = wrapExport('resetTheme'); +export const ready = wrapExport('ready'); +export const waitWebFont = wrapExport('waitWebFont'); +export const isWebFontLoaded = wrapExport('isWebFontLoaded'); +export const isCompact = wrapExport('isCompact'); +export const isDark = wrapExport('isDark'); +export const isGeneric = wrapExport('isGeneric'); +export const isMaterial = wrapExport('isMaterial'); +export const isFluent = wrapExport('isFluent'); +export const isMaterialBased = wrapExport('isMaterialBased'); +export const detachCssClasses = wrapExport('detachCssClasses'); +export const attachCssClasses = wrapExport('attachCssClasses'); +export const current = wrapExport('current'); +export const waitForThemeLoad = wrapExport('waitForThemeLoad'); +export const isPendingThemeLoaded = wrapExport('isPendingThemeLoaded'); + +export default api; diff --git a/packages/devextreme/testing/helpers/esm-shims/tslib.js b/packages/devextreme/testing/helpers/esm-shims/tslib.js new file mode 100644 index 000000000000..377dace0c5bc --- /dev/null +++ b/packages/devextreme/testing/helpers/esm-shims/tslib.js @@ -0,0 +1,41 @@ +/** + * Minimal tslib fallback for QUnit when the package is not hoisted. + * Covers helpers used by rrule's ESM build. + */ +export function __assign(target) { + for(let i = 1; i < arguments.length; i++) { + const source = arguments[i]; + for(const key in source) { + if(Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + return target; +} + +export function __extends(derived, base) { + Object.setPrototypeOf(derived, base); + function PrototypeBridge() { + this.constructor = derived; + } + PrototypeBridge.prototype = base === null ? Object.create(base) : base.prototype; + // eslint-disable-next-line new-cap, no-new + derived.prototype = new PrototypeBridge(); +} + +export function __spreadArray(to, from, pack) { + if(pack || arguments.length === 2) { + let packed; + for(let i = 0, length = from.length; i < length; i++) { + if(packed || !(i in from)) { + if(!packed) { + packed = Array.prototype.slice.call(from, 0, i); + } + packed[i] = from[i]; + } + } + return to.concat(packed || Array.prototype.slice.call(from)); + } + return to.concat(from); +} diff --git a/packages/devextreme/testing/helpers/esm-shims/zod-to-json-schema.js b/packages/devextreme/testing/helpers/esm-shims/zod-to-json-schema.js new file mode 100644 index 000000000000..c1ce5b58b1a2 --- /dev/null +++ b/packages/devextreme/testing/helpers/esm-shims/zod-to-json-schema.js @@ -0,0 +1,8 @@ +/** + * Minimal zod-to-json-schema stub for QUnit ESM / import-map loader. + */ +export function zodToJsonSchema() { + return { type: 'object' }; +} + +export default zodToJsonSchema; diff --git a/packages/devextreme/testing/helpers/esm-shims/zod.js b/packages/devextreme/testing/helpers/esm-shims/zod.js new file mode 100644 index 000000000000..489d0bbcf5ba --- /dev/null +++ b/packages/devextreme/testing/helpers/esm-shims/zod.js @@ -0,0 +1,35 @@ +/** + * Minimal zod stub for QUnit ESM / import-map loader. + */ +const z = { + object() { return z; }, + string() { return z; }, + boolean() { return z; }, + number() { return z; }, + date() { return z; }, + null() { return z; }, + enum() { return z; }, + union() { return z; }, + array() { return z; }, + tuple() { return z; }, + literal() { return z; }, + record() { return z; }, + lazy() { return z; }, + optional() { return z; }, + nullable() { return z; }, + // eslint-disable-next-line spellcheck/spell-checker + nullish() { return z; }, + strict() { return z; }, + int() { return z; }, + // eslint-disable-next-line spellcheck/spell-checker + nonnegative() { return z; }, + positive() { return z; }, + min() { return z; }, + max() { return z; }, + transform() { return z; }, + describe() { return z; }, + safeParse() { return { success: true, data: {} }; }, +}; + +export { z }; +export default z; diff --git a/packages/devextreme/testing/helpers/executeAsyncMock.js b/packages/devextreme/testing/helpers/executeAsyncMock.js index cd52380fd3a7..5da48be090e1 100644 --- a/packages/devextreme/testing/helpers/executeAsyncMock.js +++ b/packages/devextreme/testing/helpers/executeAsyncMock.js @@ -1,28 +1,20 @@ -(function(root, factory) { - root.DevExpress = root.DevExpress || {}; - root.DevExpress.testing = root.DevExpress.testing || {}; +import commonUtils from '__internal/core/utils/m_common'; - if(typeof define === 'function' && define.amd) { - define(function(require, exports, module) { - root.DevExpress.testing.executeAsyncMock = module.exports = factory(require('__internal/core/utils/m_common').default); - }); - } else { - root.DevExpress.testing.executeAsyncMock = factory(DevExpress.utils.common); - } -}(window, function(commonUtils) { - const originalExecuteAsync = commonUtils.executeAsync; - - return { - setup: function() { - commonUtils.executeAsync = function(action, context) { - return originalExecuteAsync.apply(this, [action, context, function(callback) { return callback.apply(this, arguments); }]); - }; - }, - teardown: function() { - commonUtils.executeAsync = originalExecuteAsync; - } - }; +const originalExecuteAsync = commonUtils.executeAsync; -})); +const executeAsyncMock = { + setup: function() { + commonUtils.executeAsync = function(action, context) { + return originalExecuteAsync.apply(this, [action, context, function(callback) { return callback.apply(this, arguments); }]); + }; + }, + teardown: function() { + commonUtils.executeAsync = originalExecuteAsync; + } +}; +window.DevExpress = window.DevExpress || {}; +window.DevExpress.testing = window.DevExpress.testing || {}; +window.DevExpress.testing.executeAsyncMock = executeAsyncMock; +export default executeAsyncMock; diff --git a/packages/devextreme/testing/helpers/includeThemesLinks.js b/packages/devextreme/testing/helpers/includeThemesLinks.js index a6e01e6d0104..6d8b3d53ee93 100644 --- a/packages/devextreme/testing/helpers/includeThemesLinks.js +++ b/packages/devextreme/testing/helpers/includeThemesLinks.js @@ -1,9 +1,12 @@ -const themesList = ['generic.light', 'material.blue.light']; +const themesList = [ + { name: 'generic.light', href: '/packages/devextreme/artifacts/css/dx.light.css' }, + { name: 'material.blue.light', href: '/packages/devextreme/artifacts/css/dx.material.blue.light.css' }, +]; -themesList.forEach(theme => { +themesList.forEach(({ name, href }) => { const link = document.createElement('link'); link.setAttribute('rel', 'dx-theme'); - link.setAttribute('data-theme', theme); - link.setAttribute('href', SystemJS.normalizeSync(theme.replace(/\./g, '_') + '.css')); + link.setAttribute('data-theme', name); + link.setAttribute('href', href); document.head.appendChild(link); }); diff --git a/packages/devextreme/testing/helpers/keyboardMock.js b/packages/devextreme/testing/helpers/keyboardMock.js index ade1eefd1974..1107d8978d43 100644 --- a/packages/devextreme/testing/helpers/keyboardMock.js +++ b/packages/devextreme/testing/helpers/keyboardMock.js @@ -1,16 +1,8 @@ -let focused; - -(function(root, factory) { - if(typeof define === 'function' && define.amd) { - define(function(require, exports, module) { - focused = require('__internal/core/utils/m_selectors').focused; - root.keyboardMock = module.exports = factory(require('jquery'), require('inferno')); - }); - } else { - focused = DevExpress.require('__internal/core/utils/m_selectors').focused; - root.keyboardMock = factory(root.jQuery); - } -}(window, function($, inferno) { +import $ from 'jquery'; +import * as inferno from 'inferno'; +import { focused } from '__internal/core/utils/m_selectors'; + +const keyboardMock = (function($, inferno) { let $element; let caret; @@ -427,4 +419,6 @@ let focused; } }; }; -})); +})($, inferno); + +export default keyboardMock; diff --git a/packages/devextreme/testing/helpers/memoryLeaksHelper.js b/packages/devextreme/testing/helpers/memoryLeaksHelper.js index 6a4efcca90a9..bab8140b8826 100644 --- a/packages/devextreme/testing/helpers/memoryLeaksHelper.js +++ b/packages/devextreme/testing/helpers/memoryLeaksHelper.js @@ -1,17 +1,6 @@ -(function(root, factory) { - /* global jQuery */ - if(typeof define === 'function' && define.amd) { - define(function(require, exports, module) { - root.memoryLeaksHelper = module.exports = factory( - require('jquery') - ); - }); - } else { - jQuery.extend(window, factory( - jQuery - )); - } -}(window, function($) { +import $ from 'jquery'; + +const __moduleExports = (function($) { const exports = {}; @@ -142,4 +131,8 @@ }; return exports; -})); +})($); + +window.memoryLeaksHelper = __moduleExports; + +export default __moduleExports; diff --git a/packages/devextreme/testing/helpers/mockModule.js b/packages/devextreme/testing/helpers/mockModule.js index 5864029817d4..2cbbd4521fbd 100644 --- a/packages/devextreme/testing/helpers/mockModule.js +++ b/packages/devextreme/testing/helpers/mockModule.js @@ -1,12 +1,13 @@ /* eslint-disable no-undef */ -const $ = require('jquery'); - -exports.mock = (module, value) => { - const normalizedName = System.normalizeSync(module); - System.delete(normalizedName); - value.__esModule = true; - $.extend({ default: value }); - System.set(normalizedName, System.newModule($.extend({ default: value }, value))); - return value; +/** + * Module replacement helper — not supported under native ESM + * (no module registry). Mutate a mutable import-map facade instead + * (see trackerMock.js / esm-shims/viz_chart_tracker.js). + */ +exports.mock = function mock() { + throw new Error( + 'mockModule.mock is not supported under native ESM; ' + + 'mutate the target module\'s mutable facade (default export) instead', + ); }; diff --git a/packages/devextreme/testing/helpers/nativePointerMock.js b/packages/devextreme/testing/helpers/nativePointerMock.js index fab9e3227981..c50749f0d0f5 100644 --- a/packages/devextreme/testing/helpers/nativePointerMock.js +++ b/packages/devextreme/testing/helpers/nativePointerMock.js @@ -1,13 +1,6 @@ -(function(root, factory) { - /* global jQuery */ - if(typeof define === 'function' && define.amd) { - define(function(require, exports, module) { - root.nativePointerMock = module.exports = factory(require('jquery')); - }); - } else { - root.nativePointerMock = factory(jQuery); - } -}(window, function($) { +import $ from 'jquery'; + +const __moduleExports = (function($) { const UA = (function() { const ua = window.navigator.userAgent; let matches; @@ -980,4 +973,8 @@ return result; -})); +})($); + +window.nativePointerMock = __moduleExports; + +export default __moduleExports; diff --git a/packages/devextreme/testing/helpers/noDiagram.js b/packages/devextreme/testing/helpers/noDiagram.js index 1d0e288bbae3..189f31a52683 100644 --- a/packages/devextreme/testing/helpers/noDiagram.js +++ b/packages/devextreme/testing/helpers/noDiagram.js @@ -1,4 +1,4 @@ if(window.DevExpress) { window.DevExpress.diagram = undefined; } -module.exports = null; +export default null; diff --git a/packages/devextreme/testing/helpers/noGantt.js b/packages/devextreme/testing/helpers/noGantt.js index ed0a8a552761..abc0e1f6294f 100644 --- a/packages/devextreme/testing/helpers/noGantt.js +++ b/packages/devextreme/testing/helpers/noGantt.js @@ -1,4 +1,4 @@ if(window.DevExpress) { window.DevExpress.Gantt = undefined; } -module.exports = null; +export default null; diff --git a/packages/devextreme/testing/helpers/noJQuery.js b/packages/devextreme/testing/helpers/noJQuery.js index 25af527694e7..7646bbd17d04 100644 --- a/packages/devextreme/testing/helpers/noJQuery.js +++ b/packages/devextreme/testing/helpers/noJQuery.js @@ -1 +1 @@ -window.jQuery = module.exports = null; +export default null; diff --git a/packages/devextreme/testing/helpers/pointerMock.js b/packages/devextreme/testing/helpers/pointerMock.js index 439c852ea5b6..6b89ba1b2301 100644 --- a/packages/devextreme/testing/helpers/pointerMock.js +++ b/packages/devextreme/testing/helpers/pointerMock.js @@ -1,17 +1,9 @@ -(function(root, factory) { - /* global jQuery */ - if(typeof define === 'function' && define.amd) { - define(function(require, exports, module) { - root.pointerMock = module.exports = factory( - require('jquery'), - require('inferno'), - require('common/core/events/gesture/emitter.gesture'), - require('common/core/events/click')); - }); - } else { - root.pointerMock = factory(jQuery, DevExpress.events.GestureEmitter, DevExpress.events.click); - } -}(window, function($, inferno, GestureEmitter, clickEvent) { +import $ from 'jquery'; +import * as inferno from 'inferno'; +import GestureEmitter from 'common/core/events/gesture/emitter.gesture'; +import * as clickEvent from 'common/core/events/click'; + +const pointerMock = (function($, inferno, GestureEmitter, clickEvent) { GestureEmitter.touchBoundary(0); @@ -236,4 +228,6 @@ } }; }; -})); +})($, inferno, GestureEmitter, clickEvent); + +export default pointerMock; diff --git a/packages/devextreme/testing/helpers/positionFixtures.js b/packages/devextreme/testing/helpers/positionFixtures.js index cada61dab25b..978a65f1fabc 100644 --- a/packages/devextreme/testing/helpers/positionFixtures.js +++ b/packages/devextreme/testing/helpers/positionFixtures.js @@ -1,12 +1,6 @@ -(function(root, factory) { - if(typeof define === 'function' && define.amd) { - define(function(require, exports, module) { - root.fixtures = module.exports = factory(require('jquery')); - }); - } else { - root.fixtures = factory(root.jQuery); - } -}(window, function($) { +import $ from 'jquery'; + +const __moduleExports = (function($) { const fixtures = { simple: { @@ -258,4 +252,8 @@ }; return fixtures; -})); +})($); + +window.fixtures = __moduleExports; + +export default __moduleExports; diff --git a/packages/devextreme/testing/helpers/publicModulesHelper.js b/packages/devextreme/testing/helpers/publicModulesHelper.js index bff3366338de..3c39a4f42755 100644 --- a/packages/devextreme/testing/helpers/publicModulesHelper.js +++ b/packages/devextreme/testing/helpers/publicModulesHelper.js @@ -1,12 +1,6 @@ -(function(root, factory) { - if(typeof define === 'function' && define.amd) { - define(function(require, exports, module) { - root.testGlobalExports = module.exports = factory(require('jquery')); - }); - } else { - root.testGlobalExports = factory(root.jQuery); - } -}(window, function($) { +import $ from 'jquery'; + +const __moduleExports = (function($) { return function(namespaces, fields) { $.each(namespaces, function(namespaceName, namespace) { $.each(fields, function(fieldName, fieldValue) { @@ -17,4 +11,8 @@ }); }); }; -})); +})($); + +window.testGlobalExports = __moduleExports; + +export default __moduleExports; diff --git a/packages/devextreme/testing/helpers/quillDependencies/noQuill.js b/packages/devextreme/testing/helpers/quillDependencies/noQuill.js index e45fa7973937..3b197fe204b6 100644 --- a/packages/devextreme/testing/helpers/quillDependencies/noQuill.js +++ b/packages/devextreme/testing/helpers/quillDependencies/noQuill.js @@ -1 +1,2 @@ -window.Quill = module.exports = null; +window.Quill = null; +export default null; diff --git a/packages/devextreme/testing/helpers/qunitExtensions.js b/packages/devextreme/testing/helpers/qunitExtensions.js index c7b3344d568b..75507728a1bb 100644 --- a/packages/devextreme/testing/helpers/qunitExtensions.js +++ b/packages/devextreme/testing/helpers/qunitExtensions.js @@ -514,7 +514,7 @@ if(timerType === 'timeouts') { if( callback.indexOf('.Deferred.exceptionHook') > -1 || // NOTE: jQuery.Deferred are now asynchronous - callback.indexOf('e._drain()') > -1 // NOTE: SystemJS Promise polyfill + callback.indexOf('e._drain()') > -1 // NOTE: legacy Promise polyfill ) { return true; } diff --git a/packages/devextreme/testing/helpers/stubs/zodStub.js b/packages/devextreme/testing/helpers/stubs/zodStub.js deleted file mode 100644 index 668e5fd8ecd2..000000000000 --- a/packages/devextreme/testing/helpers/stubs/zodStub.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Minimal zod stub for QUnit / SystemJS tests. - * - * Uses AMD define() when available (CSP mode) and falls back - * to global assignment for regular SystemJS (NoCsp mode). - */ - -(function() { - const z = { - // top-level constructors - object: function() { return z; }, - string: function() { return z; }, - boolean: function() { return z; }, - number: function() { return z; }, - date: function() { return z; }, - null: function() { return z; }, - enum: function() { return z; }, - union: function() { return z; }, - array: function() { return z; }, - tuple: function() { return z; }, - literal: function() { return z; }, - record: function() { return z; }, - lazy: function() { return z; }, - // chain modifiers - optional: function() { return z; }, - nullable: function() { return z; }, - // eslint-disable-next-line spellcheck/spell-checker - nullish: function() { return z; }, - strict: function() { return z; }, - int: function() { return z; }, - // eslint-disable-next-line spellcheck/spell-checker - nonnegative: function() { return z; }, - positive: function() { return z; }, - min: function() { return z; }, - max: function() { return z; }, - transform: function() { return z; }, - describe: function() { return z; }, - // validation - safeParse: function() { return { success: true, data: {} }; }, - }; - - if(typeof define === 'function') { - define(function(require, exports) { - Object.defineProperty(exports, '__esModule', { value: true }); - exports.z = z; - exports.default = z; - }); - } else { - const root = typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : globalThis; - root.z = z; - root.zod = z; - } -})(); diff --git a/packages/devextreme/testing/helpers/stubs/zodToJsonSchemaStub.js b/packages/devextreme/testing/helpers/stubs/zodToJsonSchemaStub.js deleted file mode 100644 index a7aa7e3e9d70..000000000000 --- a/packages/devextreme/testing/helpers/stubs/zodToJsonSchemaStub.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Minimal zod-to-json-schema stub for QUnit / SystemJS tests. - * - * Uses AMD define() when available (CSP mode) and falls back - * to global assignment for regular SystemJS (NoCsp mode). - */ - -(function() { - const zodToJsonSchema = function() { return { type: 'object' }; }; - - if(typeof define === 'function') { - define(function(require, exports) { - Object.defineProperty(exports, '__esModule', { value: true }); - exports.zodToJsonSchema = zodToJsonSchema; - exports.default = zodToJsonSchema; - }); - } else { - const root = typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : globalThis; - root.zodToJsonSchema = zodToJsonSchema; - } -})(); diff --git a/packages/devextreme/testing/helpers/trackerMock.js b/packages/devextreme/testing/helpers/trackerMock.js index 745abb5717e9..3a930364f4d5 100644 --- a/packages/devextreme/testing/helpers/trackerMock.js +++ b/packages/devextreme/testing/helpers/trackerMock.js @@ -1,13 +1,12 @@ -const mock = require('./mockModule.js').mock; const vizMocks = require('./vizMocks.js'); -const { ChartTracker, PieTracker } = require('viz/chart_components/tracker'); -const ChartTrackerStub = vizMocks.stubClass(ChartTracker); -const PieTrackerStub = vizMocks.stubClass(PieTracker); +// Mutate the import-map facade (see esm-shims/viz_chart_tracker.js). +const trackerModule = require('viz/chart_components/tracker'); -const trackerModule = mock('viz/chart_components/tracker', { - ChartTracker: sinon.spy((parameters) => new ChartTrackerStub(parameters)), - PieTracker: sinon.spy((parameters) => new PieTrackerStub(parameters)) -}); +const ChartTrackerStub = vizMocks.stubClass(trackerModule.ChartTracker); +const PieTrackerStub = vizMocks.stubClass(trackerModule.PieTracker); + +trackerModule.ChartTracker = sinon.spy((parameters) => new ChartTrackerStub(parameters)); +trackerModule.PieTracker = sinon.spy((parameters) => new PieTrackerStub(parameters)); exports.default = trackerModule; exports.__esModule = true; diff --git a/packages/devextreme/testing/helpers/treeListMocks.js b/packages/devextreme/testing/helpers/treeListMocks.js index 45f1d23b83e0..fcb1a8d606a1 100644 --- a/packages/devextreme/testing/helpers/treeListMocks.js +++ b/packages/devextreme/testing/helpers/treeListMocks.js @@ -1,32 +1,44 @@ -let gridBaseMock; +import $ from 'jquery'; +import treeListCoreModule from '__internal/grids/tree_list/m_core'; +import domUtilsModule from '__internal/core/utils/m_dom'; +import commonUtilsModule from '__internal/core/utils/m_common'; +import typeUtilsModule from '__internal/core/utils/m_type'; +import ArrayStoreModule from 'common/data/array_store'; +import gridBaseMockModule from './gridBaseMocks.js'; -/* global jQuery */ -if(typeof define === 'function' && define.amd) { - define(function(require, exports, module) { - gridBaseMock = require('./gridBaseMocks.js'); +const gridBaseMock = gridBaseMockModule.default ?? gridBaseMockModule; +const treeListCore = treeListCoreModule.default ?? treeListCoreModule; +const domUtils = domUtilsModule.default ?? domUtilsModule; +const commonUtils = commonUtilsModule.default ?? commonUtilsModule; +const typeUtils = typeUtilsModule.default ?? typeUtilsModule; +const ArrayStore = ArrayStoreModule.default ?? ArrayStoreModule; - window.treeListMocks = module.exports = gridBaseMock( - require('jquery'), - require('__internal/grids/tree_list/m_core').default, - null, - require('__internal/core/utils/m_dom'), - require('__internal/core/utils/m_common'), - require('__internal/core/utils/m_type'), - require('common/data/array_store'), - 'TreeList' - ); - }); -} else { - gridBaseMock = require('./gridBaseMocks.js'); +const treeListMocks = gridBaseMock( + $, + treeListCore, + null, + domUtils, + commonUtils, + typeUtils, + ArrayStore, + 'TreeList' +); - jQuery.extend(window, gridBaseMock( - jQuery, - DevExpress.require('__internal/grids/tree_list/m_core'), - null, - DevExpress.require('__internal/core/utils/m_dom'), - DevExpress.require('__internal/core/utils/m_common'), - DevExpress.require('__internal/core/utils/m_type'), - DevExpress.require('common/data/array_store'), - 'TreeList' - )); -} +window.treeListMocks = treeListMocks; + +export const setupTreeListModules = treeListMocks.setupTreeListModules; +export const MockDataController = treeListMocks.MockDataController; +export const MockEditingController = treeListMocks.MockEditingController; +export const MockSelectionController = treeListMocks.MockSelectionController; +export const MockColumnsController = treeListMocks.MockColumnsController; +export const MockTablePositionViewController = treeListMocks.MockTablePositionViewController; +export const MockGridDataSource = treeListMocks.MockGridDataSource; +export const getCells = treeListMocks.getCells; +export const MockColumnsSeparatorView = treeListMocks.MockColumnsSeparatorView; +export const MockTrackerView = treeListMocks.MockTrackerView; +export const MockDraggingPanel = treeListMocks.MockDraggingPanel; +export const TestDraggingHeader = treeListMocks.TestDraggingHeader; +export const generateItems = treeListMocks.generateItems; +export const generateNestedData = treeListMocks.generateNestedData; + +export default treeListMocks; diff --git a/packages/devextreme/testing/helpers/vizMocks.js b/packages/devextreme/testing/helpers/vizMocks.js index 8a6838ea73a5..1d96bbb2face 100644 --- a/packages/devextreme/testing/helpers/vizMocks.js +++ b/packages/devextreme/testing/helpers/vizMocks.js @@ -10,7 +10,7 @@ import { Series } from 'viz/series/base_series'; import * as loadingIndicatorModule from 'viz/core/loading_indicator'; import * as exportMenuModule from 'viz/core/export'; import rendererModule from 'viz/core/renderers/renderer_default'; -import * as errors from 'viz/core/errors_warnings'; +import errors from 'viz/core/errors_warnings'; import * as baseWidgetUtils from '__internal/viz/core/base_widget.utils'; import * as typeUtils from 'core/utils/type'; @@ -367,7 +367,17 @@ const Point = stubClass(pointModule.Point); const Legend = stubClass(legendModule.Legend); const Title = stubClass(titleModule.Title); const Tooltip = stubClass(tooltipModule.Tooltip); -const Axis = stubClass(axisModule.Axis); +// ESM npm artifacts strip /// #DEBUG methods (removeDebug: true). +// Restore the ones gauges/charts call on mocks (kept in legacy CJS transpile). +const Axis = stubClass(axisModule.Axis, null, { + $extraFunctions: [ + 'shift', + '_getTickMarkPoints', + '_validateOverlappingMode', + '_getStep', + '_validateDisplayMode', + ], +}); const SeriesStub = stubClass(Series); export { diff --git a/packages/devextreme/testing/helpers/xmlHttpRequestMock.js b/packages/devextreme/testing/helpers/xmlHttpRequestMock.js index cc55e4440a93..604163d61f3f 100644 --- a/packages/devextreme/testing/helpers/xmlHttpRequestMock.js +++ b/packages/devextreme/testing/helpers/xmlHttpRequestMock.js @@ -1,4 +1,4 @@ -/* global $ */ +import $ from 'jquery'; const RealXMLHttpRequest = window.XMLHttpRequest; diff --git a/packages/devextreme/testing/runner/README.md b/packages/devextreme/testing/runner/README.md new file mode 100644 index 000000000000..825019920821 --- /dev/null +++ b/packages/devextreme/testing/runner/README.md @@ -0,0 +1,103 @@ +# QUnit test runner (native ESM) + +Developer notes for the Node HTTP runner that serves QUnit suites with **native ESM + import maps** (no SystemJS). + +Related layout: + +| Path | Role | +| --- | --- | +| `testing/runner/lib/` | Server-side request handling, source rewrites, import-map build | +| `testing/helpers/esm-shims/` | Browser-side shim modules wired through the import map / static redirects | + +After changing TypeScript under `testing/runner/`, recompile (`tsc -p testing/runner/tsconfig.json`) and **restart** the process on port `20060` — templates and rewrite logic are loaded at process start. + +--- + +## `lib/static.ts` + +HTTP static file server for the QUnit runner. + +**Responsibilities:** + +- Resolve and serve workspace files (tests, helpers, artifacts, vendors) with correct content types and cache headers. +- Apply **serve-time transforms** so the browser receives valid ESM: + - QUnit tests/helpers → `cjsInterop.rewriteQunitTestHelperSource` + - `aspnet.js` UMD artifact → `cjsInterop.rewriteAspnetArtifactToEsm` + - Vendor / Globalize / Intl / VectorMap bundles → wrap as ESM modules + - JSON (`?esm-export=1`) → `export default …` +- Serve **generated** mutable facades for modules in `MUTABLE_MODULE_GROUPS` / viz namespace-reexports; redirect only special hand-written cases (e.g. themes). +- For pure `import * as X; export default X` viz reexports, generate facades on the fly via `autoMutableFacade.tryBuildAutoMutableFacade`. +- Support `?dx-original=1` so a shim can import the **real** artifact without being redirected back to itself. + +This module is the integration point: almost every special-case rewrite for QUnit ESM loading goes through `tryServeStatic`. + +--- + +## `lib/cjsInterop.ts` + +Serve-time **CJS → ESM** source rewrites for QUnit tests, helpers, and bundle templates. + +Legacy suites still use `require()`, `module.exports` / `exports.*`, AMD `define(function () { … })`, and CJS-style `import x from 'bare-specifier'`. Native ESM cannot load those as-is. + +**What it does:** + +1. **`require('…')`** → hoisted `import * as __dxReq_N` plus `('default' in ns ? ns.default : { …ns })` at the call site (keeps explicit `default: null` for noJQuery/…; mutable shallow copy only when there is no default — needed when tests assign onto the module object). +2. **`module.exports` / `exports.*`** → wrap the file with a synthetic `module`/`exports` object and emit `export default` + named exports. +3. **Bare default / named imports** → namespace import + CJS default interop (`'default' in ns ? ns.default : …`, merge default object/function into named bindings when needed). +4. **AMD `define(function () { … })`** → IIFE, with imports hoisted to file top (imports inside `if (define.amd)` are illegal in ESM). +5. **Plugin-style JSON** (`file.json!` / `file.json!json`) → absolute URLs with `?esm-export=1`. +6. **`aspnet.js`** → dedicated UMD → ESM conversion (`rewriteAspnetArtifactToEsm`). + +`esm-shims/` files are **excluded** from this pipeline (`isQunitTestOrHelperPath`) — they are already real ESM. + +--- + +## `lib/autoMutableFacade.ts` + +Generates **mutable ESM facades** at request time so QUnit can `sinon.stub` module APIs without editing `packages/devextreme/js`. + +**Two sources of facades:** + +1. **`MUTABLE_MODULE_GROUPS`** ([`mutableModuleGroups.ts`](./lib/mutableModuleGroups.ts)) — explicit list of stub-able modules (animation frame, viz renderer, exporter, …). All aliases share one `globalThis` api; named exports use `wrapCtor` / live forwards. Import map points at the ESM artifact URL; `static.ts` serves the generated facade unless `?dx-original=1`. Codegen lives in `autoMutableFacade.ts`. +2. **Namespace-default reexports** (`import * as X; export default X`) under `viz/` — discovered automatically. + +Hand-written files under `esm-shims/` remain only for **non-generic** cases (themes composition, CSS inject, jquery/knockout globals, vendor stubs). + +Typical generated shape: + +```js +import * as original from '.../module.js?dx-original=1'; +import { createMutableApi, wrapCtor } from '.../mutable_facade.js'; + +const api = createMutableApi(original, '__dxAutoMutable_…'); +export const Foo = wrapCtor(api, 'Foo'); +export default api; +``` + +To stub a new module, add a group entry in [`mutableModuleGroups.ts`](./lib/mutableModuleGroups.ts): + +```ts +{ + internal: '__internal/viz/core/title.js', // real module under esm/ + also: ['viz/core/title.js'], // extra artifact URLs → same facade + extraKeys: ['animation/frame'], // optional bare import-map keys + apiFromDefault: true, // when default export is the stub target +} +``` + +Import-map keys are derived as `strip(.js)` of `internal`/`also`, plus `extraKeys`. Prefer this over a new hand-written shim. +--- + +## `testing/helpers/esm-shims/` + +Browser modules that the import map (and/or `static.ts` artifact redirects) substitute for real package / artifact specifiers during QUnit runs. + +**Why they exist:** + +- **Stubbing / mutation** — prefer `MUTABLE_MODULE_GROUPS` in `mutableModuleGroups.ts` (serve-time generated facades via `autoMutableFacade.ts`). Keep a hand-written shim only for custom composition (e.g. themes). +- **Globals bridge** — e.g. `jquery.js` / `knockout.js` re-export the classic ``; - const integrationImportPaths = getJQueryIntegrationImports(); + // Restore CSP for default runs; `?nocsp` keeps the meta off for suites + // that branch on QUnit.urlParams['nocsp'] (Knockout, aspnet, …). const cspMetaTag = runProps.NoCsp ? '' : ` string; rootDirectory: string; - setNoCacheHeaders: (res: ServerResponse) => void; setStaticCacheHeaders: (res: ServerResponse, searchParams: URLSearchParams) => void; } @@ -18,53 +25,99 @@ export interface StaticFileService { ) => boolean; } +const CONTENT_TYPES: Readonly> = { + '.html': 'text/html; charset=utf-8', + '.htm': 'text/html; charset=utf-8', + '.css': 'text/css; charset=utf-8', + '.js': 'application/javascript; charset=utf-8', + '.mjs': 'application/javascript; charset=utf-8', + '.json': 'application/json; charset=utf-8', + '.xml': 'text/xml; charset=utf-8', + '.xsl': 'text/xml; charset=utf-8', + '.txt': 'text/plain; charset=utf-8', + '.md': 'text/plain; charset=utf-8', + '.log': 'text/plain; charset=utf-8', + '.svg': 'image/svg+xml', + '.png': 'image/png', + '.jpg': 'image/jpeg', + '.jpeg': 'image/jpeg', + '.gif': 'image/gif', + '.ico': 'image/x-icon', + '.woff': 'font/woff', + '.woff2': 'font/woff2', + '.ttf': 'font/ttf', + '.eot': 'application/vnd.ms-fontobject', + '.map': 'application/json; charset=utf-8', + '.wasm': 'application/wasm', +}; + +const JS_CONTENT_TYPE = 'application/javascript; charset=utf-8'; +const ESM_ARTIFACT_MARKER = '/artifacts/transpiled-esm-npm/esm/'; + +function normalizeUrlPath(filePath: string): string { + return filePath.split(path.sep).join('/'); +} + function getContentType(filePath: string): string { - const ext = path.extname(filePath).toLowerCase(); - - switch (ext) { - case '.html': - case '.htm': - return 'text/html; charset=utf-8'; - case '.css': - return 'text/css; charset=utf-8'; - case '.js': - case '.mjs': - return 'application/javascript; charset=utf-8'; - case '.json': - return 'application/json; charset=utf-8'; - case '.xml': - case '.xsl': - return 'text/xml; charset=utf-8'; - case '.txt': - case '.md': - case '.log': - return 'text/plain; charset=utf-8'; - case '.svg': - return 'image/svg+xml'; - case '.png': - return 'image/png'; - case '.jpg': - case '.jpeg': - return 'image/jpeg'; - case '.gif': - return 'image/gif'; - case '.ico': - return 'image/x-icon'; - case '.woff': - return 'font/woff'; - case '.woff2': - return 'font/woff2'; - case '.ttf': - return 'font/ttf'; - case '.eot': - return 'application/vnd.ms-fontobject'; - case '.map': - return 'application/json; charset=utf-8'; - case '.wasm': - return 'application/wasm'; - default: - return 'application/octet-stream'; + return CONTENT_TYPES[path.extname(filePath).toLowerCase()] ?? 'application/octet-stream'; +} + +function sendError(res: ServerResponse, statusCode: number, message: string): boolean { + // Always override any prior Cache-Control (e.g. DX_HTTP_CACHE year-long + // headers set before a transform/read failure). + applyNoCacheHeaders(res); + res.statusCode = statusCode; + res.setHeader('Content-Type', 'text/plain; charset=utf-8'); + res.end(message); + return true; +} + +function sendJsModuleBody(res: ServerResponse, body: string): boolean { + const buffer = Buffer.from(body, 'utf8'); + res.statusCode = 200; + res.setHeader('Content-Type', JS_CONTENT_TYPE); + res.setHeader('Content-Length', String(buffer.length)); + res.end(buffer); + return true; +} + +function sendTransformedJs( + res: ServerResponse, + filePath: string, + transform: (raw: string) => string, + errorMessage: string, +): boolean { + try { + return sendJsModuleBody(res, transform(fs.readFileSync(filePath, 'utf8'))); + } catch { + return sendError(res, 500, errorMessage); + } +} + +/** + * Native ESM requires resolvable URLs. Our transpiled ESM tree uses + * extensionless relative imports (`from './wrapper'`). Resolve those + * to `.js` / `/index.js` on disk so import maps can load artifacts. + * + * Prefer `name.js` over a sibling directory `name/` — otherwise imports like + * `../__internal/integration/jquery` resolve to a directory listing (HTML) + * and the browser reports "Failed to fetch dynamically imported module". + * + * Also: files like `ui.collection_widget.edit` have a dotted basename; + * `path.extname` returns `.edit`, so we must still try appending `.js`. + */ +function resolveStaticFilePath(filePath: string): string | null { + if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) { + return filePath; + } + + for (const candidate of [`${filePath}.js`, `${filePath}.mjs`, path.join(filePath, 'index.js')]) { + if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) { + return candidate; + } } + + return fs.existsSync(filePath) ? filePath : null; } function sendStaticFile(res: ServerResponse, filePath: string, fileSize: number): boolean { @@ -88,6 +141,326 @@ function sendStaticFile(res: ServerResponse, filePath: string, fileSize: number) return true; } +// --- Vendor / UMD → ESM wrappers ------------------------------------------------ + +const ESM_DEFAULT_FROM_CJS = `const __dxVendorExport = module.exports && module.exports.__esModule + && Object.prototype.hasOwnProperty.call(module.exports, 'default') + ? module.exports.default + : module.exports; +export default __dxVendorExport; +`; + +function forceVendorGlobalThis(source: string): string { + return source.replace(/}\(\s*this\s*,/g, '}(globalThis,'); +} + +function wrapVendorCjsBranch( + source: string, + options: { + preamble?: string; + requireShim?: string; + exportsInit?: string; + trailing?: string; + rewriteThis?: boolean; + } = {}, +): string { + const { + preamble = '', + requireShim = '', + exportsInit = '{}', + trailing = ESM_DEFAULT_FROM_CJS, + rewriteThis = true, + } = options; + + const vendorSource = rewriteThis ? forceVendorGlobalThis(source) : source; + + return [ + preamble, + preamble ? '\n' : '', + `const module = { exports: ${exportsInit} };\n`, + 'const exports = module.exports;\n', + 'var define;\n', + requireShim, + vendorSource, + '\n', + trailing, + ].join(''); +} + +/** + * `intl/dist/Intl.complete.js` appends locale data that expects a free + * `IntlPolyfill` binding from the UMD *browser* branch. Forcing CJS breaks + * that, so keep the global branch and re-export the polyfill. + */ +function wrapIntlVendorAsEsm(source: string): string { + return 'var define;\n' + + 'var IntlPolyfill;\n' + + `${source + .replace(/}\(this,/g, '}(globalThis,') + .replace(/e\.IntlPolyfill=r\(\)/g, 'e.IntlPolyfill=IntlPolyfill=r()')}\n` + + 'export default IntlPolyfill;\n'; +} + +/** + * Force the CJS branch of a UMD wrapper and re-export `module.exports` as default. + * Also emit synthetic named exports from the webpack entry module so + * `import Def, * as Ns from 'pkg'` gets CJS-style interop + * (needed by diagram.importer → `Ns.DiagramControl`). + */ +function collectWebpackEntryExportNames(source: string): string[] { + const entryMatch = /var __webpack_exports__ = __webpack_require__\((\d+)\);/.exec(source); + if (!entryMatch) { + return []; + } + + const entryId = entryMatch[1]; + const moduleStart = source.indexOf(`/***/ ${entryId}`); + if (moduleStart < 0) { + return []; + } + + const nextModule = source.indexOf('\n/***/ ', moduleStart + 1); + const moduleSource = nextModule < 0 + ? source.slice(moduleStart) + : source.slice(moduleStart, nextModule); + + const names = new Set(); + const definePropertyRe = /Object\.defineProperty\(\s*exports\s*,\s*["']([^"']+)["']/g; + let match = definePropertyRe.exec(moduleSource); + while (match) { + const name = match[1]; + if (name !== '__esModule' && name !== 'default' && /^[A-Za-z_$][\w$]*$/.test(name)) { + names.add(name); + } + match = definePropertyRe.exec(moduleSource); + } + + return [...names].sort(); +} + +function wrapWebpackVendorAsEsm(source: string): string { + const namedExports = collectWebpackEntryExportNames(source) + .map((name) => `export const ${name} = module.exports.${name};`) + .join('\n'); + + return wrapVendorCjsBranch(source, { + rewriteThis: false, + trailing: `${ESM_DEFAULT_FROM_CJS}${namedExports ? `${namedExports}\n` : ''}`, + }); +} + +/** globalize / cldrjs ship as UMD; native ESM needs a CJS-branch + require shim. */ +function wrapGlobalizeOrCldrAsEsm(source: string, relativeUrlPath: string): string { + const normalized = normalizeUrlPath(relativeUrlPath); + const isCldrMain = normalized.endsWith('/cldrjs/dist/cldr.js'); + const isCldrPlugin = /\/cldrjs\/dist\/cldr\/[^/]+\.js$/i.test(normalized); + const isGlobalizeMain = normalized.endsWith('/globalize/dist/globalize.js'); + const isGlobalizePlugin = normalized.includes('/globalize/dist/globalize/'); + const baseName = path.basename(normalized, '.js'); + const needsNumber = isGlobalizePlugin && (baseName === 'currency' || baseName === 'date'); + + const preamble: string[] = []; + if (isCldrPlugin) { + preamble.push('import __dxCldr from \'cldr\';'); + } else if (isGlobalizeMain || isGlobalizePlugin) { + preamble.push('import __dxCldr from \'cldr\';'); + preamble.push('import \'cldr/event\';'); + if (isGlobalizePlugin) { + preamble.push('import \'cldr/supplemental\';'); + preamble.push('import __dxGlobalize from \'globalize\';'); + if (needsNumber) { + // CJS factory skips `./number`; AMD/DevExtreme always load it first. + preamble.push('import \'./number.js\';'); + } + } + } + + const requireShim = isCldrMain + ? 'function require(id) { throw new Error(\'Unexpected require in cldr: \' + id); }\n' + : [ + 'function require(id) {\n', + ' if (id === \'cldrjs\' || id === \'cldr\' || id === \'../cldr\') {\n', + ' return __dxCldr;\n', + ' }\n', + ' if (id === \'../globalize\' || id === \'globalize\') {\n', + ' return __dxGlobalize;\n', + ' }\n', + ' throw new Error(\'Unhandled require in globalize/cldr UMD: \' + id);\n', + '}\n', + ].join(''); + + return wrapVendorCjsBranch(source, { + preamble: preamble.join('\n'), + requireShim, + }); +} + +/** + * Vector map geo data UMD: CJS writes into `exports`, browser branch expects + * bare `DevExpress`. Under ESM imports hoist above suite setup, so create the + * global sources bag and point `module.exports` at the same object. + */ +function wrapVectorMapDataAsEsm(source: string): string { + return wrapVendorCjsBranch(source, { + preamble: [ + 'globalThis.DevExpress = globalThis.DevExpress || {};', + 'globalThis.DevExpress.viz = globalThis.DevExpress.viz || {};', + 'globalThis.DevExpress.viz.map = globalThis.DevExpress.viz.map || {};', + 'globalThis.DevExpress.viz.map.sources = globalThis.DevExpress.viz.map.sources || {};', + ].join('\n'), + exportsInit: 'globalThis.DevExpress.viz.map.sources', + trailing: 'export default module.exports;\n', + }); +} + +/** `dx.vectormaputils.js` is UMD (`exports.parse = …`); tests do `import { parse }`. */ +function wrapVectorMapUtilsAsEsm(source: string): string { + return wrapVendorCjsBranch(source, { + rewriteThis: false, + trailing: 'export default module.exports;\nexport const parse = module.exports.parse;\n', + }); +} + +type VendorWrapper = (source: string, relativeUrlPath: string) => string; + +function resolveVendorEsmWrapper(relativeUrlPath: string): VendorWrapper | null { + const normalized = normalizeUrlPath(relativeUrlPath); + + if ( + normalized.endsWith('/intl/dist/Intl.complete.js') + || normalized.endsWith('/intl/dist/Intl.js') + ) { + return (source) => wrapIntlVendorAsEsm(source); + } + + if ( + normalized.endsWith('/globalize/dist/globalize.js') + || normalized.includes('/globalize/dist/globalize/') + || normalized.endsWith('/cldrjs/dist/cldr.js') + || /\/cldrjs\/dist\/cldr\/[^/]+\.js$/i.test(normalized) + ) { + return wrapGlobalizeOrCldrAsEsm; + } + + if (/\/artifacts\/js\/vectormap-data\/[^/]+\.js$/i.test(normalized)) { + return (source) => wrapVectorMapDataAsEsm(source); + } + + if (/\/artifacts\/js\/vectormap-utils\/dx\.vectormaputils\.js$/i.test(normalized)) { + return (source) => wrapVectorMapUtilsAsEsm(source); + } + + if ( + normalized.endsWith('/devextreme-quill/dist/dx-quill.js') + || normalized.endsWith('/artifacts/js/dx-diagram.js') + || normalized.endsWith('/artifacts/js/dx-gantt.js') + || normalized.endsWith('/artifacts/js/dx-exceljs-fork.js') + || normalized.endsWith('/artifacts/js/jszip.js') + ) { + return (source) => wrapWebpackVendorAsEsm(source); + } + + return null; +} + +/** Serve JSON as `export default …` for native ESM (`*.json!` replacement). */ +function sendJsonAsEsmModule(res: ServerResponse, filePath: string): boolean { + return sendTransformedJs( + res, + filePath, + (raw) => { + JSON.parse(raw); + return `export default ${raw};\n`; + }, + 'Failed to export JSON as ESM module', + ); +} + +// --- Mutable artifact facades --------------------------------------------------- + +function sendMutableFacadeModule(res: ServerResponse, shimUrl: string): boolean { + // Serve a re-export at the artifact URL so relative library imports and + // bare import-map entries share the same shim module graph. + return sendJsModuleBody( + res, + `export * from '${shimUrl}';\nexport { default } from '${shimUrl}';\n`, + ); +} + +// --- ESM artifact tweaks -------------------------------------------------------- + +/** + * Convert leftover `exports.foo = …` (from #DEBUG / dual CJS-ESM sources) + * into native ESM exports so the browser does not throw "exports is not defined". + */ +function rewriteLegacyCjsExportsInEsmArtifact(source: string): string { + if (!/\bexports\./.test(source)) { + return source; + } + + return source + .replace( + /^exports\.([A-Za-z_$][\w$]*)\s*=\s*([A-Za-z_$][\w$]*);?\s*$/gm, + (_match, exportName: string, valueName: string) => (exportName === valueName + ? `export { ${exportName} };` + : `export { ${valueName} as ${exportName} };`), + ) + .replace( + /^exports\.([A-Za-z_$][\w$]*)\s*=\s*function\s*\(/gm, + 'export function $1(', + ) + .replace( + /^exports\.([A-Za-z_$][\w$]*)\s*=\s*async\s+function\s*\(/gm, + 'export async function $1(', + ); +} + +/** + * ESM npm artifacts are built with removeDebug:true, which strips QUnit-only + * hooks. Re-attach the ones still present as locals in the compiled module. + * + * When debug is kept (`-c qunit`), some sources still emit CJS `exports.*` + * assignments that throw under native ESM — rewrite those to ESM exports. + */ +function restoreEsmDebugTestHooks(relativeUrlPath: string, source: string): string { + const normalized = normalizeUrlPath(relativeUrlPath); + if (!normalized.includes(ESM_ARTIFACT_MARKER)) { + return source; + } + + let next = source; + + if (normalized.endsWith('/__internal/events/core/m_events_engine.js') + && !next.includes('eventsEngine.detectPassiveEventHandlersSupport')) { + next = next.replace( + /eventsEngine\.passiveEventHandlersSupported\s*=\s*passiveEventHandlersSupported;/, + 'eventsEngine.passiveEventHandlersSupported = passiveEventHandlersSupported;\n' + + 'eventsEngine.elementDataMap = elementDataMap;\n' + + 'eventsEngine.detectPassiveEventHandlersSupport = detectPassiveEventHandlersSupport;', + ); + } + + return rewriteLegacyCjsExportsInEsmArtifact(next); +} + +function sendEsmArtifactJs( + res: ServerResponse, + filePath: string, + relativeUrlPath: string, +): boolean { + try { + const raw = fs.readFileSync(filePath, 'utf8'); + let body = restoreEsmDebugTestHooks(relativeUrlPath, raw); + body = rewriteAspnetArtifactToEsm(body, relativeUrlPath); + if (body === raw) { + return sendStaticFile(res, filePath, fs.statSync(filePath).size); + } + return sendJsModuleBody(res, body); + } catch { + return sendError(res, 500, 'Failed to serve ESM artifact'); + } +} + function sendDirectoryListing( res: ServerResponse, requestPath: string, @@ -141,7 +514,6 @@ ${items.join('\n')} export function createStaticFileService({ escapeHtml, rootDirectory, - setNoCacheHeaders, setStaticCacheHeaders, }: StaticFileServiceDeps): StaticFileService { function tryServeStatic( @@ -156,30 +528,88 @@ export function createStaticFileService({ const relativeToRoot = path.relative(rootDirectory, filePath); if (relativeToRoot.startsWith('..') || path.isAbsolute(relativeToRoot)) { - setNoCacheHeaders(res); - res.statusCode = 403; - res.setHeader('Content-Type', 'text/plain; charset=utf-8'); - res.end('Forbidden'); - return true; + return sendError(res, 403, 'Forbidden'); } - if (!fs.existsSync(filePath)) { + const resolvedFilePath = resolveStaticFilePath(filePath); + if (!resolvedFilePath) { return false; } setStaticCacheHeaders(res, searchParams); - const stat = fs.statSync(filePath); + const stat = fs.statSync(resolvedFilePath); if (stat.isDirectory()) { - return sendDirectoryListing(res, pathname, filePath, escapeHtml); + return sendDirectoryListing(res, pathname, resolvedFilePath, escapeHtml); } - if (stat.isFile()) { - return sendStaticFile(res, filePath, stat.size); + if (!stat.isFile()) { + return false; + } + + if (searchParams.has('esm-export') && path.extname(resolvedFilePath).toLowerCase() === '.json') { + return sendJsonAsEsmModule(res, resolvedFilePath); + } + + // Native ESM resolves relative imports against the request URL, not the + // on-disk file. Redirect extensionless URLs to the canonical file URL. + const resolvedUrlPath = `/${normalizeUrlPath(path.relative(rootDirectory, resolvedFilePath))}`; + if (resolvedUrlPath !== normalizedPath) { + const query = searchParams.toString(); + res.statusCode = 302; + res.setHeader('Location', query ? `${resolvedUrlPath}?${query}` : resolvedUrlPath); + res.end(); + return true; + } + + const relativeUrlPath = normalizeUrlPath(relativeToRoot); + const isJs = path.extname(resolvedFilePath).toLowerCase() === '.js'; + + if (isJs && isQunitTestOrHelperPath(relativeUrlPath)) { + return sendTransformedJs( + res, + resolvedFilePath, + (raw) => rewriteQunitTestHelperSource(raw, relativeUrlPath), + 'Failed to rewrite CJS-style test/helper module', + ); + } + + // Relative library imports bypass import maps — serve mutable facades + // at the artifact URL unless ?dx-original=1 (used by the facade itself). + // Hand-written shims (themes, …) win; otherwise auto-generate. + if (!searchParams.has('dx-original')) { + const shimUrl = findHandWrittenMutableFacade(relativeUrlPath); + if (shimUrl) { + return sendMutableFacadeModule(res, shimUrl); + } + const autoFacade = tryBuildAutoMutableFacade( + relativeUrlPath, + resolvedFilePath, + rootDirectory, + ); + if (autoFacade) { + return sendJsModuleBody(res, autoFacade); + } + } + + if (isJs) { + const vendorWrapper = resolveVendorEsmWrapper(relativeUrlPath); + if (vendorWrapper) { + return sendTransformedJs( + res, + resolvedFilePath, + (raw) => vendorWrapper(raw, relativeUrlPath), + 'Failed to wrap vendor bundle as ESM', + ); + } + + if (relativeUrlPath.includes(ESM_ARTIFACT_MARKER)) { + return sendEsmArtifactJs(res, resolvedFilePath, relativeUrlPath); + } } - return false; + return sendStaticFile(res, resolvedFilePath, stat.size); } return { diff --git a/packages/devextreme/testing/runner/templates/run-suite.template.html b/packages/devextreme/testing/runner/templates/run-suite.template.html index a7660dce96c2..d206af4ba123 100644 --- a/packages/devextreme/testing/runner/templates/run-suite.template.html +++ b/packages/devextreme/testing/runner/templates/run-suite.template.html @@ -99,9 +99,9 @@ - + - + + + {{{IMPORT_MAP_SCRIPT}}} +
- + diff --git a/packages/devextreme/testing/systemjs-builder.js b/packages/devextreme/testing/systemjs-builder.js deleted file mode 100644 index 940b87d249de..000000000000 --- a/packages/devextreme/testing/systemjs-builder.js +++ /dev/null @@ -1,272 +0,0 @@ -const path = require('path'); -const fs = require('fs'); -const babel = require('@babel/core'); -const parseArguments = require('minimist'); - - -const root = path.join(__dirname, '..'); -const transpilePath = path.join(root, '/artifacts/transpiled'); - -const getFileList = (dirName) => { - let files = []; - const items = fs.readdirSync(dirName, { withFileTypes: true }); - - // eslint-disable-next-line no-restricted-syntax - for(const item of items) { - if(item.isDirectory()) { - files = [...files, ...getFileList(path.join(dirName, item.name))]; - } else if( - item.name.endsWith('.js') || - (item.name.endsWith('.json') && !item.name.includes('tsconfig') && !item.name.includes('__meta')) - ) { - files.push(path.join(dirName, item.name)); - } - } - - return files; -}; - -const writeFileSync = (destPath, file) => { - const destDir = path.dirname(destPath); - if(!fs.existsSync(destDir)) { - fs.mkdirSync(destDir, { recursive: true }); - } - - fs.writeFileSync(destPath, file); -}; - -const buildAmdModule = (body) => ` -define(function(require, exports, module) { - ${body} -}); -`; - -const transpileCommonJSFile = (source, pathToFile) => { - const [pre, post] = path.extname(pathToFile) === '.json' - ? ['module.exports = ', ';'] - : ['', '']; - - writeFileSync( - pathToFile, - buildAmdModule( - `${pre}${source}${post}`.replace(/(\n|\r)/g, '$1 ') - ) - ); -}; - -const buildJsonModule = (body) => ` -define(function(require, exports, module) { - module.exports = ${body}; -}); -`; - -const buildSystemJSModule = (body, pre = '') => ` -SystemJS.register([], function(exports) { - ${pre} - - return { - setters: [], - execute: function() { - ${body} - } - }; -}); -`; - -const transpileFile = async(sourcePath, targetPath) => { - const code = fs.readFileSync(sourcePath) - .toString() - .replaceAll('/packages/devextreme/testing/helpers/wrapRenovatedWidget.js', '/packages/devextreme/artifacts/transpiled-testing/helpers/wrapRenovatedWidget.js') - .replaceAll(path.normalize('/testing/helpers/'), path.normalize('/artifacts/transpiled-testing/helpers/')) - // TODO see packages/devextreme/testing/tests/DevExpress.viz.vectorMap.utils/tests.js - // import { parse } from '../../../artifacts/js/vectormap-utils/dx.vectormaputils.js'; - // This used to work because the runner cwd was the same as the devextreme root folder - // remove next 3 lines after fix - .replaceAll( - path.normalize('../../../artifacts/js/vectormap-utils/dx.vectormaputils.js'), - path.normalize('../../../../artifacts/js/vectormap-utils/dx.vectormaputils.js')); - - if(sourcePath.includes('testing/helpers/includeThemesLinks.js')) { - writeFileSync(targetPath, buildSystemJSModule('', code.replaceAll('\n', ' '))); - return; - } - - if( - /(^|\s)System(JS)?\.register/gm.test(code) || - /(^|\s)define\(/gm.test(code) || - sourcePath.includes('helpers/forMap') - ) { - writeFileSync(targetPath, code); - } else if(/(\(|\s|^)require\(/.test(code) || /(module\.)?exports(\.\w+)?\s?=/.test(code)) { - transpileCommonJSFile(code, targetPath); - } else if(sourcePath.endsWith('.json')) { - writeFileSync(targetPath, buildJsonModule(code)); - } else { - await transpileWithBabel(code, targetPath); - } -}; - -const transpileModules = async() => { - await Promise.all( - getFileList(transpilePath).map((filePath) => { - return transpileFile( - filePath, - filePath.replace(path.normalize('/transpiled'), path.normalize('/transpiled-systemjs')), - ); - }) - ); -}; - -const buildCssAsSystemModule = (name, filePath) => ` -System.register('${filePath}', [], false, function() {}); -(function() { - if (typeof document == 'undefined') return; - var link = document.createElement('link'); - link.rel = 'stylesheet'; - link.href = '/packages/devextreme/${filePath}'; - link.setAttribute('data-theme', '${name}'); - document.getElementsByTagName('head')[0].appendChild(link); -})(); -`; - -const transpileCss = async() => { - const cssList = [ - ['artifacts/css/dx.light.css', 'generic.light'], - ['artifacts/css/dx.material.blue.light.css', 'material.blue.light'], - ['artifacts/css/dx.fluent.blue.light.css', 'fluent.blue.light'], - ['artifacts/css/dx-gantt.css', 'gantt'], - ]; - - // eslint-disable-next-line no-restricted-syntax - for(const [cssFile, styleName] of cssList) { - const destPath = path.join(root, cssFile.replace('css', 'css-systemjs')); - - writeFileSync(destPath, buildCssAsSystemModule(styleName, cssFile)); - } -}; - -const transpileWithBabel = async(sourceCode, destPath) => { - const { code } = await babel.transform(sourceCode, { - compact: false, - plugins: ['@babel/plugin-transform-modules-systemjs'], - sourceMaps: true, - }); - - writeFileSync(destPath, code); -}; - -const transpileIntl = async() => { - const listIntlFiles = [ - { - filePath: require.resolve('intl/lib/core.js'), - destPath: path.join(root, 'artifacts/js-systemjs/intl/intl.js'), - }, - { - filePath: require.resolve('intl/locale-data/complete.js'), - destPath: path.join(root, 'artifacts/js-systemjs/intl/intl.complete.js'), - }, - ]; - - await Promise.all(listIntlFiles.map(({ filePath, destPath }) => { - const code = fs.readFileSync(filePath).toString(); - - writeFileSync( - destPath, - buildAmdModule( - code.replace('IntlPolyfill', 'require("./intl.js")') - ) - ); - })); - - const intlIndex = ` - define(function(require, exports, module) { - window.IntlPolyfill = require('./intl.js'); - - require('./intl.complete.js'); - - if (!window.Intl) { - window.Intl = window.IntlPolyfill; - window.IntlPolyfill.__applyLocaleSensitivePrototypes(); - } - - module.exports = window.IntlPolyfill; - }); - `; - - writeFileSync(path.join(root, 'artifacts/js-systemjs/intl/index.js'), intlIndex); -}; - -const transpileJsVendors = async() => { - const pluginsList = [ - { - filePath: require.resolve('systemjs-plugin-css/css.js'), - destPath: path.join(root, 'artifacts/js-systemjs/css.js'), - }, - { - filePath: require.resolve('systemjs-plugin-json/json.js'), - destPath: path.join(root, 'artifacts/js-systemjs/json.js'), - }, - ]; - - await Promise.all( - pluginsList.map(({ filePath, destPath }) => { - const code = fs.readFileSync(filePath).toString(); - - return writeFileSync( - destPath, - buildSystemJSModule( - '', - code.replaceAll('module.exports', 'exports') - ) - ); - }), - ); - - await transpileIntl(); - - await transpileFile( - require.resolve('knockout/build/output/knockout-latest.debug.js'), - path.join(root, 'artifacts/js-systemjs/knockout.js') - ); - await transpileFile( - path.join(root, 'node_modules/@preact/signals-core/dist/signals-core.js'), - path.join(root, 'artifacts/js-systemjs/preact-signals.js') - ); - - - [].concat( - getFileList(path.join(root, 'node_modules/devextreme-cldr-data')), - getFileList(path.join(root, 'node_modules/cldr-core/supplemental')) - ) - .filter(filePath => filePath.endsWith('.json')) - .forEach((filePath) => { - transpileFile(filePath, filePath.replace(path.normalize('/node_modules'), path.normalize('/artifacts/js-systemjs'))); - }); -}; - -const transpileTesting = async() => { - const contentList = getFileList(path.join(root, 'testing/content')); - const helpersList = getFileList(path.join(root, 'testing/helpers')); - const testsList = getFileList(path.join(root, 'testing/tests')); - - [].concat(contentList, helpersList, testsList) - .forEach((filePath) => { - transpileFile(filePath, filePath.replace(path.normalize('/testing/'), path.normalize('/artifacts/transpiled-testing/'))); - }); -}; - -(async() => { - - const { transpile } = parseArguments(process.argv); - - switch(transpile) { - case 'modules': - return await transpileModules(); - case 'testing': - return await transpileTesting(); - case 'css': - return await transpileCss(); - case 'js-vendors': - return await transpileJsVendors(); - } -})(); diff --git a/packages/devextreme/testing/tests/DevExpress.aspnet/aspnet.tests.js b/packages/devextreme/testing/tests/DevExpress.aspnet/aspnet.tests.js index c61b8e313b3c..6d2fdbc87a94 100644 --- a/packages/devextreme/testing/tests/DevExpress.aspnet/aspnet.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.aspnet/aspnet.tests.js @@ -1,39 +1,28 @@ -(function(factory) { - if(typeof define === 'function' && define.amd) { - define(function(require, exports, module) { - require('integration/jquery'), - require('ui/button'); - require('ui/check_box'); - require('ui/drop_down_button'); - require('ui/form'); - require('ui/popup'); - require('ui/select_box'); - require('ui/text_box'); - require('ui/toolbar'); - require('ui/validator'); - require('ui/validation_summary'); - - const aspnet = require('aspnet'); - window.DevExpress = { aspnet: aspnet }; // for DevExpress.aspnet.createComponent in templates - - module.exports = factory( - require('jquery'), - require('core/templates/template_engine_registry').setTemplateEngine, - aspnet, - function() { return require('ui/widget/ui.errors'); }, - function() { return require('../../helpers/ajaxMock.js'); } - ); - }); - } else { - factory( - window.jQuery, - DevExpress.setTemplateEngine, - DevExpress.aspnet, - function() { return window.DevExpress_ui_widget_errors; }, - function() { return window.ajaxMock; } - ); - } -}(function($, setTemplateEngine, aspnet, errorsAccessor, ajaxMockAccessor) { +import 'integration/jquery'; +import 'ui/button'; +import 'ui/check_box'; +import 'ui/drop_down_button'; +import 'ui/form'; +import 'ui/popup'; +import 'ui/select_box'; +import 'ui/text_box'; +import 'ui/toolbar'; +import 'ui/validator'; +import 'ui/validation_summary'; + +import $ from 'jquery'; +import { setTemplateEngine } from 'core/templates/template_engine_registry'; +import aspnetModule from 'aspnet'; +import errorsModule from 'ui/widget/ui.errors'; +import ajaxMock from '../../helpers/ajaxMock.js'; + +// Templates call DevExpress.aspnet.createComponent / renderComponent. +// MVC-style templates also expect global `$` (runner calls jQuery.noConflict()). +window.DevExpress = window.DevExpress || {}; +window.DevExpress.aspnet = aspnetModule; +window.$ = $; + +(function($, setTemplateEngine, aspnet, errorsAccessor, ajaxMockAccessor) { if(QUnit.urlParams['nojquery']) { return; @@ -696,4 +685,4 @@ }); }); -})); +})($, setTemplateEngine, aspnetModule, function() { return errorsModule; }, function() { return ajaxMock; }); diff --git a/packages/devextreme/testing/tests/DevExpress.common/charts.tests.js b/packages/devextreme/testing/tests/DevExpress.common/charts.tests.js index 6c7ff287bb62..e1d72136d9ca 100644 --- a/packages/devextreme/testing/tests/DevExpress.common/charts.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.common/charts.tests.js @@ -1,16 +1,19 @@ import { registerPattern, registerGradient } from 'common/charts'; import graphicObjects from '__internal/common/m_charts'; -import utils from 'viz/core/utils_default'; +function clearGraphicObjects() { + const objects = graphicObjects.getGraphicObjects(); + Object.keys(objects).forEach((key) => { + delete objects[key]; + }); +} QUnit.module('Graphic objects', { beforeEach: function() { - this.getNextDefsStub = sinon.stub(utils, 'getNextDefsSvgId'); - this.getNextDefsStub.onCall(0).returns('DevExpressId_1'); - this.getNextDefsStub.onCall(1).returns('DevExpressId_2'); + clearGraphicObjects(); }, afterEach: function() { - this.getNextDefsStub.restore(); + clearGraphicObjects(); } }); @@ -18,12 +21,11 @@ QUnit.test('should register pattern', function(assert) { const id_1 = registerPattern({ key: 'test_key_1' }); const id_2 = registerPattern({ key: 'test_key_2' }); - assert.equal(this.getNextDefsStub.callCount, 2); - assert.equal(id_1, 'DevExpressId_1'); - assert.equal(id_2, 'DevExpressId_2'); + assert.ok(/^DevExpress_\d+$/.test(id_1), 'id has expected format'); + assert.notEqual(id_1, id_2, 'ids are unique'); assert.deepEqual(graphicObjects.getGraphicObjects(), { - 'DevExpressId_1': { key: 'test_key_1', type: 'pattern' }, - 'DevExpressId_2': { key: 'test_key_2', type: 'pattern' } + [id_1]: { key: 'test_key_1', type: 'pattern' }, + [id_2]: { key: 'test_key_2', type: 'pattern' } }); }); @@ -31,11 +33,10 @@ QUnit.test('should register gradient', function(assert) { const id_1 = registerGradient('gradient_type', { key: 'test_key_1' }); const id_2 = registerGradient('gradient_type', { key: 'test_key_2' }); - assert.equal(this.getNextDefsStub.callCount, 2); - assert.equal(id_1, 'DevExpressId_1'); - assert.equal(id_2, 'DevExpressId_2'); + assert.ok(/^DevExpress_\d+$/.test(id_1), 'id has expected format'); + assert.notEqual(id_1, id_2, 'ids are unique'); assert.deepEqual(graphicObjects.getGraphicObjects(), { - 'DevExpressId_1': { key: 'test_key_1', type: 'gradient_type' }, - 'DevExpressId_2': { key: 'test_key_2', type: 'gradient_type' } + [id_1]: { key: 'test_key_1', type: 'gradient_type' }, + [id_2]: { key: 'test_key_2', type: 'gradient_type' } }); }); diff --git a/packages/devextreme/testing/tests/DevExpress.core/config_bundled.tests.js b/packages/devextreme/testing/tests/DevExpress.core/config_bundled.tests.js index 7800023e6c96..e7cdd80db419 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/config_bundled.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/config_bundled.tests.js @@ -3,14 +3,14 @@ const useJQuery = !QUnit.urlParams['nojquery']; window.DevExpress = window.DevExpress || {}; window.DevExpress.config = { useJQuery: useJQuery }; -define(function(require) { - QUnit.test = QUnit.urlParams['nocsp'] ? QUnit.test : QUnit.skip; - require('bundles/dx.all.js'); +// Must stay dynamic: static imports hoist above the config assignment. +await import('bundles/dx.all.js'); - QUnit.module('config.useJQuery'); +QUnit.test = QUnit.urlParams['nocsp'] ? QUnit.test : QUnit.skip; - QUnit.test('config value useJQuery with jQuery in window', function(assert) { - const config = DevExpress.config; - assert.equal(config().useJQuery, useJQuery); - }); +QUnit.module('config.useJQuery'); + +QUnit.test('config value useJQuery with jQuery in window', function(assert) { + const config = DevExpress.config; + assert.equal(config().useJQuery, useJQuery); }); diff --git a/packages/devextreme/testing/tests/DevExpress.jquery/bundled.tests.js b/packages/devextreme/testing/tests/DevExpress.jquery/bundled.tests.js index 0fc86f98a8e9..26ba47daecfb 100644 --- a/packages/devextreme/testing/tests/DevExpress.jquery/bundled.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.jquery/bundled.tests.js @@ -1,18 +1,13 @@ -define(function(require) { - if(QUnit.urlParams['nojquery']) { - return; - } - - const $ = require('jquery'); - - require('bundles/dx.all.js'); - +import $ from 'jquery'; +import 'integration/jquery'; +import dxButton from 'ui/button'; +if(!QUnit.urlParams['nojquery']) { QUnit.module('jquery integration'); QUnit.test('renderer uses correct strategy', function(assert) { const node = document.createElement('div'); - const element = new DevExpress.ui.dxButton(node).element(); + const element = new dxButton(node).element(); assert.ok(element instanceof window.jQuery); }); @@ -22,4 +17,4 @@ define(function(require) { assert.equal(typeof $element.dxButton, 'function'); }); -}); +} diff --git a/packages/devextreme/testing/tests/DevExpress.jquery/template.tests.js b/packages/devextreme/testing/tests/DevExpress.jquery/template.tests.js index c072d222b479..06020db1cc88 100644 --- a/packages/devextreme/testing/tests/DevExpress.jquery/template.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.jquery/template.tests.js @@ -1,9 +1,3 @@ -SystemJS.config({ - map: { - 'jqueryify': SystemJS.map.jquery - } -}); - define(function(require) { const $ = require('jquery'); const Template = require('core/templates/template').Template; diff --git a/packages/devextreme/testing/tests/DevExpress.localization/localization.globalize.tests.js b/packages/devextreme/testing/tests/DevExpress.localization/localization.globalize.tests.js index d028a628baf6..b1131dcb7c4d 100644 --- a/packages/devextreme/testing/tests/DevExpress.localization/localization.globalize.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.localization/localization.globalize.tests.js @@ -1,26 +1,3 @@ -SystemJS.config({ - meta: { - './localization.base.tests.js': { - deps: [ - 'common/core/localization/globalize/core', - 'common/core/localization/globalize/number', - 'common/core/localization/globalize/currency', - 'common/core/localization/globalize/date', - 'common/core/localization/globalize/message' - ] - } - }, - packages: { - 'globalize': { - meta: { - '../globalize.js': { - deps: ['cldr/unresolved'] - } - } - } - } -}); - define(function(require, exports, module) { const cldrData = [ require('devextreme-cldr-data/ar.json!json'), @@ -547,7 +524,7 @@ define(function(require, exports, module) { }); QUnit.module('Exceljs format', () => { - ExcelJSLocalizationFormatTests.default.runCurrencyTests([ + ExcelJSLocalizationFormatTests.runCurrencyTests([ { value: 'USD', expected: '$#,##0_);\\($#,##0\\)' }, { value: 'RUB', expected: '\\R\\U\\B#,##0_);\\(\\R\\U\\B#,##0\\)' }, { value: 'JPY', expected: '\\¥#,##0_);\\(\\¥#,##0\\)' }, @@ -556,7 +533,7 @@ define(function(require, exports, module) { { value: 'SEK', expected: '\\S\\E\\K#,##0_);\\(\\S\\E\\K#,##0\\)' } ]); - ExcelJSLocalizationFormatTests.default.runPivotGridCurrencyTests([ + ExcelJSLocalizationFormatTests.runPivotGridCurrencyTests([ { value: 'USD', expected: '$#,##0_);\\($#,##0\\)' }, { value: 'RUB', expected: '\\R\\U\\B#,##0_);\\(\\R\\U\\B#,##0\\)' }, { value: 'JPY', expected: '\\¥#,##0_);\\(\\¥#,##0\\)' }, diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/adaptiveColumns.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/adaptiveColumns.tests.js index 62f7c4e1a833..ec8e84cf6f59 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/adaptiveColumns.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/adaptiveColumns.tests.js @@ -105,19 +105,22 @@ QUnit.module('AdaptiveColumns', { if(name === 'width' || name === 'height') { ++cssInvokeCounter; } + return cssFunc.apply(this, arguments); }; - // arrange, act - $('.dx-datagrid').width(200); - setupDataGrid(this); - this.rowsView.render($('#container')); - this.resizingController.updateDimensions(); - this.clock.tick(10); - - // assert - assert.equal(cssInvokeCounter, 0, 'no $.css() invokes for width/height CSS properties'); - - renderer.fn.css = cssFunc; + try { + // arrange, act + $('.dx-datagrid').width(200); + setupDataGrid(this); + this.rowsView.render($('#container')); + this.resizingController.updateDimensions(); + this.clock.tick(10); + + // assert + assert.equal(cssInvokeCounter, 0, 'no $.css() invokes for width/height CSS properties'); + } finally { + renderer.fn.css = cssFunc; + } }); // T516888 diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/importQuill.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/importQuill.tests.js index 8ba22c6b1e98..954d86128ce6 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/importQuill.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/importQuill.tests.js @@ -1,22 +1,13 @@ +import quillImporter from 'ui/html_editor/quill_importer'; -SystemJS.config({ - map: { - 'devextreme-quill': '/packages/devextreme/testing/helpers/quillDependencies/noQuill.js' - } -}); - -define(function(require) { - const getQuill = require('ui/html_editor/quill_importer').getQuill; - - QUnit.module('Import 3rd party', function() { - QUnit.test('it throw an error if the quill script isn\'t referenced', function(assert) { - assert.throws( - function() { getQuill(); }, - function(e) { - return /(E1041)[\s\S]*(Quill)/.test(e.message); - }, - 'The Quill script isn\'t referenced' - ); - }); +QUnit.module('Import 3rd party', function() { + QUnit.test('it throw an error if the quill script is not referenced', function(assert) { + assert.throws( + function() { quillImporter.getQuill(); }, + function(e) { + return /(E1041)[\s\S]*(Quill)/.test(e.message); + }, + 'The Quill script is not referenced' + ); }); }); diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/tableResizingModule.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/tableResizingModule.tests.js index 939672ded248..cf29a6de403a 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/tableResizingModule.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/tableResizingModule.tests.js @@ -72,6 +72,8 @@ const moduleConfig = { }, afterEach: function() { + this.clock.tick(1000); + resizeCallbacks.empty(); this.clock.restore(); } }; @@ -176,7 +178,7 @@ module('Table resizing module', moduleConfig, () => { resizeCallbacks.fire(); - assert.strictEqual(typeof resizingInstance._resizeHandlerWithContext, 'object', '_resizeHandler is an object'); + assert.ok(resizingInstance._resizeHandlerWithContext, '_resizeHandlerWithContext is registered'); }); test('Window resize callback should be cleaned after the widget dispose', function(assert) { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/toolbarModule.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/toolbarModule.tests.js index 3afd5c78e87e..bcc686b7c3b1 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/toolbarModule.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/toolbarModule.tests.js @@ -1883,6 +1883,7 @@ testModule('Toolbar items state update', { test('state of the items in menu should be synchronized after toolbar repaint (t1117604)', function(assert) { this.options.items = this.mapToMenuItems(TABLE_OPERATIONS); + resizeCallbacks.empty(); const toolbar = new Toolbar(this.quillMock, this.options); this.quillMock.getFormat = () => ({ table: true }); toolbar.updateTableWidgets(); diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/desktopTooltip.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/desktopTooltip.tests.js index 9205430c2753..55a3f263fb84 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/desktopTooltip.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/desktopTooltip.tests.js @@ -1,3 +1,4 @@ +import $ from 'jquery'; import { DesktopTooltipStrategy } from '__internal/scheduler/tooltip_strategies/desktop_tooltip_strategy'; import { FunctionTemplate } from 'core/templates/function_template'; import { extend } from 'core/utils/extend'; diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/diagramParts/importDiagram.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/diagramParts/importDiagram.tests.js index ecc19597f49f..11113aa6afb5 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/diagramParts/importDiagram.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/diagramParts/importDiagram.tests.js @@ -1,20 +1,12 @@ -SystemJS.config({ - map: { - 'devexpress-diagram': '/packages/devextreme/testing/helpers/noDiagram.js' - } -}); - -define(function(require) { - const getDiagram = require('__internal/ui/diagram/diagram.importer').getDiagram; +import { getDiagram } from '__internal/ui/diagram/diagram.importer'; - QUnit.module('Import devexpress-diagram', function() { - QUnit.test('throw an error if the devexpress-diagram script isn\'t referenced', function(assert) { - assert.throws( - function() { getDiagram(); }, - function(e) { - return /(E1041)[\s\S]*(devexpress-diagram)/.test(e.message); - } - ); - }); +QUnit.module('Import devexpress-diagram', function() { + QUnit.test('throw an error if the devexpress-diagram script isn\'t referenced', function(assert) { + assert.throws( + function() { getDiagram(); }, + function(e) { + return /(E1041)[\s\S]*(devexpress-diagram)/.test(e.message); + } + ); }); }); diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/ganttParts/importGantt.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/ganttParts/importGantt.tests.js index 66e095bfe854..58162b185b4c 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/ganttParts/importGantt.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/ganttParts/importGantt.tests.js @@ -1,21 +1,12 @@ +import { getGanttViewCore as getGantt } from '__internal/ui/gantt/gantt_importer'; -SystemJS.config({ - map: { - 'devexpress-gantt': '/packages/devextreme/testing/helpers/noGantt.js' - } -}); - -define(function(require) { - const getGantt = require('__internal/ui/gantt/gantt_importer').getGanttViewCore; - - QUnit.module('Import devexpress-gantt', function() { - QUnit.test('throw an error if the devexpress-gantt script isn\'t referenced', function(assert) { - assert.throws( - function() { getGantt(); }, - function(e) { - return /(E1041)[\s\S]*(devexpress-gantt)/.test(e.message); - } - ); - }); +QUnit.module('Import devexpress-gantt', function() { + QUnit.test('throw an error if the devexpress-gantt script isn\'t referenced', function(assert) { + assert.throws( + function() { getGantt(); }, + function(e) { + return /(E1041)[\s\S]*(devexpress-gantt)/.test(e.message); + } + ); }); }); diff --git a/packages/devextreme/testing/tests/DevExpress.ui/themes.tests.js b/packages/devextreme/testing/tests/DevExpress.ui/themes.tests.js index 3e98fd22e59e..dff805a7fd8e 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui/themes.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui/themes.tests.js @@ -770,7 +770,7 @@ QUnit.module('initialized method', (hooks) => { test('initialized fires for ordinary link (init before link addition - should wait theme loading)', function(assert) { const done = assert.async(); - const url = ROOT_URL + 'packages/devextreme/testing' + '/helpers/themeMarker.css'; // WA for systemjs builder + const url = ROOT_URL + 'packages/devextreme/testing' + '/helpers/themeMarker.css'; const $frame = createFrame(); themes.setDefaultTimeout(30000); diff --git a/packages/devextreme/testing/tests/DevExpress.viz.charts/chart.integration.tests.js b/packages/devextreme/testing/tests/DevExpress.viz.charts/chart.integration.tests.js index 953ea43bdf2c..ee10eb4db407 100644 --- a/packages/devextreme/testing/tests/DevExpress.viz.charts/chart.integration.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.viz.charts/chart.integration.tests.js @@ -12,7 +12,9 @@ import seriesFamilyModule from 'viz/core/series_family'; import { setupSeriesFamily } from '../../helpers/chartMocks.js'; import pointerMock from '../../helpers/pointerMock.js'; -const seriesFamilyNativeConstructor = { ...seriesFamilyModule }.SeriesFamily; +const mutableRendererModule = rendererModule.default ?? rendererModule; +const mutableSeriesFamilyModule = seriesFamilyModule.default ?? seriesFamilyModule; +const seriesFamilyNativeConstructor = mutableSeriesFamilyModule.SeriesFamily; setupSeriesFamily(); QUnit.testStart(function() { const markup = @@ -2325,7 +2327,7 @@ QUnit.test('check horizontal alignment === center', function(assert) { QUnit.module('Auto hide point markers', $.extend({}, moduleSetup, { beforeEach: function() { moduleSetup.beforeEach.call(this); - seriesFamilyModule.SeriesFamily = seriesFamilyNativeConstructor; + mutableSeriesFamilyModule.SeriesFamily = seriesFamilyNativeConstructor; const dataSource = []; for(let i = 0; i < 500000; i += 250) { const y1 = Math.sin(i); @@ -3300,14 +3302,14 @@ QUnit.module('Option changing in onDrawn after zooming', { beforeEach: function() { this.legendShiftSpy = sinon.spy(legendModule.Legend.prototype, 'move'); this.titleShiftSpy = sinon.spy(titleModule.Title.prototype, 'move'); - sinon.stub(rendererModule, 'Renderer').callsFake(function() { + sinon.stub(mutableRendererModule, 'Renderer').callsFake(function() { return new Renderer(); }); }, afterEach: function() { legendModule.Legend.prototype.move.restore(); titleModule.Title.prototype.move.restore(); - rendererModule.Renderer.restore(); + mutableRendererModule.Renderer.restore(); } }); @@ -4901,7 +4903,7 @@ QUnit.test('Reset axes animation before adjusting position of vertical axes (fix QUnit.module('SeriesFamily', $.extend({}, moduleSetup, { beforeEach: function() { moduleSetup.beforeEach.call(this); - seriesFamilyModule.SeriesFamily = seriesFamilyNativeConstructor; + mutableSeriesFamilyModule.SeriesFamily = seriesFamilyNativeConstructor; } })); diff --git a/packages/devextreme/testing/tests/DevExpress.viz.charts/chart.part7.tests.js b/packages/devextreme/testing/tests/DevExpress.viz.charts/chart.part7.tests.js index 358b3781265e..510f626adffa 100644 --- a/packages/devextreme/testing/tests/DevExpress.viz.charts/chart.part7.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.viz.charts/chart.part7.tests.js @@ -10,12 +10,14 @@ import { createChartInstance, LabelCtor, } from './chartParts/commons.js'; -import { ERROR_MESSAGES as dxErrors } from 'viz/core/errors_warnings'; +import errorsWarnings from 'viz/core/errors_warnings'; import seriesModule from 'viz/series/base_series'; import dataValidatorModule from 'viz/components/data_validator'; import { MockSeries, categories, seriesMockData, MockTranslator } from '../../helpers/chartMocks.js'; import graphicObjects from '__internal/common/m_charts'; +const dxErrors = errorsWarnings.ERROR_MESSAGES; + $('
').appendTo('#qunit-fixture'); (function seriesCreationTests() { diff --git a/packages/devextreme/testing/tests/DevExpress.viz.core/axisDrawing.tests.js b/packages/devextreme/testing/tests/DevExpress.viz.core/axisDrawing.tests.js index 5a818a865b72..a1cc51c986d2 100644 --- a/packages/devextreme/testing/tests/DevExpress.viz.core/axisDrawing.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.viz.core/axisDrawing.tests.js @@ -1,5 +1,5 @@ import $ from 'jquery'; -import { ERROR_MESSAGES as dxErrors } from 'viz/core/errors_warnings'; +import errorsWarnings from 'viz/core/errors_warnings'; import translator2DModule from 'viz/translators/translator2d'; import { Range } from 'viz/translators/range'; import tickGeneratorModule from 'viz/axes/tick_generator'; @@ -9,6 +9,8 @@ import { stubClass, } from '../../helpers/vizMocks.js'; +const dxErrors = errorsWarnings.ERROR_MESSAGES; + const StubTranslator = stubClass(translator2DModule.Translator2D, { updateBusinessRange: function(range) { this.getBusinessRange.returns(range); diff --git a/packages/devextreme/testing/tests/DevExpress.viz.gauges/barGauge.tests.js b/packages/devextreme/testing/tests/DevExpress.viz.gauges/barGauge.tests.js index 6f4bb5c49201..9b44a0a266e2 100644 --- a/packages/devextreme/testing/tests/DevExpress.viz.gauges/barGauge.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.viz.gauges/barGauge.tests.js @@ -61,12 +61,21 @@ QUnit.begin(function() { step(1); that.animationStep && that.animationStep(1); complete(); - that.animationComplete && that.animationComplete(); + // Drop the hook before calling it — overlapping animate() + // chains (or a second completion after done()) must not + // re-enter assert.async() under native ESM scheduling. + const onGroupComplete = that.animationComplete; + that.animationComplete = null; + onGroupComplete && onGroupComplete(); test.renderer.animationCompleted && test.renderer.animationCompleted(); } } if(arguments[1] && typeof arguments[1].step === 'function') { + // Real renderer replaces the in-flight animation; without this, + // a second animate() leaves an orphan setTimeout chain and + // animationComplete / assert.async() fire twice. + this.stopAnimation(); that = this; step = arguments[1].step; complete = arguments[1].complete || noop; @@ -77,6 +86,7 @@ QUnit.begin(function() { }; group.stopAnimation = function() { clearTimeout(this.__animation); + this.__animation = null; return this; }; return group; diff --git a/packages/devextreme/testing/tests/Memory Leaks/vizWidgets.tests.js b/packages/devextreme/testing/tests/Memory Leaks/vizWidgets.tests.js index 4799c4cef71f..56edcb6d686e 100644 --- a/packages/devextreme/testing/tests/Memory Leaks/vizWidgets.tests.js +++ b/packages/devextreme/testing/tests/Memory Leaks/vizWidgets.tests.js @@ -1,4 +1,4 @@ -window.DevExpress = { viz: { map: { sources: {} } } }; +window.DevExpress = window.DevExpress || { viz: { map: { sources: {} } } }; import $ from 'core/renderer'; import { getWidth, getHeight, setWidth, setHeight } from 'core/utils/size'; @@ -18,6 +18,8 @@ import 'viz/tree_map'; import '/packages/devextreme/artifacts/js/vectormap-data/world.js'; import '/packages/devextreme/artifacts/js/vectormap-data/usa.js'; +const DevExpress = window.DevExpress; + const chartTestsSignature = { getInitOptions() { return { diff --git a/packages/nx-infra-plugin/AGENTS.md b/packages/nx-infra-plugin/AGENTS.md index a54a48137d65..c0f41b0ac880 100644 --- a/packages/nx-infra-plugin/AGENTS.md +++ b/packages/nx-infra-plugin/AGENTS.md @@ -65,3 +65,24 @@ Each behavior is owned by exactly ONE executor's canonical tests; consumers must 3. Preserve exact functional parity. Verify with the executor's e2e spec before and after. 4. Update consumer imports in one batch. 5. Run the full validation pipeline. + +## Former gulp tasks (gulp fully removed) + +`gulpfile.js`, `build/gulp/`, and all gulp dependencies have been deleted outright — devextreme no longer depends on gulp or ships a gulp CLI. The Nx-consumed build assets that used to live under `build/gulp/` (`transpile-config.js`, `modules_metadata.json`, the `*.jst` templates) were relocated to purpose-named folders directly under `build/` (`build/transpile-config.js`, `build/modules_metadata.json`, `build/localization-templates/`, `build/vectormap-templates/`). The table below is a historical reference mapping each removed gulp task to its Nx replacement: + +| Former gulp task | Nx target | Notes | +| --------------------------------------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `clean` | `clean:artifacts` | Uses `devextreme-nx-infra-plugin:clean` with `excludePatterns` to preserve `artifacts/css`, `artifacts/npm/devextreme/package.json`, and `artifacts/npm/devextreme-dist`. Run directly via `pnpm nx clean:artifacts devextreme`. | +| `bundler-config-watch` | `build:devextreme-bundler-config:watch` | Uses `devextreme-nx-infra-plugin:concatenate-files` in `watch` mode (chokidar over the `build/bundle-templates/modules/parts` sources) with `additionalPasses` so a change rebuilds both `dx.custom.js` and the derived `dx.custom.config.js`, matching the old gulp `bundler-config` chain. `cache: false`. | +| `bundler-config` (non-watch) | `build:devextreme-bundler-config` | Run via `pnpm nx build:devextreme-bundler-config devextreme` (add `-c prod` for parity with the old uglified variant). | +| `generate-community-locales` | `build:community-localization` | Uses `devextreme-nx-infra-plugin:generate-community-locales` to normalize `js/localization/messages/*.json` against `en.json` in place (fills translations, English fallback for missing/`TODO` values, escapes quotes, inherits en's key order/formatting). Target is `cache: false` with no `outputs` (input dir == output dir — a source-normalization task, not a cached build artifact). Run via `pnpm nx build:community-localization devextreme`. | +| `test-env` | `test-env` | Uses `nx:run-commands` to wrap the existing `node ./testing/launch` script (compiles the QUnit runner, starts the test server on port 20060, opens the browser). `cache: false`, no outputs (long-running server). `cwd` is `{projectRoot}`. | +| `transpile-watch` | `build:transpile:watch` | `nx:run-commands` (parallel, `cache: false`) fanning out to the incremental watch targets `build:ts:internal:watch` (TypeScript watch program emitting `dist_ts`), `build:cjs:watch` (+ `-c production`), and `build:cjs:internal:watch` (+ `-c production`). Together these keep `artifacts/transpiled` and `artifacts/transpiled-renovation-npm` fresh, matching the old gulp JS + TS watch pipes. Watch capability lives in the `babel-transform` (per-file, chokidar + debounce, `watch` option) and `build-typescript` (`ts.createWatchProgram`, `watch` option) executors via the shared `src/utils/watch.ts` helper. `babel-transform` watch is intentionally file-level incremental and does **not** do an initial full transform — it relies on a preceding build having already populated its source directory (mirroring gulp-watch, which fed babel from a single in-memory TS-compiler stream with no such gap). Because `build:transpile`'s last step (`clean:dist-ts`) deletes `artifacts/dist_ts` — the exact directory `build:cjs:internal:watch` reads from and that runs right before `dev-watch` starts — `build:transpile:watch` itself (not the leaf `build:cjs:internal:watch` target, to avoid two parallel invocations each re-running the compile) declares `dependsOn: ["build:ts:internal"]`, so a real (or Nx-cache-restored) TS compile always repopulates `dist_ts/__internal` once, up front, before any of the fanned-out watch processes start; without it, whichever of the parallel TS-watch/babel-watch processes started first would decide — nondeterministically — whether the initial compile burst is picked up. | +| `transpile-tests` | `transpile:tests` | Uses `devextreme-nx-infra-plugin:babel-transform` with the flat (keyless) `./testing/tests.babelrc.json` config to transpile `testing/**/*.js` in place. `dependsOn: ["build:devextreme-bundler-config"]` reproduces the old gulp `series('bundler-config', …)` prerequisite. `cache: false` (in-place source transform, not a cached artifact). Run via `pnpm nx transpile:tests devextreme`. | +| `transpile-systemjs` | _(removed)_ | QUnit uses native ESM + import maps only. `build:systemjs` and `testing/systemjs-builder.js` are gone. ESM for QUnit is `artifacts/transpiled-esm-npm` from `build:transpile -c ci` (via `build:dev` / CI) or the dedicated `build:qunit-esm` target. | +| `js-bundles-watch` | `bundle:watch` | Webpack watch via `devextreme-nx-infra-plugin:bundle` with `watch: true`. Does not run `compress:bundles`. | +| `js-bundles-prod` | `bundle:prod` | Use `pnpm nx bundle:prod devextreme` (add `-c production` for uglify/dist parity). | +| `js-bundles-debug` | `bundle:debug` | Use `pnpm nx bundle:debug devextreme` (add `-c production` for uglify/dist parity). | +| `dev-watch` | `dev-watch` | `nx:run-commands` (parallel, `cache: false`, `cwd: {projectRoot}`) fanning out to the four already-migrated watch targets — `build:transpile:watch`, `build:devextreme-bundler-config:watch`, `bundle:watch`, `test-env` — matching the old `gulp.parallel('transpile-watch', 'bundler-config-watch', 'js-bundles-watch', 'test-env')`. | +| `dev` | `dev` | `nx:run-commands` with `dependsOn: ["build:dev"]`; its own command then runs `pnpm nx dev-watch devextreme`, reproducing the old `gulp.series('default-dev', 'dev-watch')` build-then-watch sequencing. Reuses `build:dev` as the initial-build step rather than replicating gulp's lighter `default-dev` variant (which skipped `clean` and the one-shot `js-bundles-debug` build) — an accepted small startup-cost tradeoff. | +| `default` / `main-batch` / `misc-batch` | `build`, `build-dist`, `build:dev` | Gulp orchestration (`gulp.series` / `gulp-multi-process`) is gone. Native Nx `build` covers the non-uglify default batch; `build -c production` (+ `build:npm -c production`) matches the old `gulp default --uglify`; `build -c production-internal` matches uglify + `BUILD_INTERNAL_PACKAGE`; `build -c testing` matches `BUILD_TEST_INTERNAL_PACKAGE`. `build-dist` is a thin wrapper (`pnpm nx run devextreme:build -c production`, `-c internal` → `production-internal`). `build:dev` is the former `DEVEXTREME_TEST_CI` path: clean → localization → `build:transpile -c ci` → parallel `bundle:debug,build:vectormap,copy:vendor` (skips prod bundles, aspnet, declarations, npm, license checks). npm scripts `build:dev` / `build-dist` / `clean` / `transpile-tests` call Nx directly. | diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 20a4ed193927..a4d6b60d0262 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1586,21 +1586,6 @@ importers: sinon: specifier: 18.0.1 version: 18.0.1 - systemjs: - specifier: 0.19.41 - version: 0.19.41 - systemjs-plugin-babel: - specifier: 0.0.25 - version: 0.0.25 - systemjs-plugin-css: - specifier: 0.1.37 - version: 0.1.37 - systemjs-plugin-json: - specifier: 0.3.0 - version: 0.3.0 - systemjs-plugin-text: - specifier: 0.0.11 - version: 0.0.11 terser-webpack-plugin: specifier: 5.3.17 version: 5.3.17(@swc/core@1.15.30(@swc/helpers@0.5.21))(esbuild@0.28.1)(webpack@5.105.4(@swc/core@1.15.30(@swc/helpers@0.5.21))(esbuild@0.28.1)) @@ -16194,18 +16179,9 @@ packages: systemjs-builder@0.16.15: resolution: {integrity: sha512-C18G//KWWwQpstAVBUDt0YbbqvSFVVtr0MFqtf2zB4U/cePOA00Btcja++mzlFLMnepVpDv0GdtfE/6A8lrxeA==} - systemjs-plugin-babel@0.0.25: - resolution: {integrity: sha512-RMKSizWWlw4+IpDB385ugxn7Owd9W+HEtjYDQ6yO1FpsnER/vk6FbXRweUF+mvRi6EHgk8vDdUdtui7ReDwX3w==} - - systemjs-plugin-css@0.1.37: - resolution: {integrity: sha512-wCGG62zYXuOlNji5FlBjeMFAnLeAO/HQmFg+8UBX/mlHoAKLHlGFYRstlhGKibRU2oxk/BH9DaihOuhhNLi7Kg==} - systemjs-plugin-json@0.3.0: resolution: {integrity: sha512-GPHZgc6bGIDIQsoNAkhthddApy4ErFhy30rMBrEepkoDidhs0JeSk821htUOSrtqJjnUPBf2gge325B5GfsW0w==} - systemjs-plugin-text@0.0.11: - resolution: {integrity: sha512-buWE27P6iM3WZYXcsiy6+fiulQ/x+Puux4ni5ejTlcUgqUg3/sUvoAUZ4GGPACC0acjxmnaCt3kHb0+uNs1ekw==} - systemjs@0.19.41: resolution: {integrity: sha512-8E9CmZ01dIr52po2LNhc3QuKyeSTyvQfshHMi3lekSbEOdR9OAUOX2X+wPKunZX3CpudM6w3r8eTCjGQrK79Wg==} @@ -37695,14 +37671,8 @@ snapshots: transitivePeerDependencies: - supports-color - systemjs-plugin-babel@0.0.25: {} - - systemjs-plugin-css@0.1.37: {} - systemjs-plugin-json@0.3.0: {} - systemjs-plugin-text@0.0.11: {} - systemjs@0.19.41: dependencies: when: 3.7.8 From 7f47fc288588ca5d441f307e2889b7819765abb6 Mon Sep 17 00:00:00 2001 From: Vladislav Volkov Date: Fri, 14 Aug 2026 18:52:45 +0400 Subject: [PATCH 2/4] Convert CJS imports to ESM (#34777) --- .../DevExpress.animation/translator.tests.js | 9 +- .../DevExpress.aspnet/aspnet_bundled.tests.js | 15 +- .../tests/DevExpress.core/utils.size.tests.js | 35 +- .../DevExpress.data/odataCommonOData.tests.js | 19 +- .../DevExpress.data/storeCustom.tests.js | 14 +- .../storeCustom_loadModeRaw.tests.js | 4 +- .../tests/DevExpress.data/storeLocal.tests.js | 2 +- .../DevExpress.exporter/pdfCreator.tests.js | 16 +- .../DevExpress.exporter/svgCreator.tests.js | 10 +- .../DevExpress.jquery/selectors.tests.js | 13 +- .../tests/DevExpress.jquery/template.tests.js | 186 +- .../DevExpress.localization/ldml.tests.js | 32 +- .../localization.custom.tests.js | 4 +- .../localization.globalize.tests.js | 1533 ++++++++--------- .../localization.globalize.widgets.tests.js | 46 +- .../localization.messages.test.js | 16 +- .../validation.tests.js | 26 +- .../dropDownBox.tests.js | 4 +- .../htmlEditor.missingModules.tests.part1.js | 4 +- .../htmlEditor.missingModules.tests.part2.js | 2 +- .../editing.tests.js | 18 +- .../integration.base.tests.js | 26 +- ...egration.recurrenceRuleValidation.tests.js | 22 +- .../integration.viewSwitcher.tests.js | 22 +- .../loading.tests.js | 10 +- .../diagram.missingModules.tests.js | 2 +- .../dropDownButton.tests.js | 8 +- .../gantt.missingModules.tests.js | 2 +- .../mapParts/bingTests.js | 6 +- .../mapParts/commonTests.js | 5 +- .../mapParts/googleStaticTests.js | 6 +- .../DevExpress.ui.widgets/mapParts/utils.js | 6 +- .../DevExpress.viz.charts/polarChart.tests.js | 4 +- .../barGauge_new.tests.js | 4 +- .../testing/tests/DevExpress/color.tests.js | 2 +- 35 files changed, 1063 insertions(+), 1070 deletions(-) diff --git a/packages/devextreme/testing/tests/DevExpress.animation/translator.tests.js b/packages/devextreme/testing/tests/DevExpress.animation/translator.tests.js index 795307a74539..d2e1bdd5e861 100644 --- a/packages/devextreme/testing/tests/DevExpress.animation/translator.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.animation/translator.tests.js @@ -1,7 +1,8 @@ -const $ = require('jquery'); -const translator = require('common/core/animation/translator'); -const styleUtils = require('core/utils/style'); -const transformStyle = styleUtils.styleProp('transform'); +import $ from 'jquery'; +import translator from 'common/core/animation/translator'; +import { styleProp } from 'core/utils/style'; + +const transformStyle = styleProp('transform'); QUnit.module('translator', { beforeEach: function() { diff --git a/packages/devextreme/testing/tests/DevExpress.aspnet/aspnet_bundled.tests.js b/packages/devextreme/testing/tests/DevExpress.aspnet/aspnet_bundled.tests.js index 3b91756424b0..9677bb02ef5e 100644 --- a/packages/devextreme/testing/tests/DevExpress.aspnet/aspnet_bundled.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.aspnet/aspnet_bundled.tests.js @@ -1,7 +1,8 @@ -define(function(require) { - window.DevExpress_ui_widget_errors = require('ui/widget/ui.errors'); - window.ajaxMock = require('../../helpers/ajaxMock.js'); - require('bundles/dx.web.js'); - require('aspnet.js'); - require('./aspnet.tests.js'); -}); +import DevExpress_ui_widget_errors from 'ui/widget/ui.errors'; +import ajaxMock from '../../helpers/ajaxMock.js'; +import 'bundles/dx.web.js'; +import 'aspnet.js'; +import './aspnet.tests.js'; + +window.DevExpress_ui_widget_errors = DevExpress_ui_widget_errors; +window.ajaxMock = ajaxMock; diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.size.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.size.tests.js index 9869807eb0b3..1fd14a2d9351 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.size.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.size.tests.js @@ -1,5 +1,8 @@ import $ from 'jquery'; -import sizeUtils, { getHeight, getWidth, getInnerHeight, getInnerWidth, getOuterHeight, getOuterWidth } from 'core/utils/size'; +import { + getHeight, getWidth, getInnerHeight, getInnerWidth, getOuterHeight, getOuterWidth, + getElementBoxParams, addOffsetToMaxHeight, addOffsetToMinHeight, getVerticalOffsets, getVisibleHeight, +} from 'core/utils/size'; import browser from 'core/utils/browser'; const testStyles = [ @@ -268,13 +271,13 @@ QUnit.test('element in parent with fixed size', function(assert) { const computedStyles = window.getComputedStyle(element); - assert.deepEqual(sizeUtils.getElementBoxParams('width', computedStyles), { + assert.deepEqual(getElementBoxParams('width', computedStyles), { border: 2, margin: 12, padding: 8 }, 'element borders, paddings and margins were computed correctly'); - assert.deepEqual(sizeUtils.getElementBoxParams('height', computedStyles), { + assert.deepEqual(getElementBoxParams('height', computedStyles), { border: 2, margin: 10, padding: 6 @@ -297,7 +300,7 @@ QUnit.module('calculate height', { QUnit.test('check addOffsetToMaxHeight', function(assert) { const checkFunc = ({ value, offset, container }, expected) => { - assert.strictEqual(sizeUtils.addOffsetToMaxHeight(value, offset, container), expected); + assert.strictEqual(addOffsetToMaxHeight(value, offset, container), expected); }; checkFunc({ value: 300, offset: 0, container: null }, 300); @@ -310,13 +313,13 @@ QUnit.test('check addOffsetToMaxHeight', function(assert) { checkFunc({ value: 'auto', offset: 0, container: null }, 'auto'); checkFunc({ value: null, offset: -50, container: null }, 'none'); - assert.roughEqual(sizeUtils.addOffsetToMaxHeight('50%', -20, window), windowHeight / 2 - 20, 1, 'string value in percent'); - assert.roughEqual(sizeUtils.addOffsetToMaxHeight('50%', -20, this.container), 30, 1, 'string value in percent with specific container'); + assert.roughEqual(addOffsetToMaxHeight('50%', -20, window), windowHeight / 2 - 20, 1, 'string value in percent'); + assert.roughEqual(addOffsetToMaxHeight('50%', -20, this.container), 30, 1, 'string value in percent with specific container'); }); QUnit.test('check addOffsetToMinHeight', function(assert) { const checkFunc = ({ value, offset, container }, expected) => { - assert.strictEqual(sizeUtils.addOffsetToMinHeight(value, offset, container), expected); + assert.strictEqual(addOffsetToMinHeight(value, offset, container), expected); }; checkFunc({ value: 300, offset: 0, container: null }, 300); @@ -329,21 +332,21 @@ QUnit.test('check addOffsetToMinHeight', function(assert) { checkFunc({ value: 'auto', offset: 0, container: null }, 'auto'); checkFunc({ value: null, offset: -50, container: null }, 0); - assert.roughEqual(sizeUtils.addOffsetToMinHeight('50%', -20, window), windowHeight / 2 - 20, 1, 'string value in percent'); - assert.roughEqual(sizeUtils.addOffsetToMaxHeight('50%', -20, this.container), 30, 1, 'string value in percent with specific container'); + assert.roughEqual(addOffsetToMinHeight('50%', -20, window), windowHeight / 2 - 20, 1, 'string value in percent'); + assert.roughEqual(addOffsetToMaxHeight('50%', -20, this.container), 30, 1, 'string value in percent with specific container'); }); QUnit.test('check getVerticalOffsets', function(assert) { - assert.strictEqual(sizeUtils.getVerticalOffsets(null), 0, 'no element'); - assert.strictEqual(sizeUtils.getVerticalOffsets(this.container), 20, 'container paddings'); - assert.strictEqual(sizeUtils.getVerticalOffsets(this.container, true), 30, 'include margins'); - assert.strictEqual(sizeUtils.getVerticalOffsets(this.invisibleElement), 10, 'invisible element paddings'); + assert.strictEqual(getVerticalOffsets(null), 0, 'no element'); + assert.strictEqual(getVerticalOffsets(this.container), 20, 'container paddings'); + assert.strictEqual(getVerticalOffsets(this.container, true), 30, 'include margins'); + assert.strictEqual(getVerticalOffsets(this.invisibleElement), 10, 'invisible element paddings'); }); QUnit.test('check getVisibleHeight', function(assert) { - assert.strictEqual(sizeUtils.getVerticalOffsets(null), 0, 'no element'); - assert.strictEqual(sizeUtils.getVisibleHeight(this.container), 100, 'container height'); - assert.strictEqual(sizeUtils.getVisibleHeight(this.invisibleElement), 0, 'invisible element height'); + assert.strictEqual(getVerticalOffsets(null), 0, 'no element'); + assert.strictEqual(getVisibleHeight(this.container), 100, 'container height'); + assert.strictEqual(getVisibleHeight(this.invisibleElement), 0, 'invisible element height'); }); QUnit.test('height for element with transform', function(assert) { diff --git a/packages/devextreme/testing/tests/DevExpress.data/odataCommonOData.tests.js b/packages/devextreme/testing/tests/DevExpress.data/odataCommonOData.tests.js index 65714c62c3a7..59857ba336d3 100644 --- a/packages/devextreme/testing/tests/DevExpress.data/odataCommonOData.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.data/odataCommonOData.tests.js @@ -1,8 +1,9 @@ -const $ = require('jquery'); -const converters = require('common/data/odata/utils').keyConverters; -const interpretJsonFormat = require('common/data/odata/utils').OData__internals.interpretJsonFormat; -const Guid = require('core/guid'); -const typeUtils = require('core/utils/type'); +import $ from 'jquery'; +import { keyConverters as converters, OData__internals } from 'common/data/odata/utils'; +import Guid from 'core/guid'; +import { isNumeric } from 'core/utils/type'; + +const interpretJsonFormat = OData__internals.interpretJsonFormat; QUnit.module('OData 2'); QUnit.test('key converters', function(assert) { @@ -83,10 +84,10 @@ QUnit.test('count', function(assert) { const t4 = interpretJsonFormat(a4, 'success'); assert.equal(t1.count, 3); - assert.ok(typeUtils.isNumeric(t1.count)); + assert.ok(isNumeric(t1.count)); assert.equal(t2.count, 3); - assert.ok(typeUtils.isNumeric(t2.count)); + assert.ok(isNumeric(t2.count)); assert.ok(!t3.count); assert.ok(!t4.count); @@ -173,10 +174,10 @@ QUnit.test('count', function(assert) { const t4 = interpretJsonFormat(a4, 'success'); assert.equal(t1.count, 3); - assert.ok(typeUtils.isNumeric(t1.count)); + assert.ok(isNumeric(t1.count)); assert.equal(t2.count, 3); - assert.ok(typeUtils.isNumeric(t2.count)); + assert.ok(isNumeric(t2.count)); assert.ok(!t3.count); assert.ok(!t4.count); diff --git a/packages/devextreme/testing/tests/DevExpress.data/storeCustom.tests.js b/packages/devextreme/testing/tests/DevExpress.data/storeCustom.tests.js index 77d783ec7864..9df83eb8ee6e 100644 --- a/packages/devextreme/testing/tests/DevExpress.data/storeCustom.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.data/storeCustom.tests.js @@ -1,8 +1,10 @@ -const $ = require('jquery'); -const CustomStore = require('common/data/custom_store').CustomStore; -const { isLoadResultObject, isGroupItemsArray, isItemsArray } = require('common/data/custom_store'); -const processRequestResultLock = require('common/data/utils').processRequestResultLock; -const config = require('core/config'); +import $ from 'jquery'; +import { CustomStore, isLoadResultObject, isGroupItemsArray, isItemsArray } from 'common/data/custom_store'; +import { processRequestResultLock } from 'common/data/utils'; +import config from 'core/config'; +import ErrorHandlingHelper from '../../helpers/data.errorHandlingHelper.js'; +import ajaxMock from '../../helpers/ajaxMock.js'; + const ERRORS = { INVALID_RETURN: 'E4012', MISSING_USER_FUNC: 'E4011', @@ -10,8 +12,6 @@ const ERRORS = { QUERY_NOT_SUPPORTED: 'E4010', REQUEST_ERROR: 'E4013' }; -const ErrorHandlingHelper = require('../../helpers/data.errorHandlingHelper.js'); -const ajaxMock = require('../../helpers/ajaxMock.js'); QUnit.testDone(function() { ajaxMock.clear(); diff --git a/packages/devextreme/testing/tests/DevExpress.data/storeCustom_loadModeRaw.tests.js b/packages/devextreme/testing/tests/DevExpress.data/storeCustom_loadModeRaw.tests.js index 1d77cb003870..dfe93222a34e 100644 --- a/packages/devextreme/testing/tests/DevExpress.data/storeCustom_loadModeRaw.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.data/storeCustom_loadModeRaw.tests.js @@ -1,5 +1,5 @@ -const CustomStore = require('common/data/custom_store').CustomStore; -const ErrorHandlingHelper = require('../../helpers/data.errorHandlingHelper.js'); +import { CustomStore } from 'common/data/custom_store'; +import ErrorHandlingHelper from '../../helpers/data.errorHandlingHelper.js'; const RAW = 'raw'; diff --git a/packages/devextreme/testing/tests/DevExpress.data/storeLocal.tests.js b/packages/devextreme/testing/tests/DevExpress.data/storeLocal.tests.js index 84d9f5ef2c2c..98f2a6ce1387 100644 --- a/packages/devextreme/testing/tests/DevExpress.data/storeLocal.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.data/storeLocal.tests.js @@ -1,4 +1,4 @@ -const LocalStore = require('common/data/local_store'); +import LocalStore from 'common/data/local_store'; const TEST_NAME = '65DFE188-D178-11E1-A097-51216288709B'; const DX_LOCALSTORAGE_ITEM_NAME = 'dx-data-localStore-' + TEST_NAME; diff --git a/packages/devextreme/testing/tests/DevExpress.exporter/pdfCreator.tests.js b/packages/devextreme/testing/tests/DevExpress.exporter/pdfCreator.tests.js index 0019aba4340f..455daabecc4f 100644 --- a/packages/devextreme/testing/tests/DevExpress.exporter/pdfCreator.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.exporter/pdfCreator.tests.js @@ -1,10 +1,12 @@ -const $ = require('jquery'); -const version = require('core/version').version; -const getData = require('exporter').pdf.getData; -const pdfCreator = require('__internal/exporter/pdf_creator').__tests; -const isFunction = require('core/utils/type').isFunction; -const imageCreator = require('__internal/exporter/image_creator').imageCreator; -const getWindow = require('core/utils/window').getWindow; +import $ from 'jquery'; +import { version } from 'core/version'; +import { pdf } from 'exporter'; +import { __tests as pdfCreator } from '__internal/exporter/pdf_creator'; +import { isFunction } from 'core/utils/type'; +import { imageCreator } from '__internal/exporter/image_creator'; +import { getWindow } from 'core/utils/window'; + +const getData = pdf.getData; const window = getWindow(); const ASN_DATE_REGEX = /CreationDate\s\(D:([0-9]+)Z([0-9]+)'([0-9]+)'/; diff --git a/packages/devextreme/testing/tests/DevExpress.exporter/svgCreator.tests.js b/packages/devextreme/testing/tests/DevExpress.exporter/svgCreator.tests.js index 07af2a88a0a1..f52588a6dc00 100644 --- a/packages/devextreme/testing/tests/DevExpress.exporter/svgCreator.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.exporter/svgCreator.tests.js @@ -1,8 +1,10 @@ -const $ = require('jquery'); -const isFunction = require('core/utils/type').isFunction; -const exporter = require('exporter').svg; +import $ from 'jquery'; +import { isFunction } from 'core/utils/type'; +import { svg } from 'exporter'; +import * as svgUtils from 'core/utils/svg'; + +const exporter = svg; const svgCreator = exporter.creator; -const svgUtils = require('core/utils/svg'); function setupCanvasStub() { // Blob diff --git a/packages/devextreme/testing/tests/DevExpress.jquery/selectors.tests.js b/packages/devextreme/testing/tests/DevExpress.jquery/selectors.tests.js index 1fa633d8d503..3e03a4f8c55f 100644 --- a/packages/devextreme/testing/tests/DevExpress.jquery/selectors.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.jquery/selectors.tests.js @@ -1,10 +1,7 @@ -define(function(require) { - const $ = require('jquery'); - - if(QUnit.urlParams['nojquery']) { - return; - } +import $ from 'jquery'; +import selectors from '__internal/core/utils/m_selectors'; +if(!QUnit.urlParams['nojquery']) { QUnit.testStart(function() { const markup = `
@@ -49,8 +46,6 @@ define(function(require) { $('#qunit-fixture').html(markup); }); - const selectors = require('__internal/core/utils/m_selectors'); - QUnit.test('focusable', function(assert) { const focusableContainer = $('.focusable'); focusableContainer.each(function(index, item) { @@ -78,4 +73,4 @@ define(function(require) { assert.ok(!$(item).is(selectors.tabbable)); }); }); -}); +} diff --git a/packages/devextreme/testing/tests/DevExpress.jquery/template.tests.js b/packages/devextreme/testing/tests/DevExpress.jquery/template.tests.js index 06020db1cc88..c36c17a61804 100644 --- a/packages/devextreme/testing/tests/DevExpress.jquery/template.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.jquery/template.tests.js @@ -1,128 +1,126 @@ -define(function(require) { - const $ = require('jquery'); - const Template = require('core/templates/template').Template; - const setTemplateEngine = require('core/templates/template_engine_registry').setTemplateEngine; - const errors = require('core/errors'); - - QUnit.module('custom template rendering', { - beforeEach: function() { - this.originalLog = errors.log; - }, - afterEach: function() { - errors.log = this.originalLog; +import $ from 'jquery'; +import { Template } from 'core/templates/template'; +import { setTemplateEngine } from 'core/templates/template_engine_registry'; +import errors from 'core/errors'; + +QUnit.module('custom template rendering', { + beforeEach: function() { + this.originalLog = errors.log; + }, + afterEach: function() { + errors.log = this.originalLog; + } +}); + +QUnit.module('user template engine'); + +const customUserTemplate = { + compile: function(element) { + element = $(element); + if(element[0].nodeName.toLowerCase() !== 'script') { + element = $('
').append(element); } - }); - QUnit.module('user template engine'); + const text = element.html(); - const customUserTemplate = { - compile: function(element) { - element = $(element); - if(element[0].nodeName.toLowerCase() !== 'script') { - element = $('
').append(element); + return text.split('$'); + }, + render: function(template, data, index) { + let i; + const result = template.slice(0); + for(i = 0; i < template.length; i++) { + if(template[i] in data) { + result[i] = data[template[i]]; } - - const text = element.html(); - - return text.split('$'); - }, - render: function(template, data, index) { - let i; - const result = template.slice(0); - for(i = 0; i < template.length; i++) { - if(template[i] in data) { - result[i] = data[template[i]]; - } - if(template[i] === '@index') { - result[i] = index; - } + if(template[i] === '@index') { + result[i] = index; } - return result.join(''); } - }; + return result.join(''); + } +}; - QUnit.test('custom user template engine for div template', function(assert) { - setTemplateEngine(customUserTemplate); +QUnit.test('custom user template engine for div template', function(assert) { + setTemplateEngine(customUserTemplate); - const template = new Template($('
$text$
')); - const container = $('
'); + const template = new Template($('
$text$
')); + const container = $('
'); - template.render({ model: { text: 123 }, container: container }); + template.render({ model: { text: 123 }, container: container }); - assert.equal(container.children().length, 1); - assert.equal(container.children().text(), '123'); - }); + assert.equal(container.children().length, 1); + assert.equal(container.children().text(), '123'); +}); - QUnit.test('custom user template engine for script template', function(assert) { - setTemplateEngine(customUserTemplate); +QUnit.test('custom user template engine for script template', function(assert) { + setTemplateEngine(customUserTemplate); - const template = new Template($('')); - const container = $('
'); + const template = new Template($('')); + const container = $('
'); - template.render({ model: { text: 123 }, container: container }); + template.render({ model: { text: 123 }, container: container }); - assert.equal(container.children('b').length, 1); - assert.equal(container.text().replace('\r\n', ''), 'Text: 123'); - }); + assert.equal(container.children('b').length, 1); + assert.equal(container.text().replace('\r\n', ''), 'Text: 123'); +}); - QUnit.test('custom user template engine has access to item index', function(assert) { - setTemplateEngine(customUserTemplate); +QUnit.test('custom user template engine has access to item index', function(assert) { + setTemplateEngine(customUserTemplate); - const template = new Template($('
$text$, ($@index$)
')); - const container = $('
'); + const template = new Template($('
$text$, ($@index$)
')); + const container = $('
'); - template.render({ model: { text: 123 }, container: container, index: 1 }); + template.render({ model: { text: 123 }, container: container, index: 1 }); - assert.equal(container.children().text(), '123, (1)'); - }); + assert.equal(container.children().text(), '123, (1)'); +}); - QUnit.test('removing div template from document on creation', function(assert) { - setTemplateEngine(customUserTemplate); +QUnit.test('removing div template from document on creation', function(assert) { + setTemplateEngine(customUserTemplate); - const template = new Template($('
$text$
')); - const container = $('
'); + const template = new Template($('
$text$
')); + const container = $('
'); - template.render({ model: { text: 123 }, container: container }); + template.render({ model: { text: 123 }, container: container }); - assert.equal(container.children().length, 1); - assert.equal(container.children().text(), '123'); - }); + assert.equal(container.children().length, 1); + assert.equal(container.children().text(), '123'); +}); - QUnit.test('template render result', function(assert) { - setTemplateEngine(customUserTemplate); +QUnit.test('template render result', function(assert) { + setTemplateEngine(customUserTemplate); - const template = new Template($('
$text$
')); - const container = $('
'); + const template = new Template($('
$text$
')); + const container = $('
'); - let result = template.render({ model: { text: 123 }, container: container }); + let result = template.render({ model: { text: 123 }, container: container }); - result = $(result); + result = $(result); - assert.equal(result.length, 1); - assert.equal(result[0].tagName.toLowerCase(), 'div'); - assert.equal(result.text(), '123'); - }); + assert.equal(result.length, 1); + assert.equal(result[0].tagName.toLowerCase(), 'div'); + assert.equal(result.text(), '123'); +}); - QUnit.module('default template engine', { - beforeEach: function() { - setTemplateEngine('default'); - } - }); +QUnit.module('default template engine', { + beforeEach: function() { + setTemplateEngine('default'); + } +}); - QUnit.test('default template engine should clone element', function(assert) { - const $element = $('
123
'); - const template = new Template($element); - const $result = template.render({ model: null, container: $('
') }); +QUnit.test('default template engine should clone element', function(assert) { + const $element = $('
123
'); + const template = new Template($element); + const $result = template.render({ model: null, container: $('
') }); - assert.notEqual($result[0], $element[0]); - }); + assert.notEqual($result[0], $element[0]); +}); - QUnit.test('default template engine should preserve element for transcluded templates', function(assert) { - const $element = $('
123
'); - const template = new Template($element); - const $result = template.render({ model: null, container: $('
'), transclude: true }); +QUnit.test('default template engine should preserve element for transcluded templates', function(assert) { + const $element = $('
123
'); + const template = new Template($element); + const $result = template.render({ model: null, container: $('
'), transclude: true }); - assert.equal($result[0], $element[0]); - }); + assert.equal($result[0], $element[0]); }); diff --git a/packages/devextreme/testing/tests/DevExpress.localization/ldml.tests.js b/packages/devextreme/testing/tests/DevExpress.localization/ldml.tests.js index b96f360e315f..c368509ea446 100644 --- a/packages/devextreme/testing/tests/DevExpress.localization/ldml.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.localization/ldml.tests.js @@ -1,17 +1,15 @@ -require('../../helpers/noIntl.js'); -const getNumberFormatter = require('common/core/localization/ldml/number').getFormatter; -const getNumberFormat = require('common/core/localization/ldml/number').getFormat; -const getDateParser = require('common/core/localization/ldml/date.parser').getParser; -const getRegExpInfo = require('common/core/localization/ldml/date.parser').getRegExpInfo; -const getDateFormatter = require('common/core/localization/ldml/date.formatter').getFormatter; -const getDateFormat = require('common/core/localization/ldml/date.format').getFormat; -const defaultDateNames = require('common/core/localization/default_date_names'); -const numberLocalization = require('common/core/localization/number'); -const dateLocalization = require('common/core/localization/date'); -const extend = require('core/utils/extend').extend; -const console = require('core/utils/console').logger; - -require('common/core/localization/currency'); +import '../../helpers/noIntl.js'; +import { getFormatter as getNumberFormatter, getFormat as getNumberFormat } from 'common/core/localization/ldml/number'; +import { getParser as getDateParser, getRegExpInfo } from 'common/core/localization/ldml/date.parser'; +import { getFormatter as getDateFormatter } from 'common/core/localization/ldml/date.formatter'; +import { getFormat as getDateFormat } from 'common/core/localization/ldml/date.format'; +import defaultDateNames from 'common/core/localization/default_date_names'; +import numberLocalization from 'common/core/localization/number'; +import dateLocalization from 'common/core/localization/date'; +import { extend } from 'core/utils/extend'; +import { logger as console } from 'core/utils/console'; + +import 'common/core/localization/currency'; const dateParts = extend({}, defaultDateNames, { getPeriodNames: function() { @@ -406,14 +404,14 @@ QUnit.module('number formatter', () => { assert.deepEqual(regExpInfo.patterns, [ 'HH', '\' h \'', 'mm' ]); - // eslint-disable-next-line no-useless-escape + assert.deepEqual(regExpInfo.regexp, /^(2[0-3]|1[0-9]|0?[0-9])(\ h\ )([1-5][0-9]|0?[0-9])$/i); regExpInfo = getRegExpInfo('HH:mm', parts); assert.deepEqual(regExpInfo.patterns, [ 'HH', ':', 'mm' ]); - // eslint-disable-next-line no-useless-escape + assert.deepEqual(regExpInfo.regexp, /^(2[0-3]|1[0-9]|0?[0-9])(h|:)([1-5][0-9]|0?[0-9])$/i); parts.getTimeSeparator = function() { @@ -423,7 +421,7 @@ QUnit.module('number formatter', () => { assert.deepEqual(regExpInfo.patterns, [ 'HH', ':', 'mm' ]); - // eslint-disable-next-line no-useless-escape + assert.deepEqual(regExpInfo.regexp, /^(2[0-3]|1[0-9]|0?[0-9])(\[\.\]|:)([1-5][0-9]|0?[0-9])$/i); }); diff --git a/packages/devextreme/testing/tests/DevExpress.localization/localization.custom.tests.js b/packages/devextreme/testing/tests/DevExpress.localization/localization.custom.tests.js index c3079b762b39..254848e54d1f 100644 --- a/packages/devextreme/testing/tests/DevExpress.localization/localization.custom.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.localization/localization.custom.tests.js @@ -1,5 +1,5 @@ -const numberLocalization = require('common/core/localization/number'); -const dateLocalization = require('common/core/localization/date'); +import numberLocalization from 'common/core/localization/number'; +import dateLocalization from 'common/core/localization/date'; QUnit.module('Custom date names', { beforeEach: function() { diff --git a/packages/devextreme/testing/tests/DevExpress.localization/localization.globalize.tests.js b/packages/devextreme/testing/tests/DevExpress.localization/localization.globalize.tests.js index b1131dcb7c4d..02a4ec2b0a06 100644 --- a/packages/devextreme/testing/tests/DevExpress.localization/localization.globalize.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.localization/localization.globalize.tests.js @@ -1,934 +1,933 @@ -define(function(require, exports, module) { - const cldrData = [ - require('devextreme-cldr-data/ar.json!json'), - require('devextreme-cldr-data/ru.json!json'), - require('devextreme-cldr-data/de.json!json'), - require('devextreme-cldr-data/da.json!json') - ]; - - require('common/core/localization/globalize/core'); - require('common/core/localization/globalize/number'); - require('common/core/localization/globalize/currency'); - require('common/core/localization/globalize/date'); - require('common/core/localization/globalize/message'); - - const generateExpectedDate = require('../../helpers/dateHelper.js').generateDate; - - const $ = require('jquery'); - const Globalize = require('globalize'); - const numberLocalization = require('common/core/localization/number'); - const dateLocalization = require('common/core/localization/date'); - const messageLocalization = require('common/core/localization/message'); - const config = require('core/config'); - - const ExcelJSLocalizationFormatTests = require('../DevExpress.exporter/exceljsParts/exceljs.format.tests.js'); - - const likelySubtags = require('cldr-core/supplemental/likelySubtags.json!'); - Globalize.load(likelySubtags); - - cldrData.forEach(localeCldrData => { - Globalize.load(localeCldrData); - }); +import 'common/core/localization/globalize/core'; +import 'common/core/localization/globalize/number'; +import 'common/core/localization/globalize/currency'; +import 'common/core/localization/globalize/date'; +import 'common/core/localization/globalize/message'; - const NBSP = String.fromCharCode(160); - const RUB = String.fromCharCode(8381); +import { generateDate as generateExpectedDate } from '../../helpers/dateHelper.js'; - const noop = require('core/utils/common').noop; - const formatHelper = require('format_helper'); - const browser = require('core/utils/browser'); - const dateUtils = require('core/utils/date'); +import $ from 'jquery'; +import Globalize from 'globalize'; +import numberLocalization from 'common/core/localization/number'; +import dateLocalization from 'common/core/localization/date'; +import messageLocalization from 'common/core/localization/message'; +import config from 'core/config'; - const sharedTests = require('./sharedParts/localization.shared.js').default; +import ExcelJSLocalizationFormatTests from '../DevExpress.exporter/exceljsParts/exceljs.format.tests.js'; - const NEGATIVE_NUMBERS = [-4.645, -35.855]; - const ROUNDING_CORRECTION = { - '-4.64': '-4.65', - '-35.85': '-35.86' - }; +import likelySubtags from 'cldr-core/supplemental/likelySubtags.json!'; - function isIosWithMSKTimeZone() { - const isIos = navigator.userAgent.indexOf('Mac OS X') > -1 && browser['webkit']; - const hasMSKTimeZone = new Date().toString().indexOf('MSK') > -1; +import { noop } from 'core/utils/common'; +import formatHelper from 'format_helper'; +import browser from 'core/utils/browser'; +import dateUtils from 'core/utils/date'; - return isIos && hasMSKTimeZone; - } +import sharedTests from './sharedParts/localization.shared.js'; - QUnit.module('Globalize common', { - before: function() { - numberLocalization.inject({ - format: function(value, format) { - // NOTE: Globalizejs implementation of negative number rounding differs from Intl. - // https://github.com/globalizejs/globalize/issues/884 - // If the fractional portion is exactly 0.5 and the argument is negative, - // the argument is rounded to the next integer in the positive direction - let result = this.callBase.apply(this, arguments); - if(NEGATIVE_NUMBERS.indexOf(value) !== -1 && format.type === 'fixedPoint' && format.precision === 2 && !!ROUNDING_CORRECTION[result]) { - result = ROUNDING_CORRECTION[result]; - } - return result; - } - }); - } - }, function() { +import ar from 'devextreme-cldr-data/ar.json!json'; +import ru from 'devextreme-cldr-data/ru.json!json'; +import de from 'devextreme-cldr-data/de.json!json'; +import da from 'devextreme-cldr-data/da.json!json'; + +const cldrData = [ar, ru, de, da]; + +Globalize.load(likelySubtags); + +cldrData.forEach(localeCldrData => { + Globalize.load(localeCldrData); +}); - QUnit.test('engine', function(assert) { - assert.equal(numberLocalization.engine(), 'globalize'); - assert.equal(dateLocalization.engine(), 'globalize'); - assert.equal(messageLocalization.engine(), 'globalize'); +const NBSP = String.fromCharCode(160); +const RUB = String.fromCharCode(8381); + +const NEGATIVE_NUMBERS = [-4.645, -35.855]; +const ROUNDING_CORRECTION = { + '-4.64': '-4.65', + '-35.85': '-35.86' +}; + +function isIosWithMSKTimeZone() { + const isIos = navigator.userAgent.indexOf('Mac OS X') > -1 && browser['webkit']; + const hasMSKTimeZone = new Date().toString().indexOf('MSK') > -1; + + return isIos && hasMSKTimeZone; +} + +QUnit.module('Globalize common', { + before: function() { + numberLocalization.inject({ + format: function(value, format) { + // NOTE: Globalizejs implementation of negative number rounding differs from Intl. + // https://github.com/globalizejs/globalize/issues/884 + // If the fractional portion is exactly 0.5 and the argument is negative, + // the argument is rounded to the next integer in the positive direction + let result = this.callBase.apply(this, arguments); + if(NEGATIVE_NUMBERS.indexOf(value) !== -1 && format.type === 'fixedPoint' && format.precision === 2 && !!ROUNDING_CORRECTION[result]) { + result = ROUNDING_CORRECTION[result]; + } + return result; + } }); + } +}, function() { - sharedTests(); + QUnit.test('engine', function(assert) { + assert.equal(numberLocalization.engine(), 'globalize'); + assert.equal(dateLocalization.engine(), 'globalize'); + assert.equal(messageLocalization.engine(), 'globalize'); }); - QUnit.module('Localization date (ru)', { - beforeEach: function() { - Globalize.locale('ru'); - }, - afterEach: function() { - Globalize.locale('en'); - } - }, () => { - QUnit.test('getFormatParts', function(assert) { - assert.equal(dateLocalization.getFormatParts('dayofweek').length, 0); - assert.equal(dateLocalization.getFormatParts('shortdate').join(' '), 'day month year'); - assert.equal(dateLocalization.getFormatParts('longDateLongTime').join(' '), 'day month year hours minutes seconds'); - assert.equal(dateLocalization.getFormatParts('d - M - y, hh:mm:ss [SSS]').join(' '), 'day month year hours minutes seconds milliseconds'); - assert.equal(dateLocalization.getFormatParts('ah:mm').join(' '), 'hours minutes'); // T460693 - }); + sharedTests(); +}); - QUnit.test('getMonthNames', function(assert) { - assert.deepEqual(dateLocalization.getMonthNames(), - ['январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь'], - 'Array of month names'); - }); +QUnit.module('Localization date (ru)', { + beforeEach: function() { + Globalize.locale('ru'); + }, + afterEach: function() { + Globalize.locale('en'); + } +}, () => { + QUnit.test('getFormatParts', function(assert) { + assert.equal(dateLocalization.getFormatParts('dayofweek').length, 0); + assert.equal(dateLocalization.getFormatParts('shortdate').join(' '), 'day month year'); + assert.equal(dateLocalization.getFormatParts('longDateLongTime').join(' '), 'day month year hours minutes seconds'); + assert.equal(dateLocalization.getFormatParts('d - M - y, hh:mm:ss [SSS]').join(' '), 'day month year hours minutes seconds milliseconds'); + assert.equal(dateLocalization.getFormatParts('ah:mm').join(' '), 'hours minutes'); // T460693 + }); - QUnit.test('getMonthNames with specified type', function(assert) { - assert.deepEqual(dateLocalization.getMonthNames('wide', 'format'), - ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'], - 'Array of month names'); - }); + QUnit.test('getMonthNames', function(assert) { + assert.deepEqual(dateLocalization.getMonthNames(), + ['январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь'], + 'Array of month names'); + }); - QUnit.test('getMonthNames with type=\'standalone\'', function(assert) { - assert.deepEqual(dateLocalization.getMonthNames('wide', 'standalone'), - ['январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь'], - 'Array of month names'); - }); + QUnit.test('getMonthNames with specified type', function(assert) { + assert.deepEqual(dateLocalization.getMonthNames('wide', 'format'), + ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'], + 'Array of month names'); + }); + + QUnit.test('getMonthNames with type=\'standalone\'', function(assert) { + assert.deepEqual(dateLocalization.getMonthNames('wide', 'standalone'), + ['январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь'], + 'Array of month names'); + }); - QUnit.test('getPeriodNames', function(assert) { - assert.deepEqual(dateLocalization.getPeriodNames(), ['AM', 'PM'], 'Array of period names'); + QUnit.test('getPeriodNames', function(assert) { + assert.deepEqual(dateLocalization.getPeriodNames(), ['AM', 'PM'], 'Array of period names'); - Globalize.locale('ar'); + Globalize.locale('ar'); - [null, 'abbreviated', 'wide', 'narrow'].forEach(format => { - ['format', null].forEach(type => { - const expect = ([null, 'wide'].includes(format) && type == null) ? ['صباحًا', 'مساءً'] : ['ص', 'م']; + [null, 'abbreviated', 'wide', 'narrow'].forEach(format => { + ['format', null].forEach(type => { + const expect = ([null, 'wide'].includes(format) && type == null) ? ['صباحًا', 'مساءً'] : ['ص', 'م']; - assert.deepEqual(dateLocalization.getPeriodNames(format, type), expect, 'Array of correct period names'); - }); + assert.deepEqual(dateLocalization.getPeriodNames(format, type), expect, 'Array of correct period names'); }); }); + }); - QUnit.test('getDayNames', function(assert) { - assert.deepEqual(dateLocalization.getDayNames(), - ['воскресенье', 'понедельник', 'вторник', 'среда', 'четверг', 'пятница', 'суббота'], - 'Array of day names'); - }); - - QUnit.test('getTimeSeparator', function(assert) { - assert.equal(dateLocalization.getTimeSeparator(), ':'); - }); - - QUnit.test('format', function(assert) { - const expectedValues = { - 'day': '2', - 'dayofweek': 'понедельник', - 'hour': '03', - 'longdate': 'понедельник, 2 марта 2015 г.', - 'longdatelongtime': 'понедельник, 2 марта 2015 г., 03:04:05', - 'longtime': '03:04:05', - 'millisecond': '006', - 'minute': '04', - 'month': 'март', - 'monthandday': '2 марта', - 'monthandyear': 'март 2015 г.', - 'quarter': '1-й кв.', - 'quarterandyear': '1-й кв. 2015 г.', - 'second': '05', - 'shortdate': '02.03.2015', - 'shortdateshorttime': '02.03.2015, 03:04', - 'shorttime': '03:04', - 'shortyear': '15', - 'year': '2015', - - 'datetime-local': '2015-03-02T03:04:05', - 'yyyy MMMM d': '2015 марта 2', - 'ss SSS': '05 006' - }; - const date = new Date(2015, 2, 2, 3, 4, 5); - - date.setMilliseconds(6); - - $.each(expectedValues, function(format, expectedValue) { - assert.equal(dateLocalization.format(date, format), expectedValue, format + ' format'); - }); + QUnit.test('getDayNames', function(assert) { + assert.deepEqual(dateLocalization.getDayNames(), + ['воскресенье', 'понедельник', 'вторник', 'среда', 'четверг', 'пятница', 'суббота'], + 'Array of day names'); + }); + + QUnit.test('getTimeSeparator', function(assert) { + assert.equal(dateLocalization.getTimeSeparator(), ':'); + }); - assert.equal(dateLocalization.format(date), String(new Date(2015, 2, 2, 3, 4, 5)), 'without format'); - assert.notOk(dateLocalization.format(), 'without date'); + QUnit.test('format', function(assert) { + const expectedValues = { + 'day': '2', + 'dayofweek': 'понедельник', + 'hour': '03', + 'longdate': 'понедельник, 2 марта 2015 г.', + 'longdatelongtime': 'понедельник, 2 марта 2015 г., 03:04:05', + 'longtime': '03:04:05', + 'millisecond': '006', + 'minute': '04', + 'month': 'март', + 'monthandday': '2 марта', + 'monthandyear': 'март 2015 г.', + 'quarter': '1-й кв.', + 'quarterandyear': '1-й кв. 2015 г.', + 'second': '05', + 'shortdate': '02.03.2015', + 'shortdateshorttime': '02.03.2015, 03:04', + 'shorttime': '03:04', + 'shortyear': '15', + 'year': '2015', + + 'datetime-local': '2015-03-02T03:04:05', + 'yyyy MMMM d': '2015 марта 2', + 'ss SSS': '05 006' + }; + const date = new Date(2015, 2, 2, 3, 4, 5); + + date.setMilliseconds(6); + + $.each(expectedValues, function(format, expectedValue) { + assert.equal(dateLocalization.format(date, format), expectedValue, format + ' format'); }); - QUnit.test('format cache for different locales', function(assert) { - const originalLocale = Globalize.locale().locale; - const date = new Date(2015, 2, 2, 3, 4, 5); - try { - Globalize.locale('en'); - assert.equal(dateLocalization.format(date, 'month'), 'March'); - } finally { - Globalize.locale(originalLocale); - assert.equal(dateLocalization.format(date, 'month'), 'март'); + assert.equal(dateLocalization.format(date), String(new Date(2015, 2, 2, 3, 4, 5)), 'without format'); + assert.notOk(dateLocalization.format(), 'without date'); + }); + + QUnit.test('format cache for different locales', function(assert) { + const originalLocale = Globalize.locale().locale; + const date = new Date(2015, 2, 2, 3, 4, 5); + try { + Globalize.locale('en'); + assert.equal(dateLocalization.format(date, 'month'), 'March'); + } finally { + Globalize.locale(originalLocale); + assert.equal(dateLocalization.format(date, 'month'), 'март'); + } + }); + + QUnit.test('parse', function(assert) { + const assertData = { + 'day': { + text: '2', + expectedConfig: { day: 2 } + }, + 'hour': { + text: '03', + expectedConfig: { hours: 3 } + }, + 'longdate': { + text: 'понедельник, 2 марта 2015 г.', + expected: new Date(2015, 2, 2) + }, + 'longdatelongtime': { + text: 'понедельник, 2 марта 2015 г., 3:04:05', + expected: new Date(2015, 2, 2, 3, 4, 5) + }, + 'longtime': { + text: '3:04:05', + expectedConfig: { hours: 3, minutes: 4, seconds: 5 } + }, + 'minute': { + text: '04', + expectedConfig: { minutes: 4 } + }, + 'month': { + text: 'март', + expectedConfig: { month: 2, day: 1 } + }, + 'monthandday': { + text: '2 марта', + expectedConfig: { month: 2, day: 2 } + }, + 'monthandyear': { + text: 'март 2015 г.', + expected: new Date(2015, 2, 1) + }, + 'second': { + text: '05', + expectedConfig: { seconds: 5 } + }, + 'shortdate': { + text: '02.03.2015', + expected: new Date(2015, 2, 2) + }, + 'shortdateshorttime': { + text: '02.03.2015, 3:04', + expected: new Date(2015, 2, 2, 3, 4) + }, + 'shorttime': { + text: '3:04', + expectedConfig: { hours: 3, minutes: 4 } + }, + 'shortyear': { + text: '15', + expected: new Date(2015, 0, 1) + }, + 'year': { + text: '2015', + expected: new Date(2015, 0, 1) + }, + + 'datetime-local': { + text: '2015-03-02T03:04:05', + expected: new Date(2015, 2, 2, 3, 4, 5) + }, + 'yyyy MMMM d': { + text: '2015 марта 2', + expected: new Date(2015, 2, 2) } + }; + + $.each(assertData, function(format, data) { + assert.equal(dateLocalization.parse(data.text, format), String(data.expected || generateExpectedDate(data.expectedConfig)), format + ' format'); }); - QUnit.test('parse', function(assert) { - const assertData = { - 'day': { - text: '2', - expectedConfig: { day: 2 } - }, - 'hour': { - text: '03', - expectedConfig: { hours: 3 } - }, - 'longdate': { - text: 'понедельник, 2 марта 2015 г.', - expected: new Date(2015, 2, 2) - }, - 'longdatelongtime': { - text: 'понедельник, 2 марта 2015 г., 3:04:05', - expected: new Date(2015, 2, 2, 3, 4, 5) - }, - 'longtime': { - text: '3:04:05', - expectedConfig: { hours: 3, minutes: 4, seconds: 5 } - }, - 'minute': { - text: '04', - expectedConfig: { minutes: 4 } - }, - 'month': { - text: 'март', - expectedConfig: { month: 2, day: 1 } - }, - 'monthandday': { - text: '2 марта', - expectedConfig: { month: 2, day: 2 } - }, - 'monthandyear': { - text: 'март 2015 г.', - expected: new Date(2015, 2, 1) - }, - 'second': { - text: '05', - expectedConfig: { seconds: 5 } - }, - 'shortdate': { - text: '02.03.2015', - expected: new Date(2015, 2, 2) - }, - 'shortdateshorttime': { - text: '02.03.2015, 3:04', - expected: new Date(2015, 2, 2, 3, 4) - }, - 'shorttime': { - text: '3:04', - expectedConfig: { hours: 3, minutes: 4 } - }, - 'shortyear': { - text: '15', - expected: new Date(2015, 0, 1) - }, - 'year': { - text: '2015', - expected: new Date(2015, 0, 1) - }, - - 'datetime-local': { - text: '2015-03-02T03:04:05', - expected: new Date(2015, 2, 2, 3, 4, 5) - }, - 'yyyy MMMM d': { - text: '2015 марта 2', - expected: new Date(2015, 2, 2) - } - }; + assert.equal(dateLocalization.parse('550', 'millisecond').getMilliseconds(), 550, 'millisecond format'); + assert.equal(dateLocalization.parse('550', 'SSS').getMilliseconds(), 550, 'millisecond format'); - $.each(assertData, function(format, data) { - assert.equal(dateLocalization.parse(data.text, format), String(data.expected || generateExpectedDate(data.expectedConfig)), format + ' format'); - }); + assert.equal(dateLocalization.parse(dateLocalization.format(new Date(), 'shortDate')), String(generateExpectedDate({ hours: 0 })), 'without format'); + assert.notOk(dateLocalization.parse(), 'without date'); - assert.equal(dateLocalization.parse('550', 'millisecond').getMilliseconds(), 550, 'millisecond format'); - assert.equal(dateLocalization.parse('550', 'SSS').getMilliseconds(), 550, 'millisecond format'); + assert.equal(dateLocalization.parse(Globalize.formatDate(new Date(), { date: 'short' }), { date: 'short' }), String(generateExpectedDate({ hours: 0 })), 'globalize format'); + }); - assert.equal(dateLocalization.parse(dateLocalization.format(new Date(), 'shortDate')), String(generateExpectedDate({ hours: 0 })), 'without format'); - assert.notOk(dateLocalization.parse(), 'without date'); + QUnit.test('firstDayOfWeekIndex', function(assert) { + assert.equal(dateLocalization.firstDayOfWeekIndex(), 1); + }); +}); - assert.equal(dateLocalization.parse(Globalize.formatDate(new Date(), { date: 'short' }), { date: 'short' }), String(generateExpectedDate({ hours: 0 })), 'globalize format'); - }); +QUnit.module('Custom format types', () => { + QUnit.test('format: { time: \'medium\' }', function(assert) { + assert.equal(dateLocalization.format(new Date(2015, 1, 2, 3, 4, 5, 6), { time: 'medium' }), '3:04:05 AM', 'with object format'); + }); - QUnit.test('firstDayOfWeekIndex', function(assert) { - assert.equal(dateLocalization.firstDayOfWeekIndex(), 1); - }); + QUnit.test('Parse custom format', function(assert) { + const expected = new Date(2010, 2, 2).toString(); + assert.equal(dateLocalization.parse('20100302', 'yyyyMMdd'), expected, 'Format \'yyyyMMdd\' parse ok'); + assert.equal(dateLocalization.parse('02mar10', 'dMyyyy'), expected, 'Format \'dMyyyy\' parse ok'); }); +}); - QUnit.module('Custom format types', () => { - QUnit.test('format: { time: \'medium\' }', function(assert) { - assert.equal(dateLocalization.format(new Date(2015, 1, 2, 3, 4, 5, 6), { time: 'medium' }), '3:04:05 AM', 'with object format'); +QUnit.module('Localization message (custom locales)', { + beforeEach: function() { + messageLocalization.load({ + 'en': { + addedKey: 'testValue', + hello: 'Hello, {0} {1}' + } + }); + } +}, () => { + QUnit.test('Fallback to neutral culture', function(assert) { + const originalLocale = Globalize.locale().locale; + + messageLocalization.load({ + 'ru': { + TestBack: 'Back ru', + TestCancel: 'Cancel ru' + } }); - QUnit.test('Parse custom format', function(assert) { - const expected = new Date(2010, 2, 2).toString(); - assert.equal(dateLocalization.parse('20100302', 'yyyyMMdd'), expected, 'Format \'yyyyMMdd\' parse ok'); - assert.equal(dateLocalization.parse('02mar10', 'dMyyyy'), expected, 'Format \'dMyyyy\' parse ok'); + messageLocalization.load({ + 'ru-RU': { + TestCancel: 'Cancel ru-RU' + } }); + + try { + Globalize.locale('ru-RU'); + + assert.equal(messageLocalization.format('TestBack'), 'Back ru'); + assert.equal(messageLocalization.format('TestCancel'), 'Cancel ru-RU'); + } finally { + Globalize.locale(originalLocale); + } }); - QUnit.module('Localization message (custom locales)', { - beforeEach: function() { - messageLocalization.load({ - 'en': { - addedKey: 'testValue', - hello: 'Hello, {0} {1}' - } - }); + + QUnit.test('Fallback to default (en) culture', function(assert) { + const originalLocale = Globalize.locale().locale; + try { + Globalize.locale('ru'); + + assert.equal(messageLocalization.format('OK'), 'OK'); + assert.equal(messageLocalization.getFormatter('OK')(), 'OK'); + } finally { + Globalize.locale(originalLocale); } - }, () => { - QUnit.test('Fallback to neutral culture', function(assert) { - const originalLocale = Globalize.locale().locale; + }); - messageLocalization.load({ - 'ru': { - TestBack: 'Back ru', - TestCancel: 'Cancel ru' - } - }); + QUnit.test('Extended culture with empty string value (T271323)', function(assert) { + const originalLocale = Globalize.locale().locale; - messageLocalization.load({ - 'ru-RU': { - TestCancel: 'Cancel ru-RU' + Globalize.load({ + 'supplemental': { + 'likelySubtags': { + 'zh': 'zh-Hans-CN' } - }); - - try { - Globalize.locale('ru-RU'); + } + }); - assert.equal(messageLocalization.format('TestBack'), 'Back ru'); - assert.equal(messageLocalization.format('TestCancel'), 'Cancel ru-RU'); - } finally { - Globalize.locale(originalLocale); + messageLocalization.load({ + 'zh-CN': { + addedKey: '' } }); + try { + Globalize.locale('zh-CN'); - QUnit.test('Fallback to default (en) culture', function(assert) { - const originalLocale = Globalize.locale().locale; - try { - Globalize.locale('ru'); + assert.equal(messageLocalization.localizeString('@addedKey'), 'testValue', 'Default culture value'); + } finally { + Globalize.locale(originalLocale); + } + }); - assert.equal(messageLocalization.format('OK'), 'OK'); - assert.equal(messageLocalization.getFormatter('OK')(), 'OK'); - } finally { - Globalize.locale(originalLocale); + QUnit.test('localizeString by custom locale (T383089)', function(assert) { + messageLocalization.load({ + 'ru': { + 'ruAddedKey': 'ruValue' } }); + Globalize.locale('ru'); + const localized = messageLocalization.localizeString('@ruAddedKey @@ruAddedKey @'); + assert.equal(localized, 'ruValue @ruAddedKey @'); - QUnit.test('Extended culture with empty string value (T271323)', function(assert) { - const originalLocale = Globalize.locale().locale; + Globalize.locale('en'); + }); - Globalize.load({ - 'supplemental': { - 'likelySubtags': { - 'zh': 'zh-Hans-CN' - } - } - }); + QUnit.test('Empty message', function(assert) { + Globalize.loadMessages({ + 'en': { + 'empty': '' + } + }); - messageLocalization.load({ - 'zh-CN': { - addedKey: '' - } - }); + assert.equal(messageLocalization.format('empty'), ''); + }); - try { - Globalize.locale('zh-CN'); + QUnit.test('DX messages can be customized', function(assert) { + assert.equal(messageLocalization.format('dxCollectionWidget-noDataText'), 'No data to display'); - assert.equal(messageLocalization.localizeString('@addedKey'), 'testValue', 'Default culture value'); - } finally { - Globalize.locale(originalLocale); + Globalize.loadMessages({ + 'en': { + 'dxCollectionWidget-noDataText': 'Custom caption' } }); - QUnit.test('localizeString by custom locale (T383089)', function(assert) { - messageLocalization.load({ - 'ru': { - 'ruAddedKey': 'ruValue' - } - }); - Globalize.locale('ru'); - const localized = messageLocalization.localizeString('@ruAddedKey @@ruAddedKey @'); - assert.equal(localized, 'ruValue @ruAddedKey @'); + assert.equal(messageLocalization.format('dxCollectionWidget-noDataText'), 'Custom caption'); + }); - Globalize.locale('en'); + QUnit.test('getDictionary ru', function(assert) { + messageLocalization.load({ + 'ru': { + 'freshRuAddedKey': 'ruValue' + } }); + Globalize.locale('ru'); - QUnit.test('Empty message', function(assert) { - Globalize.loadMessages({ - 'en': { - 'empty': '' - } - }); + messageLocalization.localizeString('@unknownKey'); + messageLocalization.localizeString('@ruAddedKey'); - assert.equal(messageLocalization.format('empty'), ''); - }); + assert.equal(messageLocalization.getDictionary()['freshRuAddedKey'], 'ruValue'); + assert.equal(messageLocalization.getDictionary(true)['freshRuAddedKey'], undefined); + assert.equal(messageLocalization.getDictionary()['unknownKey'], 'Unknown key'); + assert.equal(messageLocalization.getDictionary(true)['unknownKey'], 'Unknown key'); - QUnit.test('DX messages can be customized', function(assert) { - assert.equal(messageLocalization.format('dxCollectionWidget-noDataText'), 'No data to display'); + Globalize.locale('en'); + }); +}); - Globalize.loadMessages({ - 'en': { - 'dxCollectionWidget-noDataText': 'Custom caption' - } - }); +QUnit.module('Localization globalizeNumber', () => { + QUnit.test('format', function(assert) { + assert.equal(numberLocalization.format(1.2), '1.2'); + assert.equal(numberLocalization.format(12), '12'); + assert.equal(numberLocalization.format(2, { minimumIntegerDigits: 2 }), '02'); + assert.equal(numberLocalization.format(12, { minimumIntegerDigits: 2 }), '12'); + assert.equal(numberLocalization.format(2, { minimumIntegerDigits: 3 }), '002'); + assert.equal(numberLocalization.format(12, { minimumIntegerDigits: 3 }), '012'); + assert.equal(numberLocalization.format(123, { minimumIntegerDigits: 3 }), '123'); + }); +}); - assert.equal(messageLocalization.format('dxCollectionWidget-noDataText'), 'Custom caption'); - }); +QUnit.module('Localization currency with Globalize', () => { - QUnit.test('getDictionary ru', function(assert) { - messageLocalization.load({ - 'ru': { - 'freshRuAddedKey': 'ruValue' - } - }); - Globalize.locale('ru'); + QUnit.test('format currency default after global config change', function(assert) { + const originalDefaultCurrency = config().defaultCurrency; - messageLocalization.localizeString('@unknownKey'); - messageLocalization.localizeString('@ruAddedKey'); + assert.equal(numberLocalization.format(1.2, { currency: 'default' }), '$1.20'); - assert.equal(messageLocalization.getDictionary()['freshRuAddedKey'], 'ruValue'); - assert.equal(messageLocalization.getDictionary(true)['freshRuAddedKey'], undefined); - assert.equal(messageLocalization.getDictionary()['unknownKey'], 'Unknown key'); - assert.equal(messageLocalization.getDictionary(true)['unknownKey'], 'Unknown key'); + config({ defaultCurrency: 'EUR' }); + assert.equal(numberLocalization.format(12, { currency: 'default' }), '€12.00'); + + config({ defaultCurrency: originalDefaultCurrency }); + assert.equal(numberLocalization.format(1.2, { currency: 'default' }), '$1.20'); - Globalize.locale('en'); - }); }); - QUnit.module('Localization globalizeNumber', () => { - QUnit.test('format', function(assert) { - assert.equal(numberLocalization.format(1.2), '1.2'); - assert.equal(numberLocalization.format(12), '12'); - assert.equal(numberLocalization.format(2, { minimumIntegerDigits: 2 }), '02'); - assert.equal(numberLocalization.format(12, { minimumIntegerDigits: 2 }), '12'); - assert.equal(numberLocalization.format(2, { minimumIntegerDigits: 3 }), '002'); - assert.equal(numberLocalization.format(12, { minimumIntegerDigits: 3 }), '012'); - assert.equal(numberLocalization.format(123, { minimumIntegerDigits: 3 }), '123'); - }); + QUnit.test('format', function(assert) { + assert.equal(numberLocalization.format(1.2, { currency: 'default' }), '$1.20'); + assert.equal(numberLocalization.format(12, { currency: 'default' }), '$12.00'); + assert.equal(numberLocalization.format(1, { minimumIntegerDigits: 2, minimumFractionDigits: 0, currency: 'default' }), '$01'); + assert.equal(numberLocalization.format(1, { minimumIntegerDigits: 2, minimumFractionDigits: 0, currency: 'RUB' }), 'RUB' + NBSP + '01'); }); - QUnit.module('Localization currency with Globalize', () => { + QUnit.test('format currency with sign/style (T1076906)', function(assert) { + assert.equal(numberLocalization.format(-1.2, { currency: 'default', style: 'accounting' }), '($1.20)'); + assert.equal(numberLocalization.format(-1.2, { type: 'currency', useCurrencyAccountingStyle: true }), '($1)'); + assert.equal(numberLocalization.format(-12, { currency: 'default', style: 'symbol' }), '-$12.00'); + assert.equal(numberLocalization.format(-12, { type: 'currency', useCurrencyAccountingStyle: false }), '-$12'); + }); - QUnit.test('format currency default after global config change', function(assert) { - const originalDefaultCurrency = config().defaultCurrency; + QUnit.test('format currency & power in RU locale', function(assert) { + Globalize.locale('ru'); + assert.equal(numberLocalization.format(0, { type: 'currency thousands', currency: undefined, precision: 0 }), '0K' + NBSP + '$'); + assert.equal(numberLocalization.format(0, { type: 'currency thousands', currency: 'CSK', precision: 2 }), '0,00K' + NBSP + 'CSK'); + assert.equal(numberLocalization.format(2e+5, { type: 'currency thousands', precision: 0 }), '200K' + NBSP + '$'); + Globalize.locale('en'); + }); - assert.equal(numberLocalization.format(1.2, { currency: 'default' }), '$1.20'); + QUnit.test('getOpenXmlCurrencyFormat: check conversion for some cultures (T835933)', function(assert) { + try { + Globalize.locale('en'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat(undefined), '$#,##0{0}_);\\($#,##0{0}\\)'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat('USD'), '$#,##0{0}_);\\($#,##0{0}\\)'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat('RUB'), '\\R\\U\\B#,##0{0}_);\\(\\R\\U\\B#,##0{0}\\)'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat('CNY'), '\\C\\N\\¥#,##0{0}_);\\(\\C\\N\\¥#,##0{0}\\)'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat('NOK'), '\\N\\O\\K#,##0{0}_);\\(\\N\\O\\K#,##0{0}\\)'); + + Globalize.locale('en-ru'); // switch to parent if there are no settings for the passed culture + assert.equal(numberLocalization.getOpenXmlCurrencyFormat(undefined), '$#,##0{0}_);\\($#,##0{0}\\)'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat('USD'), '$#,##0{0}_);\\($#,##0{0}\\)'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat('RUB'), '\\R\\U\\B#,##0{0}_);\\(\\R\\U\\B#,##0{0}\\)'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat('CNY'), '\\C\\N\\¥#,##0{0}_);\\(\\C\\N\\¥#,##0{0}\\)'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat('NOK'), '\\N\\O\\K#,##0{0}_);\\(\\N\\O\\K#,##0{0}\\)'); - config({ defaultCurrency: 'EUR' }); - assert.equal(numberLocalization.format(12, { currency: 'default' }), '€12.00'); + Globalize.locale('ru'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat(undefined), '#,##0{0}\xA0$'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat('USD'), '#,##0{0}\xA0$'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat('RUB'), '#,##0{0}\xA0\\₽'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat('CNY'), '#,##0{0}\xA0\\C\\N\\¥'); + assert.equal(numberLocalization.getOpenXmlCurrencyFormat('NOK'), '#,##0{0}\xA0\\N\\O\\K'); + } finally { + Globalize.locale('en'); + } + }); - config({ defaultCurrency: originalDefaultCurrency }); - assert.equal(numberLocalization.format(1.2, { currency: 'default' }), '$1.20'); + QUnit.test('getDecimalSeparator and getThousandsSeparator in RU locale', function(assert) { + Globalize.locale('ru'); + assert.equal(numberLocalization.getDecimalSeparator(), ','); + assert.equal(numberLocalization.getThousandsSeparator(), '\xa0'); + Globalize.locale('en'); + }); - }); + QUnit.test('getCurrencySymbol and config.defaultCurrency', function(assert) { + const originalDefaultCurrency = config().defaultCurrency; - QUnit.test('format', function(assert) { - assert.equal(numberLocalization.format(1.2, { currency: 'default' }), '$1.20'); - assert.equal(numberLocalization.format(12, { currency: 'default' }), '$12.00'); - assert.equal(numberLocalization.format(1, { minimumIntegerDigits: 2, minimumFractionDigits: 0, currency: 'default' }), '$01'); - assert.equal(numberLocalization.format(1, { minimumIntegerDigits: 2, minimumFractionDigits: 0, currency: 'RUB' }), 'RUB' + NBSP + '01'); - }); + try { + assert.equal(numberLocalization.getCurrencySymbol().symbol, '$'); - QUnit.test('format currency with sign/style (T1076906)', function(assert) { - assert.equal(numberLocalization.format(-1.2, { currency: 'default', style: 'accounting' }), '($1.20)'); - assert.equal(numberLocalization.format(-1.2, { type: 'currency', useCurrencyAccountingStyle: true }), '($1)'); - assert.equal(numberLocalization.format(-12, { currency: 'default', style: 'symbol' }), '-$12.00'); - assert.equal(numberLocalization.format(-12, { type: 'currency', useCurrencyAccountingStyle: false }), '-$12'); - }); + config({ + defaultCurrency: 'EUR' + }); - QUnit.test('format currency & power in RU locale', function(assert) { - Globalize.locale('ru'); - assert.equal(numberLocalization.format(0, { type: 'currency thousands', currency: undefined, precision: 0 }), '0K' + NBSP + '$'); - assert.equal(numberLocalization.format(0, { type: 'currency thousands', currency: 'CSK', precision: 2 }), '0,00K' + NBSP + 'CSK'); - assert.equal(numberLocalization.format(2e+5, { type: 'currency thousands', precision: 0 }), '200K' + NBSP + '$'); - Globalize.locale('en'); - }); + assert.equal(numberLocalization.getCurrencySymbol().symbol, '€'); + } finally { + config({ + defaultCurrency: originalDefaultCurrency + }); + } + }); +}); - QUnit.test('getOpenXmlCurrencyFormat: check conversion for some cultures (T835933)', function(assert) { - try { - Globalize.locale('en'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat(undefined), '$#,##0{0}_);\\($#,##0{0}\\)'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat('USD'), '$#,##0{0}_);\\($#,##0{0}\\)'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat('RUB'), '\\R\\U\\B#,##0{0}_);\\(\\R\\U\\B#,##0{0}\\)'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat('CNY'), '\\C\\N\\¥#,##0{0}_);\\(\\C\\N\\¥#,##0{0}\\)'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat('NOK'), '\\N\\O\\K#,##0{0}_);\\(\\N\\O\\K#,##0{0}\\)'); - - Globalize.locale('en-ru'); // switch to parent if there are no settings for the passed culture - assert.equal(numberLocalization.getOpenXmlCurrencyFormat(undefined), '$#,##0{0}_);\\($#,##0{0}\\)'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat('USD'), '$#,##0{0}_);\\($#,##0{0}\\)'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat('RUB'), '\\R\\U\\B#,##0{0}_);\\(\\R\\U\\B#,##0{0}\\)'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat('CNY'), '\\C\\N\\¥#,##0{0}_);\\(\\C\\N\\¥#,##0{0}\\)'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat('NOK'), '\\N\\O\\K#,##0{0}_);\\(\\N\\O\\K#,##0{0}\\)'); - - Globalize.locale('ru'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat(undefined), '#,##0{0}\xA0$'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat('USD'), '#,##0{0}\xA0$'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat('RUB'), '#,##0{0}\xA0\\₽'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat('CNY'), '#,##0{0}\xA0\\C\\N\\¥'); - assert.equal(numberLocalization.getOpenXmlCurrencyFormat('NOK'), '#,##0{0}\xA0\\N\\O\\K'); - } finally { - Globalize.locale('en'); - } - }); +QUnit.module('Exceljs format', () => { + ExcelJSLocalizationFormatTests.runCurrencyTests([ + { value: 'USD', expected: '$#,##0_);\\($#,##0\\)' }, + { value: 'RUB', expected: '\\R\\U\\B#,##0_);\\(\\R\\U\\B#,##0\\)' }, + { value: 'JPY', expected: '\\¥#,##0_);\\(\\¥#,##0\\)' }, + { value: 'KPW', expected: '\\K\\P\\W#,##0_);\\(\\K\\P\\W#,##0\\)' }, + { value: 'LBP', expected: '\\L\\B\\P#,##0_);\\(\\L\\B\\P#,##0\\)' }, + { value: 'SEK', expected: '\\S\\E\\K#,##0_);\\(\\S\\E\\K#,##0\\)' } + ]); + + ExcelJSLocalizationFormatTests.runPivotGridCurrencyTests([ + { value: 'USD', expected: '$#,##0_);\\($#,##0\\)' }, + { value: 'RUB', expected: '\\R\\U\\B#,##0_);\\(\\R\\U\\B#,##0\\)' }, + { value: 'JPY', expected: '\\¥#,##0_);\\(\\¥#,##0\\)' }, + { value: 'KPW', expected: '\\K\\P\\W#,##0_);\\(\\K\\P\\W#,##0\\)' }, + { value: 'LBP', expected: '\\L\\B\\P#,##0_);\\(\\L\\B\\P#,##0\\)' }, + { value: 'SEK', expected: '\\S\\E\\K#,##0_);\\(\\S\\E\\K#,##0\\)' } + ]); +}); - QUnit.test('getDecimalSeparator and getThousandsSeparator in RU locale', function(assert) { - Globalize.locale('ru'); - assert.equal(numberLocalization.getDecimalSeparator(), ','); - assert.equal(numberLocalization.getThousandsSeparator(), '\xa0'); - Globalize.locale('en'); +QUnit.module('Format helper', () => { + QUnit.module('Numeric and dateTime formats', { + beforeEach: function() { + this.testDate = new Date(2010, 2, 5, 12, 13, 33, 0); + } + }, () => { + QUnit.test('Currency numeric formats', function(assert) { + assert.equal(formatHelper.format(1204, 'currency'), '$1,204'); + assert.equal(formatHelper.format(1204, { type: 'cuRRency', precision: 2 }), '$1,204.00'); + assert.equal(formatHelper.format(-1204, { type: 'currency', precision: 2 }), '($1,204.00)'); }); - QUnit.test('getCurrencySymbol and config.defaultCurrency', function(assert) { - const originalDefaultCurrency = config().defaultCurrency; - - try { - assert.equal(numberLocalization.getCurrencySymbol().symbol, '$'); + QUnit.test('currency RUB large number format with different locales', function(assert) { + const currentCultureName = Globalize.locale().locale; - config({ - defaultCurrency: 'EUR' - }); + assert.equal(formatHelper.format(1.204, { type: 'currency', precision: 2, currency: 'RUB' }), 'RUB' + NBSP + '1.20'); - assert.equal(numberLocalization.getCurrencySymbol().symbol, '€'); + Globalize.locale('ru'); + try { + assert.equal(formatHelper.format(1.204, { type: 'currency', precision: 2, currency: 'RUB' }), '1,20' + NBSP + RUB); } finally { - config({ - defaultCurrency: originalDefaultCurrency - }); + Globalize.locale(currentCultureName); } }); - }); - - QUnit.module('Exceljs format', () => { - ExcelJSLocalizationFormatTests.runCurrencyTests([ - { value: 'USD', expected: '$#,##0_);\\($#,##0\\)' }, - { value: 'RUB', expected: '\\R\\U\\B#,##0_);\\(\\R\\U\\B#,##0\\)' }, - { value: 'JPY', expected: '\\¥#,##0_);\\(\\¥#,##0\\)' }, - { value: 'KPW', expected: '\\K\\P\\W#,##0_);\\(\\K\\P\\W#,##0\\)' }, - { value: 'LBP', expected: '\\L\\B\\P#,##0_);\\(\\L\\B\\P#,##0\\)' }, - { value: 'SEK', expected: '\\S\\E\\K#,##0_);\\(\\S\\E\\K#,##0\\)' } - ]); - - ExcelJSLocalizationFormatTests.runPivotGridCurrencyTests([ - { value: 'USD', expected: '$#,##0_);\\($#,##0\\)' }, - { value: 'RUB', expected: '\\R\\U\\B#,##0_);\\(\\R\\U\\B#,##0\\)' }, - { value: 'JPY', expected: '\\¥#,##0_);\\(\\¥#,##0\\)' }, - { value: 'KPW', expected: '\\K\\P\\W#,##0_);\\(\\K\\P\\W#,##0\\)' }, - { value: 'LBP', expected: '\\L\\B\\P#,##0_);\\(\\L\\B\\P#,##0\\)' }, - { value: 'SEK', expected: '\\S\\E\\K#,##0_);\\(\\S\\E\\K#,##0\\)' } - ]); - }); - - QUnit.module('Format helper', () => { - QUnit.module('Numeric and dateTime formats', { - beforeEach: function() { - this.testDate = new Date(2010, 2, 5, 12, 13, 33, 0); - } - }, () => { - QUnit.test('Currency numeric formats', function(assert) { - assert.equal(formatHelper.format(1204, 'currency'), '$1,204'); - assert.equal(formatHelper.format(1204, { type: 'cuRRency', precision: 2 }), '$1,204.00'); - assert.equal(formatHelper.format(-1204, { type: 'currency', precision: 2 }), '($1,204.00)'); - }); - QUnit.test('currency RUB large number format with different locales', function(assert) { - const currentCultureName = Globalize.locale().locale; - - assert.equal(formatHelper.format(1.204, { type: 'currency', precision: 2, currency: 'RUB' }), 'RUB' + NBSP + '1.20'); + QUnit.test('Fixed point numeric formats', function(assert) { + assert.equal(formatHelper.format(23.04059872, { type: 'fIxedPoint', precision: 4 }), '23.0406'); + }); - Globalize.locale('ru'); - try { - assert.equal(formatHelper.format(1.204, { type: 'currency', precision: 2, currency: 'RUB' }), '1,20' + NBSP + RUB); - } finally { - Globalize.locale(currentCultureName); - } - }); + QUnit.test('Percent numeric formats', function(assert) { + assert.equal(formatHelper.format(0.45, 'percEnt'), '45%'); + assert.equal(formatHelper.format(0.45, { type: 'peRcent', precision: 2 }), '45.00%'); + }); - QUnit.test('Fixed point numeric formats', function(assert) { - assert.equal(formatHelper.format(23.04059872, { type: 'fIxedPoint', precision: 4 }), '23.0406'); - }); + QUnit.test('Decimal numeric formats', function(assert) { + assert.equal(formatHelper.format(437, 'decimAl'), '437'); + assert.equal(formatHelper.format(437, { type: 'deCimal', precision: 5 }), '00437'); + }); - QUnit.test('Percent numeric formats', function(assert) { - assert.equal(formatHelper.format(0.45, 'percEnt'), '45%'); - assert.equal(formatHelper.format(0.45, { type: 'peRcent', precision: 2 }), '45.00%'); - }); + QUnit.test('Long date format', function(assert) { + assert.equal(formatHelper.format(this.testDate, 'LONGDate'), 'Friday, March 5, 2010'); + }); - QUnit.test('Decimal numeric formats', function(assert) { - assert.equal(formatHelper.format(437, 'decimAl'), '437'); - assert.equal(formatHelper.format(437, { type: 'deCimal', precision: 5 }), '00437'); - }); + QUnit.test('Long time format', function(assert) { + assert.equal(formatHelper.format(this.testDate, 'longTIME'), '12:13:33 PM'); + }); + QUnit.test('Month and day format', function(assert) { + assert.equal(formatHelper.format(this.testDate, 'monthAndDAY'), 'March 5'); + }); - QUnit.test('Long date format', function(assert) { - assert.equal(formatHelper.format(this.testDate, 'LONGDate'), 'Friday, March 5, 2010'); - }); + QUnit.test('Month and year format', function(assert) { + assert.equal(formatHelper.format(this.testDate, 'MONTHAndYear'), 'March 2010'); + }); - QUnit.test('Long time format', function(assert) { - assert.equal(formatHelper.format(this.testDate, 'longTIME'), '12:13:33 PM'); - }); - QUnit.test('Month and day format', function(assert) { - assert.equal(formatHelper.format(this.testDate, 'monthAndDAY'), 'March 5'); - }); + QUnit.test('Short date format', function(assert) { + assert.equal(formatHelper.format(this.testDate, 'shoRTDate'), '3/5/2010'); + }); - QUnit.test('Month and year format', function(assert) { - assert.equal(formatHelper.format(this.testDate, 'MONTHAndYear'), 'March 2010'); - }); + QUnit.test('Short time format', function(assert) { + assert.equal(formatHelper.format(this.testDate, 'shoRTTime'), '12:13 PM'); + }); - QUnit.test('Short date format', function(assert) { - assert.equal(formatHelper.format(this.testDate, 'shoRTDate'), '3/5/2010'); - }); + QUnit.test('Custom date time format', function(assert) { + assert.equal(formatHelper.format(this.testDate, 'dd MMM yy'), '05 Mar 10'); + }); - QUnit.test('Short time format', function(assert) { - assert.equal(formatHelper.format(this.testDate, 'shoRTTime'), '12:13 PM'); - }); + QUnit.test('LongDateLongTime', function(assert) { + assert.equal(formatHelper.format(this.testDate, 'LONGDATELongTime'), 'Friday, March 5, 2010, 12:13:33 PM'); + }); - QUnit.test('Custom date time format', function(assert) { - assert.equal(formatHelper.format(this.testDate, 'dd MMM yy'), '05 Mar 10'); - }); + QUnit.test('ShortDateShortTime', function(assert) { + assert.equal(formatHelper.format(this.testDate, 'shortDATESHORTTime'), '3/5/2010, 12:13 PM'); + }); - QUnit.test('LongDateLongTime', function(assert) { - assert.equal(formatHelper.format(this.testDate, 'LONGDATELongTime'), 'Friday, March 5, 2010, 12:13:33 PM'); - }); + QUnit.test('Invalid format parameters', function(assert) { + assert.equal(formatHelper.format('test', 'percent'), 'test'); + assert.equal(formatHelper.format(12, 12), 12); + }); - QUnit.test('ShortDateShortTime', function(assert) { - assert.equal(formatHelper.format(this.testDate, 'shortDATESHORTTime'), '3/5/2010, 12:13 PM'); - }); + QUnit.test('Quarter and year', function(assert) { + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'QUarterAndYear'), 'Q1 2005'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'dd MMM yy, Q'), '01 Jan 05, 1'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qq, dd MMM yy'), '01, 01 Jan 05'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'q, yy'), '1, 05'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qq, yy'), '01, 05'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'QQ, yyyy MM'), '01, 2005 01'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qqq, yyyy'), 'Q1, 2005'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qqqq, yyyy'), '1st quarter, 2005'); + }); - QUnit.test('Invalid format parameters', function(assert) { - assert.equal(formatHelper.format('test', 'percent'), 'test'); - assert.equal(formatHelper.format(12, 12), 12); - }); + // B218108 + QUnit.test('Custom quarter format', function(assert) { + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'q'), '1', 'quarter format - q'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'Q'), '1', 'quarter format - Q'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qq'), '01', 'quarter format - qq'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'QQ'), '01', 'quarter format - QQ'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qqq'), 'Q1', 'quarter format - qqq'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'QQQ'), 'Q1', 'quarter format - QQQ'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qqqq'), '1st quarter', 'quarter format - qqqq'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'QQQQ'), '1st quarter', 'quarter format - QQQQ'); + + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'q MMM QQ'), '1 Jan 01', 'quarter format - q MMM QQ'); + }); - QUnit.test('Quarter and year', function(assert) { - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'QUarterAndYear'), 'Q1 2005'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'dd MMM yy, Q'), '01 Jan 05, 1'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qq, dd MMM yy'), '01, 01 Jan 05'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'q, yy'), '1, 05'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qq, yy'), '01, 05'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'QQ, yyyy MM'), '01, 2005 01'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qqq, yyyy'), 'Q1, 2005'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qqqq, yyyy'), '1st quarter, 2005'); - }); + QUnit.test('Quarters for any months', function(assert) { + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'quartERAndYear'), 'Q1 2005'); + assert.equal(formatHelper.format(new Date(2005, 1, 1), 'quartERAndYear'), 'Q1 2005'); + assert.equal(formatHelper.format(new Date(2005, 2, 1), 'quartERAndYear'), 'Q1 2005'); - // B218108 - QUnit.test('Custom quarter format', function(assert) { - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'q'), '1', 'quarter format - q'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'Q'), '1', 'quarter format - Q'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qq'), '01', 'quarter format - qq'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'QQ'), '01', 'quarter format - QQ'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qqq'), 'Q1', 'quarter format - qqq'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'QQQ'), 'Q1', 'quarter format - QQQ'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'qqqq'), '1st quarter', 'quarter format - qqqq'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'QQQQ'), '1st quarter', 'quarter format - QQQQ'); - - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'q MMM QQ'), '1 Jan 01', 'quarter format - q MMM QQ'); - }); + assert.equal(formatHelper.format(new Date(2005, 3, 1), 'quarterANDYear'), 'Q2 2005'); + assert.equal(formatHelper.format(new Date(2005, 4, 1), 'quarterANDYear'), 'Q2 2005'); + assert.equal(formatHelper.format(new Date(2005, 5, 1), 'quarterANDYear'), 'Q2 2005'); - QUnit.test('Quarters for any months', function(assert) { - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'quartERAndYear'), 'Q1 2005'); - assert.equal(formatHelper.format(new Date(2005, 1, 1), 'quartERAndYear'), 'Q1 2005'); - assert.equal(formatHelper.format(new Date(2005, 2, 1), 'quartERAndYear'), 'Q1 2005'); + assert.equal(formatHelper.format(new Date(2005, 6, 1), 'qUARterAndYear'), 'Q3 2005'); + assert.equal(formatHelper.format(new Date(2005, 7, 1), 'qUARterAndYear'), 'Q3 2005'); + assert.equal(formatHelper.format(new Date(2005, 8, 1), 'qUARterAndYear'), 'Q3 2005'); - assert.equal(formatHelper.format(new Date(2005, 3, 1), 'quarterANDYear'), 'Q2 2005'); - assert.equal(formatHelper.format(new Date(2005, 4, 1), 'quarterANDYear'), 'Q2 2005'); - assert.equal(formatHelper.format(new Date(2005, 5, 1), 'quarterANDYear'), 'Q2 2005'); + assert.equal(formatHelper.format(new Date(2005, 9, 1), 'qUARterAndYear'), 'Q4 2005'); + assert.equal(formatHelper.format(new Date(2005, 10, 1), 'qUARterAndYear'), 'Q4 2005'); + assert.equal(formatHelper.format(new Date(2005, 11, 1), 'qUARterAndYear'), 'Q4 2005'); + }); - assert.equal(formatHelper.format(new Date(2005, 6, 1), 'qUARterAndYear'), 'Q3 2005'); - assert.equal(formatHelper.format(new Date(2005, 7, 1), 'qUARterAndYear'), 'Q3 2005'); - assert.equal(formatHelper.format(new Date(2005, 8, 1), 'qUARterAndYear'), 'Q3 2005'); + QUnit.test('Choose call format method by the value type', function(assert) { + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'loNGDate'), 'Saturday, January 1, 2005'); + assert.equal(formatHelper.format(new Date(2005, 0, 1), 'SHORTDate'), '1/1/2005'); + assert.equal(formatHelper.format(12.098, { type: 'fixEDPoint', precision: 2 }), '12.10'); + assert.equal(formatHelper.format(12.098, { type: 'cuRRency', precision: 1 }), '$12.1'); + assert.equal(formatHelper.format('InvalidValue'), 'InvalidValue'); + }); - assert.equal(formatHelper.format(new Date(2005, 9, 1), 'qUARterAndYear'), 'Q4 2005'); - assert.equal(formatHelper.format(new Date(2005, 10, 1), 'qUARterAndYear'), 'Q4 2005'); - assert.equal(formatHelper.format(new Date(2005, 11, 1), 'qUARterAndYear'), 'Q4 2005'); - }); + QUnit.test('Millisecond date time interval format', function(assert) { + assert.equal(formatHelper.format(new Date(2005, 0, 1, 10, 33, 20, 237), 'millisecond'), '237'); + assert.equal(formatHelper.format(new Date(2005, 0, 1, 10, 33, 20, 569), 'millisecond'), '569'); + }); - QUnit.test('Choose call format method by the value type', function(assert) { - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'loNGDate'), 'Saturday, January 1, 2005'); - assert.equal(formatHelper.format(new Date(2005, 0, 1), 'SHORTDate'), '1/1/2005'); - assert.equal(formatHelper.format(12.098, { type: 'fixEDPoint', precision: 2 }), '12.10'); - assert.equal(formatHelper.format(12.098, { type: 'cuRRency', precision: 1 }), '$12.1'); - assert.equal(formatHelper.format('InvalidValue'), 'InvalidValue'); - }); + QUnit.test('Day date time interval format', function(assert) { + assert.equal(formatHelper.format(new Date(2005, 0, 16, 10, 33, 20, 237), 'day'), '16'); + assert.equal(formatHelper.format(new Date(2005, 0, 30, 19, 23, 56, 237), 'day'), '30'); + }); - QUnit.test('Millisecond date time interval format', function(assert) { - assert.equal(formatHelper.format(new Date(2005, 0, 1, 10, 33, 20, 237), 'millisecond'), '237'); - assert.equal(formatHelper.format(new Date(2005, 0, 1, 10, 33, 20, 569), 'millisecond'), '569'); - }); + QUnit.test('Month date time interval format', function(assert) { + assert.equal(formatHelper.format(new Date(2005, 0, 16, 10, 33, 20, 237), 'month'), 'January'); + assert.equal(formatHelper.format(new Date(2005, 9, 27, 19, 23, 56, 237), 'month'), 'October'); + }); - QUnit.test('Day date time interval format', function(assert) { - assert.equal(formatHelper.format(new Date(2005, 0, 16, 10, 33, 20, 237), 'day'), '16'); - assert.equal(formatHelper.format(new Date(2005, 0, 30, 19, 23, 56, 237), 'day'), '30'); - }); + QUnit.test('Quarter date time interval format', function(assert) { + assert.equal(formatHelper.format(new Date(2005, 0, 16, 10, 33, 20, 237), 'quarter'), 'Q1'); + assert.equal(formatHelper.format(new Date(2005, 9, 27, 19, 23, 56, 237), 'quarter'), 'Q4'); + }); - QUnit.test('Month date time interval format', function(assert) { - assert.equal(formatHelper.format(new Date(2005, 0, 16, 10, 33, 20, 237), 'month'), 'January'); - assert.equal(formatHelper.format(new Date(2005, 9, 27, 19, 23, 56, 237), 'month'), 'October'); - }); + QUnit.test('Year date time interval format', function(assert) { + assert.equal(formatHelper.format(new Date(2005, 0, 16, 10, 33, 20, 237), 'year'), '2005'); + assert.equal(formatHelper.format(new Date(2009, 9, 27, 19, 23, 56, 237), 'year'), '2009'); + }); - QUnit.test('Quarter date time interval format', function(assert) { - assert.equal(formatHelper.format(new Date(2005, 0, 16, 10, 33, 20, 237), 'quarter'), 'Q1'); - assert.equal(formatHelper.format(new Date(2005, 9, 27, 19, 23, 56, 237), 'quarter'), 'Q4'); - }); + QUnit.test('Short Year date time interval format', function(assert) { + assert.equal(formatHelper.format(new Date(2005, 0, 16, 10, 33, 20, 237), 'shortyear'), '05'); + assert.equal(formatHelper.format(new Date(2009, 9, 27, 19, 23, 56, 237), 'shortyear'), '09'); + }); - QUnit.test('Year date time interval format', function(assert) { - assert.equal(formatHelper.format(new Date(2005, 0, 16, 10, 33, 20, 237), 'year'), '2005'); - assert.equal(formatHelper.format(new Date(2009, 9, 27, 19, 23, 56, 237), 'year'), '2009'); - }); + // This condition is added because of Safari bug 15434904 + if(!isIosWithMSKTimeZone()) { + QUnit.test('getDateMarkerFormat for second range', function(assert) { + const date1 = new Date(2010, 0, 1, 2, 23, 33); + const date2 = new Date(date1.getTime()); - QUnit.test('Short Year date time interval format', function(assert) { - assert.equal(formatHelper.format(new Date(2005, 0, 16, 10, 33, 20, 237), 'shortyear'), '05'); - assert.equal(formatHelper.format(new Date(2009, 9, 27, 19, 23, 56, 237), 'shortyear'), '09'); + date2.setMilliseconds(3000); + const format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); + assert.equal(formatHelper.format(date2, format), '2:23:36 AM'); }); - // This condition is added because of Safari bug 15434904 - if(!isIosWithMSKTimeZone()) { - QUnit.test('getDateMarkerFormat for second range', function(assert) { - const date1 = new Date(2010, 0, 1, 2, 23, 33); - const date2 = new Date(date1.getTime()); - - date2.setMilliseconds(3000); - const format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); - assert.equal(formatHelper.format(date2, format), '2:23:36 AM'); - }); - - QUnit.test('getDateMarkerFormat for minute range', function(assert) { - const date1 = new Date(2010, 0, 1, 2, 23, 33, 990); - let date2 = new Date(date1.getTime()); - let format; - - date2.setSeconds(63); - format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); - assert.equal(formatHelper.format(date2, format), '2:24:03 AM'); - - date2 = new Date(date1.getTime()); - date2.setMinutes(25); - format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); - assert.equal(formatHelper.format(date2, format), '2:25 AM'); - }); - - QUnit.test('getDateMarkerFormat for hour range', function(assert) { - const date1 = new Date(2010, 0, 1, 2, 23, 33, 990); - let date2 = new Date(date1.getTime()); - let format; - - date2.setSeconds(30000); - format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); - assert.equal(formatHelper.format(date2, format), '10:43:00 AM'); - - date2 = new Date(date1.getTime()); - date2.setHours(4); - format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); - assert.equal(formatHelper.format(date2, format), '4:23 AM'); - }); - } - - QUnit.test('getDateMarkerFormat for day range', function(assert) { - const date1 = new Date(2010, 0, 29, 12, 23, 33, 990); + QUnit.test('getDateMarkerFormat for minute range', function(assert) { + const date1 = new Date(2010, 0, 1, 2, 23, 33, 990); let date2 = new Date(date1.getTime()); let format; - // day and time - date2 = new Date(date1.getTime()); - date2.setMinutes(1000); + date2.setSeconds(63); format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); - assert.equal(formatHelper.format(date2, format), 'Saturday, 30 4:40 AM'); + assert.equal(formatHelper.format(date2, format), '2:24:03 AM'); - // day date2 = new Date(date1.getTime()); - date2.setDate(30); + date2.setMinutes(25); format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); - assert.equal(formatHelper.format(date2, format), 'Saturday, 30'); + assert.equal(formatHelper.format(date2, format), '2:25 AM'); }); - QUnit.test('getDateMarkerFormat for month range', function(assert) { - const date1 = new Date(2010, 10, 29, 12, 23, 33, 990); + QUnit.test('getDateMarkerFormat for hour range', function(assert) { + const date1 = new Date(2010, 0, 1, 2, 23, 33, 990); let date2 = new Date(date1.getTime()); let format; - // month, day and time - date2.setHours(74); - format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); - assert.equal(formatHelper.format(date2, format), 'December 2 2:23 AM'); - - // year, month, day and time - date2 = new Date(date1.getTime()); - date2.setFullYear(2011); - date2.setMonth(11); - date2.setHours(74); - format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); - assert.equal(formatHelper.format(date2, format), '1/1/2012 2:23 AM'); - - // month and day - date2 = new Date(date1.getTime()); - date2.setDate(32); + date2.setSeconds(30000); format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); - assert.equal(formatHelper.format(date2, format), 'December 2'); + assert.equal(formatHelper.format(date2, format), '10:43:00 AM'); - // month date2 = new Date(date1.getTime()); - date2.setMonth(11); + date2.setHours(4); format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); - assert.equal(formatHelper.format(date2, format), 'December'); + assert.equal(formatHelper.format(date2, format), '4:23 AM'); }); + } - QUnit.test('getDateMarkerFormat for year range', function(assert) { - const date1 = new Date(2010, 10, 29, 12, 23, 33, 990); - const date2 = new Date(date1.getTime()); + QUnit.test('getDateMarkerFormat for day range', function(assert) { + const date1 = new Date(2010, 0, 29, 12, 23, 33, 990); + let date2 = new Date(date1.getTime()); + let format; + + // day and time + date2 = new Date(date1.getTime()); + date2.setMinutes(1000); + format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); + assert.equal(formatHelper.format(date2, format), 'Saturday, 30 4:40 AM'); + + // day + date2 = new Date(date1.getTime()); + date2.setDate(30); + format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); + assert.equal(formatHelper.format(date2, format), 'Saturday, 30'); + }); - // year - date2.setFullYear(2031); - const format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); - assert.equal(formatHelper.format(date2, format), '2031'); - }); + QUnit.test('getDateMarkerFormat for month range', function(assert) { + const date1 = new Date(2010, 10, 29, 12, 23, 33, 990); + let date2 = new Date(date1.getTime()); + let format; + + // month, day and time + date2.setHours(74); + format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); + assert.equal(formatHelper.format(date2, format), 'December 2 2:23 AM'); + + // year, month, day and time + date2 = new Date(date1.getTime()); + date2.setFullYear(2011); + date2.setMonth(11); + date2.setHours(74); + format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); + assert.equal(formatHelper.format(date2, format), '1/1/2012 2:23 AM'); + + // month and day + date2 = new Date(date1.getTime()); + date2.setDate(32); + format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); + assert.equal(formatHelper.format(date2, format), 'December 2'); + + // month + date2 = new Date(date1.getTime()); + date2.setMonth(11); + format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); + assert.equal(formatHelper.format(date2, format), 'December'); + }); - // B217749 - QUnit.test('value is null or undefined', function(assert) { - assert.strictEqual(formatHelper.format(null, ''), ''); - assert.strictEqual(formatHelper.format(undefined, ''), ''); - assert.strictEqual(formatHelper.format('test', ''), 'test'); - }); + QUnit.test('getDateMarkerFormat for year range', function(assert) { + const date1 = new Date(2010, 10, 29, 12, 23, 33, 990); + const date2 = new Date(date1.getTime()); - QUnit.test('large number auto format negative numbers', function(assert) { - assert.strictEqual(formatHelper.format(-123, 'fixedPoint largeNumber'), '-123'); - assert.strictEqual(formatHelper.format(-1230, 'fixedPoint largeNumber'), '-1K'); - assert.strictEqual(formatHelper.format(-12300000, 'fixedPoint largeNumber'), '-12M'); - }); + // year + date2.setFullYear(2031); + const format = formatHelper.getDateFormatByDifferences(dateUtils.getDatesDifferences(date1, date2)); + assert.equal(formatHelper.format(date2, format), '2031'); + }); - QUnit.test('large number auto format precision', function(assert) { - assert.strictEqual(formatHelper.format(0.01, 'fixedPoint LARGENumber'), '0'); - assert.strictEqual(formatHelper.format(10.23, 'fixedPoint largeNumber'), '10'); - assert.strictEqual(formatHelper.format(123, { type: 'fixedPoint largeNumber', precision: 1 }), '123.0'); - assert.strictEqual(formatHelper.format(12345, { type: 'fixedPoint largeNUMBER', precision: 2 }), '12.35K'); - assert.strictEqual(formatHelper.format(12345, { type: 'fixedPoint largeNumber', precision: 5 }), '12.34500K'); - }); + // B217749 + QUnit.test('value is null or undefined', function(assert) { + assert.strictEqual(formatHelper.format(null, ''), ''); + assert.strictEqual(formatHelper.format(undefined, ''), ''); + assert.strictEqual(formatHelper.format('test', ''), 'test'); + }); - QUnit.test('large number auto format small numbers', function(assert) { - assert.strictEqual(formatHelper.format(0.01, { type: 'fixedPoint largeNumber', precision: 2 }), '0.01'); - assert.strictEqual(formatHelper.format(999, { type: 'fixedPoint largeNumber', precision: 2 }), '999.00'); - assert.strictEqual(formatHelper.format(999.9, { type: 'fixedPoint largeNumber', precision: 0 }), '1,000'); - assert.strictEqual(formatHelper.format(1000, { type: 'fixedPoint largeNumber', precision: 0 }), '1K'); - }); + QUnit.test('large number auto format negative numbers', function(assert) { + assert.strictEqual(formatHelper.format(-123, 'fixedPoint largeNumber'), '-123'); + assert.strictEqual(formatHelper.format(-1230, 'fixedPoint largeNumber'), '-1K'); + assert.strictEqual(formatHelper.format(-12300000, 'fixedPoint largeNumber'), '-12M'); + }); - QUnit.test('large number auto format powers', function(assert) { - assert.strictEqual(formatHelper.format(1234.56, { type: 'fixedPoint largeNumber', precision: 2 }), '1.23K'); - assert.strictEqual(formatHelper.format(12345.67, { type: 'fixedPoint largeNumber', precision: 2 }), '12.35K'); - assert.strictEqual(formatHelper.format(123400000, { type: 'fixedPoint largeNumber', precision: 2 }), '123.40M'); - assert.strictEqual(formatHelper.format(1234000000, { type: 'fixedPoint largeNumber', precision: 2 }), '1.23B'); - assert.strictEqual(formatHelper.format(12340000000000, { type: 'fixedPoint largeNumber', precision: 2 }), '12.34T'); - assert.strictEqual(formatHelper.format(12340000000000000, { type: 'fixedPoint largeNumber', precision: 2 }), '12,340.00T'); - }); + QUnit.test('large number auto format precision', function(assert) { + assert.strictEqual(formatHelper.format(0.01, 'fixedPoint LARGENumber'), '0'); + assert.strictEqual(formatHelper.format(10.23, 'fixedPoint largeNumber'), '10'); + assert.strictEqual(formatHelper.format(123, { type: 'fixedPoint largeNumber', precision: 1 }), '123.0'); + assert.strictEqual(formatHelper.format(12345, { type: 'fixedPoint largeNUMBER', precision: 2 }), '12.35K'); + assert.strictEqual(formatHelper.format(12345, { type: 'fixedPoint largeNumber', precision: 5 }), '12.34500K'); + }); - QUnit.test('large number format powers', function(assert) { - assert.strictEqual(formatHelper.format(12345.67, { type: 'fixedPoint', precision: 2 }), '12,345.67'); - assert.strictEqual(formatHelper.format(12345.67, { type: 'fixedPoint largeNumber', precision: 2 }), '12.35K'); - assert.strictEqual(formatHelper.format(12345.67, { type: 'fixedPoint thousands', precision: 2 }), '12.35K'); - assert.strictEqual(formatHelper.format(12345.67, { type: 'fixedPoint miLLions', precision: 3 }), '0.012M'); - assert.strictEqual(formatHelper.format(12345.67, { type: 'fixedPoint biLLions', precision: 7 }), '0.0000123B'); - assert.strictEqual(formatHelper.format(12345670, { type: 'fixedPoint triLLions', precision: 7 }), '0.0000123T'); - }); + QUnit.test('large number auto format small numbers', function(assert) { + assert.strictEqual(formatHelper.format(0.01, { type: 'fixedPoint largeNumber', precision: 2 }), '0.01'); + assert.strictEqual(formatHelper.format(999, { type: 'fixedPoint largeNumber', precision: 2 }), '999.00'); + assert.strictEqual(formatHelper.format(999.9, { type: 'fixedPoint largeNumber', precision: 0 }), '1,000'); + assert.strictEqual(formatHelper.format(1000, { type: 'fixedPoint largeNumber', precision: 0 }), '1K'); + }); - QUnit.test('currency large number format', function(assert) { - assert.strictEqual(formatHelper.format(12345.67, { type: 'currency largeNumber', precision: 2 }), '$12.35K'); - assert.strictEqual(formatHelper.format(12345.67, { type: 'currency thoUSands', precision: 2 }), '$12.35K'); - assert.strictEqual(formatHelper.format(12345.67, { type: 'currency miLLions', precision: 3 }), '$0.012M'); - }); + QUnit.test('large number auto format powers', function(assert) { + assert.strictEqual(formatHelper.format(1234.56, { type: 'fixedPoint largeNumber', precision: 2 }), '1.23K'); + assert.strictEqual(formatHelper.format(12345.67, { type: 'fixedPoint largeNumber', precision: 2 }), '12.35K'); + assert.strictEqual(formatHelper.format(123400000, { type: 'fixedPoint largeNumber', precision: 2 }), '123.40M'); + assert.strictEqual(formatHelper.format(1234000000, { type: 'fixedPoint largeNumber', precision: 2 }), '1.23B'); + assert.strictEqual(formatHelper.format(12340000000000, { type: 'fixedPoint largeNumber', precision: 2 }), '12.34T'); + assert.strictEqual(formatHelper.format(12340000000000000, { type: 'fixedPoint largeNumber', precision: 2 }), '12,340.00T'); + }); - QUnit.test('large number format without number type', function(assert) { - assert.strictEqual(formatHelper.format(12345.67, { type: 'largeNumber', precision: 2 }), '12.35K'); - assert.strictEqual(formatHelper.format(12345.67, { type: 'thousands', precision: 2 }), '12.35K'); - assert.strictEqual(formatHelper.format(12345.67, { type: 'millions', precision: 3 }), '0.012M'); - }); + QUnit.test('large number format powers', function(assert) { + assert.strictEqual(formatHelper.format(12345.67, { type: 'fixedPoint', precision: 2 }), '12,345.67'); + assert.strictEqual(formatHelper.format(12345.67, { type: 'fixedPoint largeNumber', precision: 2 }), '12.35K'); + assert.strictEqual(formatHelper.format(12345.67, { type: 'fixedPoint thousands', precision: 2 }), '12.35K'); + assert.strictEqual(formatHelper.format(12345.67, { type: 'fixedPoint miLLions', precision: 3 }), '0.012M'); + assert.strictEqual(formatHelper.format(12345.67, { type: 'fixedPoint biLLions', precision: 7 }), '0.0000123B'); + assert.strictEqual(formatHelper.format(12345670, { type: 'fixedPoint triLLions', precision: 7 }), '0.0000123T'); + }); - QUnit.test('Empty format for number', function(assert) { - assert.equal(formatHelper.format(1204, ''), '1204'); - assert.equal(formatHelper.format(12.04, ''), '12.04'); - }); + QUnit.test('currency large number format', function(assert) { + assert.strictEqual(formatHelper.format(12345.67, { type: 'currency largeNumber', precision: 2 }), '$12.35K'); + assert.strictEqual(formatHelper.format(12345.67, { type: 'currency thoUSands', precision: 2 }), '$12.35K'); + assert.strictEqual(formatHelper.format(12345.67, { type: 'currency miLLions', precision: 3 }), '$0.012M'); + }); - QUnit.test('exponential number type pow', function(assert) { - assert.strictEqual(formatHelper.format(5, { type: 'exponEntial', precision: 2 }), '5.00E+0'); - assert.strictEqual(formatHelper.format(0.0081, { type: 'exponential', precision: 2 }), '8.10E-3'); - assert.strictEqual(formatHelper.format(-12345.67, { type: 'exponential', precision: 2 }), '-1.23E+4'); - assert.strictEqual(formatHelper.format(500000001, { type: 'exponential', precision: 2 }), '5.00E+8'); - assert.strictEqual(formatHelper.format(1.56662165464E+99, { type: 'exponential', precision: 2 }), '1.57E+99'); - assert.strictEqual(formatHelper.format(1.56662165464E-99, { type: 'exponential', precision: 2 }), '1.57E-99'); - }); + QUnit.test('large number format without number type', function(assert) { + assert.strictEqual(formatHelper.format(12345.67, { type: 'largeNumber', precision: 2 }), '12.35K'); + assert.strictEqual(formatHelper.format(12345.67, { type: 'thousands', precision: 2 }), '12.35K'); + assert.strictEqual(formatHelper.format(12345.67, { type: 'millions', precision: 3 }), '0.012M'); + }); - QUnit.test('exponential number type precision', function(assert) { - assert.strictEqual(formatHelper.format(1234, 'exponential'), '1.2E+3'); - assert.strictEqual(formatHelper.format(5, { type: 'exponential', precision: 0 }), '5E+0'); - assert.strictEqual(formatHelper.format(0.0081, { type: 'exponential', precision: 1 }), '8.1E-3'); - assert.strictEqual(formatHelper.format(-12345.67, { type: 'exponential', precision: 2 }), '-1.23E+4'); - assert.strictEqual(formatHelper.format(500000001, { type: 'exponential', precision: 3 }), '5.000E+8'); - assert.strictEqual(formatHelper.format(-123456789, { type: 'exponential', precision: 8 }), '-1.23456789E+8'); - }); + QUnit.test('Empty format for number', function(assert) { + assert.equal(formatHelper.format(1204, ''), '1204'); + assert.equal(formatHelper.format(12.04, ''), '12.04'); + }); - QUnit.test('exponential number type round', function(assert) { - assert.strictEqual(formatHelper.format(0.00999, { type: 'exponential', precision: 0 }), '1E-2'); - assert.strictEqual(formatHelper.format(0.00999, { type: 'exponential', precision: 2 }), '9.99E-3'); - assert.strictEqual(formatHelper.format(999, { type: 'exponential', precision: 1 }), '1.0E+3'); - }); + QUnit.test('exponential number type pow', function(assert) { + assert.strictEqual(formatHelper.format(5, { type: 'exponEntial', precision: 2 }), '5.00E+0'); + assert.strictEqual(formatHelper.format(0.0081, { type: 'exponential', precision: 2 }), '8.10E-3'); + assert.strictEqual(formatHelper.format(-12345.67, { type: 'exponential', precision: 2 }), '-1.23E+4'); + assert.strictEqual(formatHelper.format(500000001, { type: 'exponential', precision: 2 }), '5.00E+8'); + assert.strictEqual(formatHelper.format(1.56662165464E+99, { type: 'exponential', precision: 2 }), '1.57E+99'); + assert.strictEqual(formatHelper.format(1.56662165464E-99, { type: 'exponential', precision: 2 }), '1.57E-99'); + }); + QUnit.test('exponential number type precision', function(assert) { + assert.strictEqual(formatHelper.format(1234, 'exponential'), '1.2E+3'); + assert.strictEqual(formatHelper.format(5, { type: 'exponential', precision: 0 }), '5E+0'); + assert.strictEqual(formatHelper.format(0.0081, { type: 'exponential', precision: 1 }), '8.1E-3'); + assert.strictEqual(formatHelper.format(-12345.67, { type: 'exponential', precision: 2 }), '-1.23E+4'); + assert.strictEqual(formatHelper.format(500000001, { type: 'exponential', precision: 3 }), '5.000E+8'); + assert.strictEqual(formatHelper.format(-123456789, { type: 'exponential', precision: 8 }), '-1.23456789E+8'); + }); + + QUnit.test('exponential number type round', function(assert) { + assert.strictEqual(formatHelper.format(0.00999, { type: 'exponential', precision: 0 }), '1E-2'); + assert.strictEqual(formatHelper.format(0.00999, { type: 'exponential', precision: 2 }), '9.99E-3'); + assert.strictEqual(formatHelper.format(999, { type: 'exponential', precision: 1 }), '1.0E+3'); + }); - QUnit.test('exponential number type positive and negative number', function(assert) { - assert.strictEqual(formatHelper.format(0, { type: 'exponential', precision: 2 }), '0.00E+0'); - assert.strictEqual(formatHelper.format(1234, { type: 'exponential', precision: 2 }), '1.23E+3'); - assert.strictEqual(formatHelper.format(-1234, { type: 'exponential', precision: 2 }), '-1.23E+3'); - }); + QUnit.test('exponential number type positive and negative number', function(assert) { + assert.strictEqual(formatHelper.format(0, { type: 'exponential', precision: 2 }), '0.00E+0'); + assert.strictEqual(formatHelper.format(1234, { type: 'exponential', precision: 2 }), '1.23E+3'); + assert.strictEqual(formatHelper.format(-1234, { type: 'exponential', precision: 2 }), '-1.23E+3'); }); - QUnit.module('formatNumberEx', () => { - QUnit.test('not execute formatNumberEx for non-number value', function(assert) { - assert.equal(formatHelper.format('test string', { format: 'currency' }), 'test string'); - }); + }); - QUnit.test('not execute formatNumberEx for infinite value', function(assert) { - assert.equal(formatHelper.format(Infinity, { format: 'fixedPoint' }), Infinity.toString()); - assert.equal(formatHelper.format(-Infinity, { format: 'fixedPoint' }), (-Infinity).toString()); - }); + QUnit.module('formatNumberEx', () => { + QUnit.test('not execute formatNumberEx for non-number value', function(assert) { + assert.equal(formatHelper.format('test string', { format: 'currency' }), 'test string'); + }); - QUnit.test('not execute formatNumberEx for NaN value', function(assert) { - assert.equal(formatHelper.format(NaN, { format: 'fixedPoint' }), NaN.toString()); - }); + QUnit.test('not execute formatNumberEx for infinite value', function(assert) { + assert.equal(formatHelper.format(Infinity, { format: 'fixedPoint' }), Infinity.toString()); + assert.equal(formatHelper.format(-Infinity, { format: 'fixedPoint' }), (-Infinity).toString()); + }); - QUnit.test('Case insensitive currency', function(assert) { - assert.equal(formatHelper.format(1204, 'currency'), '$1,204'); - assert.equal(formatHelper.format(1204, { type: 'cuRrency', precision: 2 }), '$1,204.00'); - }); + QUnit.test('not execute formatNumberEx for NaN value', function(assert) { + assert.equal(formatHelper.format(NaN, { format: 'fixedPoint' }), NaN.toString()); + }); - QUnit.test('not execute formatNumberEx for string w with set format', function(assert) { - /* eslint-disable no-extend-native */ + QUnit.test('Case insensitive currency', function(assert) { + assert.equal(formatHelper.format(1204, 'currency'), '$1,204'); + assert.equal(formatHelper.format(1204, { type: 'cuRrency', precision: 2 }), '$1,204.00'); + }); - String.prototype.format = noop; + QUnit.test('not execute formatNumberEx for string w with set format', function(assert) { + /* eslint-disable no-extend-native */ - assert.equal(formatHelper.format(123, 'currency'), '$123'); + String.prototype.format = noop; - // cleanup - delete String.prototype.format; - }); + assert.equal(formatHelper.format(123, 'currency'), '$123'); + + // cleanup + delete String.prototype.format; }); }); }); diff --git a/packages/devextreme/testing/tests/DevExpress.localization/localization.globalize.widgets.tests.js b/packages/devextreme/testing/tests/DevExpress.localization/localization.globalize.widgets.tests.js index 29056fc61eed..d0488ddaab72 100644 --- a/packages/devextreme/testing/tests/DevExpress.localization/localization.globalize.widgets.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.localization/localization.globalize.widgets.tests.js @@ -1,13 +1,27 @@ -const likelySubtags = require('cldr-core/supplemental/likelySubtags.json!'); -const numberingSystems = require('cldr-core/supplemental/numberingSystems.json!'); -const Globalize = require('globalize'); +import likelySubtags from 'cldr-core/supplemental/likelySubtags.json!'; +import numberingSystems from 'cldr-core/supplemental/numberingSystems.json!'; +import Globalize from 'globalize'; -const cldrData = [ - require('devextreme-cldr-data/fa.json!json'), - require('devextreme-cldr-data/mr.json!json'), - require('devextreme-cldr-data/ar.json!json'), - require('devextreme-cldr-data/de.json!json'), -]; +import fa from 'devextreme-cldr-data/fa.json!json'; +import mr from 'devextreme-cldr-data/mr.json!json'; +import ar from 'devextreme-cldr-data/ar.json!json'; +import de from 'devextreme-cldr-data/de.json!json'; + +import 'common/core/localization/globalize/core'; +import 'common/core/localization/globalize/number'; +import 'common/core/localization/globalize/currency'; +import 'common/core/localization/globalize/date'; +import 'common/core/localization/globalize/message'; + +import $ from 'jquery'; +import dateLocalization from 'common/core/localization/date'; + +import 'ui/date_box'; +import 'viz/chart'; + +import * as ExcelExport from '__internal/exporter/exceljs/export_format'; + +const cldrData = [fa, mr, ar, de]; Globalize.load(likelySubtags); Globalize.load(numberingSystems); @@ -16,20 +30,6 @@ cldrData.forEach(localeCldrData => { Globalize.load(localeCldrData); }); -require('common/core/localization/globalize/core'); -require('common/core/localization/globalize/number'); -require('common/core/localization/globalize/currency'); -require('common/core/localization/globalize/date'); -require('common/core/localization/globalize/message'); - -const $ = require('jquery'); -const dateLocalization = require('common/core/localization/date'); - -require('ui/date_box'); -require('viz/chart'); - -const ExcelExport = require('__internal/exporter/exceljs/export_format'); - const TEXTEDITOR_INPUT_SELECTOR = '.dx-texteditor-input'; const DATEVIEW_ITEM_SELECTOR = '.dx-dateview-item'; const DATEVIEW_ROLLER_DAY_SELECTOR = '.dx-dateviewroller-day'; diff --git a/packages/devextreme/testing/tests/DevExpress.localization/localization.messages.test.js b/packages/devextreme/testing/tests/DevExpress.localization/localization.messages.test.js index 6f4570399b3b..12845c890d5a 100644 --- a/packages/devextreme/testing/tests/DevExpress.localization/localization.messages.test.js +++ b/packages/devextreme/testing/tests/DevExpress.localization/localization.messages.test.js @@ -1,18 +1,18 @@ -const localization = require('localization'); -const dictionaries = {}; - -dictionaries['zh-tw'] = require('localization/messages/zh-tw.json!'); +import { loadMessages, locale, formatMessage } from 'localization'; +// eslint-disable-next-line spellcheck/spell-checker +import zhTwMessages from 'localization/messages/zh-tw.json!'; QUnit.module('Locale messages of DevExtreme', { }, () => { QUnit.test('test zh-TW locale format message', function(assert) { try { - localization.loadMessages(dictionaries['zh-tw']); - localization.locale('zh-TW'); - assert.equal(localization.formatMessage('Yes'), '是'); + // eslint-disable-next-line spellcheck/spell-checker + loadMessages(zhTwMessages); + locale('zh-TW'); + assert.equal(formatMessage('Yes'), '是'); } finally { - localization.locale('en'); + locale('en'); } }); }); diff --git a/packages/devextreme/testing/tests/DevExpress.localization/validation.tests.js b/packages/devextreme/testing/tests/DevExpress.localization/validation.tests.js index 623796d1dd67..4b12138141f5 100644 --- a/packages/devextreme/testing/tests/DevExpress.localization/validation.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.localization/validation.tests.js @@ -1,22 +1,22 @@ -require('common/core/localization/globalize/core'); -require('common/core/localization/globalize/number'); -require('common/core/localization/globalize/currency'); -require('common/core/localization/globalize/date'); -require('common/core/localization/globalize/message'); -const cldrData = [ - require('devextreme-cldr-data/fr.json!json') -]; +import 'common/core/localization/globalize/core'; +import 'common/core/localization/globalize/number'; +import 'common/core/localization/globalize/currency'; +import 'common/core/localization/globalize/date'; +import 'common/core/localization/globalize/message'; -const ValidationEngine = require('ui/validation_engine'); -const Globalize = require('globalize'); -const localization = require('localization'); -const fr = require('localization/messages/fr.json!'); +import ValidationEngine from 'ui/validation_engine'; +import Globalize from 'globalize'; +import { loadMessages } from 'localization'; +import fr from 'localization/messages/fr.json!'; +import frCldr from 'devextreme-cldr-data/fr.json!json'; + +const cldrData = [frCldr]; cldrData.forEach(localeCldrData => { Globalize.load(localeCldrData); }); -localization.loadMessages(fr); +loadMessages(fr); QUnit.module('culture-specific validation', { beforeEach: function() { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dropDownBox.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dropDownBox.tests.js index c0b2ad29a24d..3c4059e5a0f7 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dropDownBox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dropDownBox.tests.js @@ -3,7 +3,7 @@ import renderer from 'core/renderer'; import keyboardMock from '../../helpers/keyboardMock.js'; import fx from 'common/core/animation/fx'; import DropDownBox from 'ui/drop_down_box'; -import typeUtils, { isRenderer } from 'core/utils/type'; +import { isRenderer, isFunction } from 'core/utils/type'; import config from 'core/config'; import devices from '__internal/core/m_devices'; import { normalizeKeyName } from 'common/core/events/utils/index'; @@ -789,7 +789,7 @@ QUnit.module('popup options', moduleConfig, () => { contentTemplate: () => $content }); - assert.ok(typeUtils.isFunction(instance.option('dropDownOptions.hideOnParentScroll'))); + assert.ok(isFunction(instance.option('dropDownOptions.hideOnParentScroll'))); }); [true, false].forEach((isMac) => { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditor.missingModules.tests.part1.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditor.missingModules.tests.part1.js index d61a6192935d..13cf0441b0c7 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditor.missingModules.tests.part1.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditor.missingModules.tests.part1.js @@ -1,2 +1,2 @@ -require('../../helpers/ignoreQuillTimers.js'); -require('./htmlEditorParts/importQuill.tests.js'); +import '../../helpers/ignoreQuillTimers.js'; +import './htmlEditorParts/importQuill.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditor.missingModules.tests.part2.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditor.missingModules.tests.part2.js index 339dd30efcf3..52f2e5017af0 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditor.missingModules.tests.part2.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditor.missingModules.tests.part2.js @@ -1 +1 @@ -require('../../helpers/ignoreQuillTimers.js'); +import '../../helpers/ignoreQuillTimers.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/editing.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/editing.tests.js index e2125aa08ba8..a42f81dc26e5 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/editing.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/editing.tests.js @@ -1,12 +1,12 @@ -const $ = require('jquery'); -const devices = require('core/devices'); -const fx = require('common/core/animation/fx'); -const keyboardMock = require('../../helpers/keyboardMock.js'); -const { createWrapper } = require('../../helpers/scheduler/helpers.js'); -const { waitAsync } = require('../../helpers/scheduler/waitForAsync.js'); - -require('__internal/scheduler/scheduler'); -require('ui/drop_down_button'); +import $ from 'jquery'; +import devices from 'core/devices'; +import fx from 'common/core/animation/fx'; +import keyboardMock from '../../helpers/keyboardMock.js'; +import { createWrapper } from '../../helpers/scheduler/helpers.js'; +import { waitAsync } from '../../helpers/scheduler/waitForAsync.js'; + +import '__internal/scheduler/scheduler'; +import 'ui/drop_down_button'; QUnit.testStart(function() { $('#qunit-fixture').html('
'); diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.base.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.base.tests.js index 344a1ac27a97..81f0ba81e33c 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.base.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.base.tests.js @@ -1,7 +1,16 @@ -const { getOuterHeight } = require('core/utils/size'); -const $ = require('jquery'); -const { createWrapper } = require('../../helpers/scheduler/helpers.js'); -const { waitAsync } = require('../../helpers/scheduler/waitForAsync.js'); +import { getOuterHeight } from 'core/utils/size'; +import $ from 'jquery'; +import { createWrapper } from '../../helpers/scheduler/helpers.js'; +import { waitAsync } from '../../helpers/scheduler/waitForAsync.js'; + +import 'fluent_blue_light.css!'; + +import { noop } from 'core/utils/common'; +import errors from 'ui/widget/ui.errors'; +import config from 'core/config'; + +import '__internal/scheduler/scheduler'; +import 'ui/drop_down_button'; QUnit.testStart(function() { $('#qunit-fixture').html( @@ -10,15 +19,6 @@ QUnit.testStart(function() {
'); }); -require('fluent_blue_light.css!'); - -const noop = require('core/utils/common').noop; -const errors = require('ui/widget/ui.errors'); -const config = require('core/config'); - -require('__internal/scheduler/scheduler'); -require('ui/drop_down_button'); - QUnit.module('Integration: Base', { beforeEach: function() { this.createInstance = async function(options) { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.recurrenceRuleValidation.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.recurrenceRuleValidation.tests.js index a8d5b4170e91..9a93400f7933 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.recurrenceRuleValidation.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.recurrenceRuleValidation.tests.js @@ -1,4 +1,14 @@ -const $ = require('jquery'); +import $ from 'jquery'; + +import 'fluent_blue_light.css!'; + +import fx from 'common/core/animation/fx'; +import * as dragEvents from 'common/core/events/drag'; +import { DataSource } from 'common/data/data_source/data_source'; +import { createWrapper } from '../../helpers/scheduler/helpers.js'; + +import '__internal/scheduler/scheduler'; +import 'ui/drop_down_button'; QUnit.testStart(function() { $('#qunit-fixture').html( @@ -7,16 +17,6 @@ QUnit.testStart(function() {
'); }); -require('fluent_blue_light.css!'); - -const fx = require('common/core/animation/fx'); -const dragEvents = require('common/core/events/drag'); -const DataSource = require('common/data/data_source/data_source').DataSource; -const { createWrapper } = require('../../helpers/scheduler/helpers.js'); - -require('__internal/scheduler/scheduler'); -require('ui/drop_down_button'); - QUnit.module('Integration: recurrence rules validation', { beforeEach: function() { fx.off = true; diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.viewSwitcher.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.viewSwitcher.tests.js index 17d055ea0ba7..c0a720c0c6d7 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.viewSwitcher.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/integration.viewSwitcher.tests.js @@ -1,4 +1,14 @@ -const $ = require('jquery'); +import $ from 'jquery'; + +import 'fluent_blue_light.css!'; +import 'ui/drop_down_button'; + +import { noop } from 'core/utils/common'; +import { DataSource } from 'common/data/data_source/data_source'; +import { createWrapper } from '../../helpers/scheduler/helpers.js'; +import { waitAsync } from '../../helpers/scheduler/waitForAsync.js'; + +import '__internal/scheduler/scheduler'; QUnit.testStart(function() { $('#qunit-fixture').html( @@ -7,16 +17,6 @@ QUnit.testStart(function() {
'); }); -require('fluent_blue_light.css!'); -require('ui/drop_down_button'); - -const noop = require('core/utils/common').noop; -const DataSource = require('common/data/data_source/data_source').DataSource; -const { createWrapper } = require('../../helpers/scheduler/helpers.js'); -const { waitAsync } = require('../../helpers/scheduler/waitForAsync.js'); - -require('__internal/scheduler/scheduler'); - QUnit.module('Integration: View switcher', () => { QUnit.test('dataSource should be filtered if \'currentView\' option is changed', async function(assert) { const dataSource = new DataSource({ diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/loading.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/loading.tests.js index f49ef240ae7c..4f72cf33ef2b 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/loading.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/loading.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const loading = require('__internal/scheduler/loading'); -const viewPort = require('core/utils/view_port').value; -const fx = require('common/core/animation/fx'); -const LoadPanel = require('ui/load_panel'); +import $ from 'jquery'; +import * as loading from '__internal/scheduler/loading'; +import { value as viewPort } from 'core/utils/view_port'; +import fx from 'common/core/animation/fx'; +import LoadPanel from 'ui/load_panel'; QUnit.module('loading tests', { beforeEach: function() { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/diagram.missingModules.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/diagram.missingModules.tests.js index 81ac9299d301..4d8198542df5 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/diagram.missingModules.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/diagram.missingModules.tests.js @@ -1 +1 @@ -require('./diagramParts/importDiagram.tests.js'); +import './diagramParts/importDiagram.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/dropDownButton.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/dropDownButton.tests.js index 0c4faa275ab1..ffff4a3f23a7 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/dropDownButton.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/dropDownButton.tests.js @@ -1,7 +1,7 @@ import { getHeight, getOuterHeight, getOuterWidth, getWidth } from 'core/utils/size'; import $ from 'jquery'; import DropDownButton from 'ui/drop_down_button'; -import typeUtils, { isRenderer } from 'core/utils/type'; +import { isRenderer, isPromise } from 'core/utils/type'; import config from 'core/config'; import eventsEngine from 'common/core/events/core/events_engine'; import keyboardMock from '../../helpers/keyboardMock.js'; @@ -1726,7 +1726,7 @@ QUnit.module('public methods', { const togglePromise = this.dropDownButton.toggle(); assert.strictEqual(popup.option('visible'), false, 'popup visibility is inverted'); - assert.ok(typeUtils.isPromise(togglePromise), 'toggle should return promise'); + assert.ok(isPromise(togglePromise), 'toggle should return promise'); }); QUnit.test('open method', function(assert) { @@ -1735,7 +1735,7 @@ QUnit.module('public methods', { const openPromise = this.dropDownButton.open(); assert.strictEqual(popup.option('visible'), true, 'popup is opened'); - assert.ok(typeUtils.isPromise(openPromise), 'open should return promise'); + assert.ok(isPromise(openPromise), 'open should return promise'); }); QUnit.test('close method', function(assert) { @@ -1745,7 +1745,7 @@ QUnit.module('public methods', { const closePromise = this.dropDownButton.close(); assert.strictEqual(popup.option('visible'), false, 'popup is closed'); - assert.ok(typeUtils.isPromise(closePromise), 'close should return promise'); + assert.ok(isPromise(closePromise), 'close should return promise'); }); QUnit.test('opened option', function(assert) { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/gantt.missingModules.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/gantt.missingModules.tests.js index 9510f40ebac3..c79cad2d7a43 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/gantt.missingModules.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/gantt.missingModules.tests.js @@ -1 +1 @@ -require('./ganttParts/importGantt.tests.js'); +import './ganttParts/importGantt.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/bingTests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/bingTests.js index 3a6a0a1acc7e..7df2f8f97e39 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/bingTests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/bingTests.js @@ -2,17 +2,13 @@ import $ from 'jquery'; import errorsLogger from 'core/errors'; -import testing from './utils.js'; +import { LOCATIONS, MARKERS, ROUTES } from './utils.js'; import BingProvider from '__internal/ui/map/provider.dynamic.bing'; import ajaxMock from '../../../helpers/ajaxMock.js'; import errors from 'ui/widget/ui.errors'; import 'ui/map'; -const LOCATIONS = testing.LOCATIONS; -const MARKERS = testing.MARKERS; -const ROUTES = testing.ROUTES; - const prepareTestingBingProvider = function(abortDirectionsUpdate) { window.geocodedLocation = new Microsoft.Maps.Location(-1.12345, -1.12345); window.geocodedWithErrorLocation = new Microsoft.Maps.Location(); diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/commonTests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/commonTests.js index 9d3f32f59dcb..754ac7c8141a 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/commonTests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/commonTests.js @@ -1,12 +1,9 @@ import $ from 'jquery'; -import testing from './utils.js'; +import { MARKERS, ROUTES } from './utils.js'; import Map from 'ui/map'; import GoogleStaticProvider from '__internal/ui/map/provider.google_static'; import ajaxMock from '../../../helpers/ajaxMock.js'; -const MARKERS = testing.MARKERS; -const ROUTES = testing.ROUTES; - const MAP_CLASS = 'dx-map'; const MAP_CONTAINER_CLASS = 'dx-map-container'; const MAP_SHIELD_CLASS = 'dx-map-shield'; diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/googleStaticTests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/googleStaticTests.js index 1e8697ba5a38..8917af82b6fc 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/googleStaticTests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/googleStaticTests.js @@ -1,14 +1,10 @@ import $ from 'jquery'; -import testing from './utils.js'; +import { LOCATIONS, MARKERS, ROUTES } from './utils.js'; import Map from 'ui/map'; import GoogleStaticProvider from '__internal/ui/map/provider.google_static'; import Color from 'color'; import ajaxMock from '../../../helpers/ajaxMock.js'; -const LOCATIONS = testing.LOCATIONS; -const MARKERS = testing.MARKERS; -const ROUTES = testing.ROUTES; - const MAP_CONTAINER_CLASS = 'dx-map-container'; diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/utils.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/utils.js index 428c4949e952..6ab1eaebda00 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/utils.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/utils.js @@ -1,10 +1,10 @@ -exports.LOCATIONS = [ +export const LOCATIONS = [ 'Brooklyn Bridge,New York,NY', { lat: 40.537102, lng: -73.990318 }, [40.539102, -73.970318], '40.557102, -72.990318' ]; -exports.MARKERS = [ +export const MARKERS = [ { tooltip: { text: 'A', @@ -41,7 +41,7 @@ exports.MARKERS = [ } } ]; -exports.ROUTES = [ +export const ROUTES = [ { weight: 5, color: 'blue', diff --git a/packages/devextreme/testing/tests/DevExpress.viz.charts/polarChart.tests.js b/packages/devextreme/testing/tests/DevExpress.viz.charts/polarChart.tests.js index 781beda4acb4..e947b5b328dc 100644 --- a/packages/devextreme/testing/tests/DevExpress.viz.charts/polarChart.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.viz.charts/polarChart.tests.js @@ -5,7 +5,7 @@ import { Renderer, Legend, ExportMenu } from '../../helpers/vizMocks.js'; import trackerModule from 'viz/chart_components/tracker'; import chartThemeManagerModule from 'viz/components/chart_theme_manager'; import legendModule from 'viz/components/legend'; -import seriesModule, { Series } from 'viz/series/base_series'; +import seriesModule from 'viz/series/base_series'; import seriesFamilyModule from 'viz/core/series_family'; import axisModule from 'viz/axes/base_axis'; import dxPolarChart from 'viz/polar_chart'; @@ -18,6 +18,8 @@ import exportModule from '__internal/viz/core/exportModule'; import 'viz/chart'; +const { Series } = seriesModule; + const stubTooltip = sinon.createStubInstance(tooltipModule.Tooltip); const stubRange = sinon.createStubInstance(rangeModule.Range); const stubSeriesFamily = createStubSeriesFamily(); diff --git a/packages/devextreme/testing/tests/DevExpress.viz.gauges/barGauge_new.tests.js b/packages/devextreme/testing/tests/DevExpress.viz.gauges/barGauge_new.tests.js index 167d8682b962..0a3f0b971eec 100644 --- a/packages/devextreme/testing/tests/DevExpress.viz.gauges/barGauge_new.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.viz.gauges/barGauge_new.tests.js @@ -1,5 +1,5 @@ import $ from 'jquery'; -import legendModule, { Legend } from 'viz/components/legend'; +import legendModule from 'viz/components/legend'; import { Renderer, Title, @@ -15,6 +15,8 @@ import dxBarGauge from 'viz/bar_gauge'; import '__internal/viz/gauges/bar_gauge'; +const { Legend } = legendModule; + const environment = { beforeEach() { this.renderer = new Renderer(); diff --git a/packages/devextreme/testing/tests/DevExpress/color.tests.js b/packages/devextreme/testing/tests/DevExpress/color.tests.js index 52f75ff1ba14..0eeb0af899bd 100644 --- a/packages/devextreme/testing/tests/DevExpress/color.tests.js +++ b/packages/devextreme/testing/tests/DevExpress/color.tests.js @@ -1,4 +1,4 @@ -const Color = require('color'); +import Color from 'color'; QUnit.module('Colors parsing', { beforeEach: function() { From 8ec064d6f59895796b2bfdcd5d5311990db68145 Mon Sep 17 00:00:00 2001 From: Vladislav Volkov Date: Mon, 17 Aug 2026 14:01:41 +0400 Subject: [PATCH 3/4] Convert CJS imports to ESM (knockout, core, serverSide, ui.events, Bundles) (#34782) --- .../Bundles/bundlesParts/animation.tests.js | 2 +- .../tests/Bundles/bundlesParts/core.tests.js | 2 +- .../Bundles/bundlesParts/data.odata.tests.js | 2 +- .../Bundles/bundlesParts/events.tests.js | 4 +-- .../bundlesParts/widgets-base.tests.js | 2 +- .../Bundles/bundlesParts/widgets-web.tests.js | 2 +- .../testing/tests/Bundles/dx.all.tests.js | 18 ++++++------ .../testing/tests/Bundles/dx.custom.tests.js | 18 ++++++------ .../testing/tests/Bundles/dx.viz.tests.js | 14 +++++----- .../testing/tests/Bundles/dx.web.tests.js | 18 ++++++------ .../config_bundled_nojquery.tests.js | 15 +++++----- .../DevExpress.core/config_nojquery.tests.js | 2 +- .../tests/DevExpress.core/domAdapter.tests.js | 2 +- .../DevExpress.core/elementData.tests.js | 2 +- .../tests/DevExpress.core/guid.tests.js | 2 +- .../tests/DevExpress.core/namespace.tests.js | 6 ++-- .../tests/DevExpress.core/renderer.tests.js | 4 +-- .../tests/DevExpress.core/utils.ajax.tests.js | 6 ++-- .../utils.animationFrame.tests.js | 6 ++-- .../DevExpress.core/utils.browser.tests.js | 2 +- .../DevExpress.core/utils.callOnce.tests.js | 2 +- .../DevExpress.core/utils.callbacks.tests.js | 2 +- .../tests/DevExpress.core/utils.date.tests.js | 2 +- .../utils.date_parser.tests.js | 4 +-- .../utils.date_serialization.tests.js | 4 +-- .../DevExpress.core/utils.deferred.tests.js | 13 ++++----- .../utils.dependencyInjector.tests.js | 2 +- .../DevExpress.core/utils.inflector.tests.js | 2 +- .../tests/DevExpress.core/utils.math.tests.js | 2 +- .../DevExpress.core/utils.object.tests.js | 2 +- .../DevExpress.core/utils.queue.tests.js | 4 +-- .../DevExpress.core/utils.ready_callbacks.js | 2 +- .../DevExpress.core/utils.string.tests.js | 2 +- .../DevExpress.core/utils.topOverlay.tests.js | 4 +-- .../tests/DevExpress.core/utils.type.tests.js | 10 +++---- .../utils.variableWrapper.tests.js | 4 +-- .../DevExpress.core/utils.version.tests.js | 2 +- .../DevExpress.core/utils.viewPort.tests.js | 4 +-- .../DevExpress.knockout/accordion.tests.js | 8 +++--- .../DevExpress.knockout/actionSheet.tests.js | 10 +++---- .../DevExpress.knockout/autocomplete.tests.js | 10 +++---- .../tests/DevExpress.knockout/box.tests.js | 8 +++--- .../DevExpress.knockout/calendar.tests.js | 8 +++--- .../DevExpress.knockout/cleanNode.tests.js | 8 +++--- .../collectionWidget.tests.js | 12 ++++---- .../componentRegistration.tests.js | 28 +++++++++---------- .../DevExpress.knockout/contextMenu.tests.js | 8 +++--- .../DevExpress.knockout/draggable.test.js | 8 +++--- .../dropDownEditor.tests.js | 8 +++--- .../eventRegistration.tests.js | 20 ++++++------- .../fieldset_bundled.tests.js | 18 ++++++------ .../tests/DevExpress.knockout/list.tests.js | 14 +++++----- .../DevExpress.knockout/loadPanel.tests.js | 8 +++--- .../tests/DevExpress.knockout/lookup.tests.js | 12 ++++---- .../DevExpress.knockout/objectUtils.tests.js | 8 +++--- .../DevExpress.knockout/overlay.tests.js | 14 +++++----- .../DevExpress.knockout/pivotGrid.tests.js | 8 +++--- .../tests/DevExpress.knockout/popup.tests.js | 16 +++++------ .../DevExpress.knockout/scheduler.tests.js | 12 ++++---- .../DevExpress.knockout/selectBox.tests.js | 10 +++---- .../DevExpress.knockout/sortable.tests.js | 8 +++--- .../tests/DevExpress.knockout/tabs.tests.js | 8 +++--- .../tests/DevExpress.knockout/tagBox.tests.js | 10 +++---- .../DevExpress.knockout/template.tests.js | 8 +++--- .../DevExpress.knockout/toolbar.tests.js | 8 +++--- .../DevExpress.knockout/treeList.tests.js | 8 +++--- .../DevExpress.knockout/treeView.tests.js | 12 ++++---- .../validationGroup.tests.js | 16 +++++------ .../variableWrapperUtils.tests.js | 8 +++--- .../autocomplete.tests.js | 2 +- .../DevExpress.serverSide/calendar.tests.js | 2 +- .../calendarView.tests.js | 2 +- .../DevExpress.serverSide/checkbox.tests.js | 2 +- .../DevExpress.serverSide/colorBox.tests.js | 2 +- .../DevExpress.serverSide/colorView.tests.js | 2 +- .../DevExpress.serverSide/dataGrid.tests.js | 2 +- .../DevExpress.serverSide/datebox.tests.js | 2 +- .../dropDownBox.tests.js | 2 +- .../dropDownEditor.tests.js | 4 +-- .../DevExpress.serverSide/editor.tests.js | 2 +- .../DevExpress.serverSide/fieldChooser.js | 2 +- .../DevExpress.serverSide/fileManager.test.js | 2 +- .../fileUploader.tests.js | 2 +- .../filterBuilder.tests.js | 4 +-- .../DevExpress.serverSide/gantt.tests.js | 2 +- .../localization.intl.tests.js | 2 +- .../DevExpress.serverSide/lookup.tests.js | 2 +- .../DevExpress.serverSide/numberBox.tests.js | 2 +- .../DevExpress.serverSide/overlay.tests.js | 4 +-- .../DevExpress.serverSide/pivotGrid.test.js | 2 +- .../progressBar.tests.js | 2 +- .../rangeSlider.tests.js | 2 +- .../DevExpress.serverSide/selectBox.tests.js | 2 +- .../DevExpress.serverSide/slider.tests.js | 4 +-- .../DevExpress.serverSide/switch.tests.js | 2 +- .../DevExpress.serverSide/tagBox.tests.js | 2 +- .../DevExpress.serverSide/textArea.tests.js | 2 +- .../DevExpress.serverSide/textBox.tests.js | 2 +- .../DevExpress.serverSide/textEditor.tests.js | 2 +- .../DevExpress.serverSide/trackBar.tests.js | 6 ++-- .../DevExpress.serverSide/treeList.tests.js | 2 +- .../utils.ready_callbacks.tests.js | 2 +- .../validationGroup.tests.js | 2 +- .../validationSummary.tests.js | 2 +- .../DevExpress.serverSide/validator.tests.js | 2 +- .../widgetsCreation.tests.js | 4 +-- .../DevExpress.ui.events/contextmenu.tests.js | 12 ++++---- .../DevExpress.ui.events/dblclick.tests.js | 8 +++--- .../tests/DevExpress.ui.events/drag.tests.js | 12 ++++---- .../DevExpress.ui.events/feedback.tests.js | 10 +++---- .../tests/DevExpress.ui.events/hold.tests.js | 6 ++-- .../tests/DevExpress.ui.events/hover.tests.js | 6 ++-- .../DevExpress.ui.events/pointer.tests.js | 12 ++++---- .../pointerParts/baseTests.js | 12 ++++---- .../pointerParts/mouseAndTouchTests.js | 10 +++---- .../pointerParts/mouseTests.js | 10 +++---- .../pointerParts/touchTests.js | 14 +++++----- .../DevExpress.ui.events/scroll.tests.js | 18 ++++++------ .../transformation.tests.js | 4 +-- .../tests/DevExpress.ui.events/wheel.tests.js | 6 ++-- 120 files changed, 381 insertions(+), 385 deletions(-) diff --git a/packages/devextreme/testing/tests/Bundles/bundlesParts/animation.tests.js b/packages/devextreme/testing/tests/Bundles/bundlesParts/animation.tests.js index 4901738147fe..adb9bbba3336 100644 --- a/packages/devextreme/testing/tests/Bundles/bundlesParts/animation.tests.js +++ b/packages/devextreme/testing/tests/Bundles/bundlesParts/animation.tests.js @@ -1,4 +1,4 @@ -const $ = require('jquery'); +import $ from 'jquery'; QUnit.test('animation', function(assert) { diff --git a/packages/devextreme/testing/tests/Bundles/bundlesParts/core.tests.js b/packages/devextreme/testing/tests/Bundles/bundlesParts/core.tests.js index b572f50372b9..a2869b26c482 100644 --- a/packages/devextreme/testing/tests/Bundles/bundlesParts/core.tests.js +++ b/packages/devextreme/testing/tests/Bundles/bundlesParts/core.tests.js @@ -1,4 +1,4 @@ -const $ = require('jquery'); +import $ from 'jquery'; QUnit.test('core', function(assert) { diff --git a/packages/devextreme/testing/tests/Bundles/bundlesParts/data.odata.tests.js b/packages/devextreme/testing/tests/Bundles/bundlesParts/data.odata.tests.js index 58a2a5e54678..41385002be19 100644 --- a/packages/devextreme/testing/tests/Bundles/bundlesParts/data.odata.tests.js +++ b/packages/devextreme/testing/tests/Bundles/bundlesParts/data.odata.tests.js @@ -1,4 +1,4 @@ -const $ = require('jquery'); +import $ from 'jquery'; QUnit.test('data.odata', function(assert) { diff --git a/packages/devextreme/testing/tests/Bundles/bundlesParts/events.tests.js b/packages/devextreme/testing/tests/Bundles/bundlesParts/events.tests.js index a4634362de59..b1c6fa2b2e61 100644 --- a/packages/devextreme/testing/tests/Bundles/bundlesParts/events.tests.js +++ b/packages/devextreme/testing/tests/Bundles/bundlesParts/events.tests.js @@ -1,5 +1,5 @@ -const $ = require('jquery'); -const special = require('../../../helpers/eventHelper.js').special; +import $ from 'jquery'; +import { special } from '../../../helpers/eventHelper.js'; QUnit.test('events', function(assert) { diff --git a/packages/devextreme/testing/tests/Bundles/bundlesParts/widgets-base.tests.js b/packages/devextreme/testing/tests/Bundles/bundlesParts/widgets-base.tests.js index 302526274c8a..f60e0e5ce790 100644 --- a/packages/devextreme/testing/tests/Bundles/bundlesParts/widgets-base.tests.js +++ b/packages/devextreme/testing/tests/Bundles/bundlesParts/widgets-base.tests.js @@ -1,4 +1,4 @@ -const $ = require('jquery'); +import $ from 'jquery'; QUnit.test('widgets-base', function(assert) { diff --git a/packages/devextreme/testing/tests/Bundles/bundlesParts/widgets-web.tests.js b/packages/devextreme/testing/tests/Bundles/bundlesParts/widgets-web.tests.js index ed84590a1d82..76875c74e79c 100644 --- a/packages/devextreme/testing/tests/Bundles/bundlesParts/widgets-web.tests.js +++ b/packages/devextreme/testing/tests/Bundles/bundlesParts/widgets-web.tests.js @@ -1,4 +1,4 @@ -const $ = require('jquery'); +import $ from 'jquery'; QUnit.test('widgets-web', function(assert) { diff --git a/packages/devextreme/testing/tests/Bundles/dx.all.tests.js b/packages/devextreme/testing/tests/Bundles/dx.all.tests.js index 004aaa59610a..26109431b59c 100644 --- a/packages/devextreme/testing/tests/Bundles/dx.all.tests.js +++ b/packages/devextreme/testing/tests/Bundles/dx.all.tests.js @@ -1,6 +1,6 @@ -const $ = require('jquery'); +import $ from 'jquery'; -require('bundles/dx.all.js'); +import 'bundles/dx.all.js'; QUnit.test('DevExpress namespaces', function(assert) { const namespaces = [ @@ -19,10 +19,10 @@ QUnit.test('DevExpress namespaces', function(assert) { assert.ok(DevExpress.utils.readyCallbacks, 'readyCallbacks namespace'); }); -require('./bundlesParts/core.tests.js'); -require('./bundlesParts/events.tests.js'); -require('./bundlesParts/data.tests.js'); -require('./bundlesParts/data.odata.tests.js'); -require('./bundlesParts/animation.tests.js'); -require('./bundlesParts/widgets-base.tests.js'); -require('./bundlesParts/widgets-web.tests.js'); +import './bundlesParts/core.tests.js'; +import './bundlesParts/events.tests.js'; +import './bundlesParts/data.tests.js'; +import './bundlesParts/data.odata.tests.js'; +import './bundlesParts/animation.tests.js'; +import './bundlesParts/widgets-base.tests.js'; +import './bundlesParts/widgets-web.tests.js'; diff --git a/packages/devextreme/testing/tests/Bundles/dx.custom.tests.js b/packages/devextreme/testing/tests/Bundles/dx.custom.tests.js index cfdd52f6ed78..81ad2c77a395 100644 --- a/packages/devextreme/testing/tests/Bundles/dx.custom.tests.js +++ b/packages/devextreme/testing/tests/Bundles/dx.custom.tests.js @@ -1,6 +1,6 @@ -const $ = require('jquery'); +import $ from 'jquery'; -require('bundles/dx.custom.js'); +import 'bundles/dx.custom.js'; QUnit.test('DevExpress namespaces', function(assert) { const namespaces = [ @@ -16,10 +16,10 @@ QUnit.test('DevExpress namespaces', function(assert) { }); }); -require('./bundlesParts/core.tests.js'); -require('./bundlesParts/events.tests.js'); -require('./bundlesParts/data.tests.js'); -require('./bundlesParts/data.odata.tests.js'); -require('./bundlesParts/animation.tests.js'); -require('./bundlesParts/widgets-base.tests.js'); -require('./bundlesParts/widgets-web.tests.js'); +import './bundlesParts/core.tests.js'; +import './bundlesParts/events.tests.js'; +import './bundlesParts/data.tests.js'; +import './bundlesParts/data.odata.tests.js'; +import './bundlesParts/animation.tests.js'; +import './bundlesParts/widgets-base.tests.js'; +import './bundlesParts/widgets-web.tests.js'; diff --git a/packages/devextreme/testing/tests/Bundles/dx.viz.tests.js b/packages/devextreme/testing/tests/Bundles/dx.viz.tests.js index b579be2030f6..88d61c7f24cf 100644 --- a/packages/devextreme/testing/tests/Bundles/dx.viz.tests.js +++ b/packages/devextreme/testing/tests/Bundles/dx.viz.tests.js @@ -1,6 +1,6 @@ -const $ = require('jquery'); +import $ from 'jquery'; -require('bundles/dx.viz.js'); +import 'bundles/dx.viz.js'; QUnit.test('DevExpress namespaces', function(assert) { const namespaces = [ @@ -16,8 +16,8 @@ QUnit.test('DevExpress namespaces', function(assert) { }); }); -require('./bundlesParts/core.tests.js'); -require('./bundlesParts/events.tests.js'); -require('./bundlesParts/data.tests.js'); -require('./bundlesParts/data.odata.tests.js'); -require('./bundlesParts/animation.tests.js'); +import './bundlesParts/core.tests.js'; +import './bundlesParts/events.tests.js'; +import './bundlesParts/data.tests.js'; +import './bundlesParts/data.odata.tests.js'; +import './bundlesParts/animation.tests.js'; diff --git a/packages/devextreme/testing/tests/Bundles/dx.web.tests.js b/packages/devextreme/testing/tests/Bundles/dx.web.tests.js index b96815164317..c8ef7037c130 100644 --- a/packages/devextreme/testing/tests/Bundles/dx.web.tests.js +++ b/packages/devextreme/testing/tests/Bundles/dx.web.tests.js @@ -1,6 +1,6 @@ -const $ = require('jquery'); +import $ from 'jquery'; -require('bundles/dx.web.js'); +import 'bundles/dx.web.js'; QUnit.test('DevExpress namespaces', function(assert) { const namespaces = [ @@ -23,10 +23,10 @@ QUnit.test('DevExpress namespaces', function(assert) { }); }); -require('./bundlesParts/core.tests.js'); -require('./bundlesParts/events.tests.js'); -require('./bundlesParts/data.tests.js'); -require('./bundlesParts/data.odata.tests.js'); -require('./bundlesParts/animation.tests.js'); -require('./bundlesParts/widgets-base.tests.js'); -require('./bundlesParts/widgets-web.tests.js'); +import './bundlesParts/core.tests.js'; +import './bundlesParts/events.tests.js'; +import './bundlesParts/data.tests.js'; +import './bundlesParts/data.odata.tests.js'; +import './bundlesParts/animation.tests.js'; +import './bundlesParts/widgets-base.tests.js'; +import './bundlesParts/widgets-web.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.core/config_bundled_nojquery.tests.js b/packages/devextreme/testing/tests/DevExpress.core/config_bundled_nojquery.tests.js index b239f8f42fc9..8425f89264bd 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/config_bundled_nojquery.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/config_bundled_nojquery.tests.js @@ -1,11 +1,10 @@ -define(function(require) { - QUnit.test = QUnit.urlParams['nocsp'] ? QUnit.test : QUnit.skip; - require('bundles/dx.all.js'); +import 'bundles/dx.all.js'; - QUnit.module('config.useJQuery'); +QUnit.test = QUnit.urlParams['nocsp'] ? QUnit.test : QUnit.skip; - QUnit.test('config value useJQuery should be false if jquery is not included', function(assert) { - const config = DevExpress.config; - assert.equal(!!config().useJQuery, false); - }); +QUnit.module('config.useJQuery'); + +QUnit.test('config value useJQuery should be false if jquery is not included', function(assert) { + const config = DevExpress.config; + assert.equal(!!config().useJQuery, false); }); diff --git a/packages/devextreme/testing/tests/DevExpress.core/config_nojquery.tests.js b/packages/devextreme/testing/tests/DevExpress.core/config_nojquery.tests.js index 72c3071ea903..6b822ccfe13f 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/config_nojquery.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/config_nojquery.tests.js @@ -1,4 +1,4 @@ -const config = require('core/config'); +import config from 'core/config'; QUnit.module('config.useJQuery'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/domAdapter.tests.js b/packages/devextreme/testing/tests/DevExpress.core/domAdapter.tests.js index 20220591e88f..4ecb6f729423 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/domAdapter.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/domAdapter.tests.js @@ -1,4 +1,4 @@ -const domAdapter = require('core/dom_adapter'); +import domAdapter from 'core/dom_adapter'; QUnit.module('DOM Adapter', { beforeEach: function() { diff --git a/packages/devextreme/testing/tests/DevExpress.core/elementData.tests.js b/packages/devextreme/testing/tests/DevExpress.core/elementData.tests.js index 613c39d0ff37..b570f85b7d76 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/elementData.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/elementData.tests.js @@ -1,4 +1,4 @@ -const dataUtils = require('core/element_data'); +import * as dataUtils from 'core/element_data'; QUnit.module('Data'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/guid.tests.js b/packages/devextreme/testing/tests/DevExpress.core/guid.tests.js index afe4e2afcb97..8b8cf824aa10 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/guid.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/guid.tests.js @@ -1,4 +1,4 @@ -const Guid = require('core/guid'); +import Guid from 'core/guid'; QUnit.module('Guid'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/namespace.tests.js b/packages/devextreme/testing/tests/DevExpress.core/namespace.tests.js index ff21a6088e2b..43f157d18be8 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/namespace.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/namespace.tests.js @@ -1,7 +1,7 @@ -const testGlobalExports = require('../../helpers/publicModulesHelper.js'); -const { version } = require('core/version'); +import testGlobalExports from '../../helpers/publicModulesHelper.js'; +import { version } from 'core/version'; -require('bundles/modules/core'); +import 'bundles/modules/core'; testGlobalExports({ 'DevExpress': DevExpress diff --git a/packages/devextreme/testing/tests/DevExpress.core/renderer.tests.js b/packages/devextreme/testing/tests/DevExpress.core/renderer.tests.js index 81e4982aa60e..20fef36c5dd6 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/renderer.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/renderer.tests.js @@ -1,5 +1,5 @@ -const { setHeight, setWidth, implementationsMap } = require('core/utils/size'); -const renderer = require('core/renderer'); +import { setHeight, setWidth, implementationsMap } from 'core/utils/size'; +import renderer from 'core/renderer'; QUnit.module('renderer'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.ajax.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.ajax.tests.js index e5cffcd95c9f..2ddc16fb90c3 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.ajax.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.ajax.tests.js @@ -1,6 +1,6 @@ -const $ = require('jquery'); -const ajax = require('core/utils/ajax'); -const compareVersion = require('core/utils/version').compare; +import $ from 'jquery'; +import ajax from 'core/utils/ajax'; +import { compare as compareVersion } from 'core/utils/version'; QUnit.test = QUnit.urlParams['nocsp'] ? QUnit.test : QUnit.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.animationFrame.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.animationFrame.tests.js index 4fcc57b708d0..cb656949677c 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.animationFrame.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.animationFrame.tests.js @@ -1,6 +1,6 @@ -const $ = require('jquery'); -const animationFrame = require('common/core/animation/frame'); -const coreUtilsType = require('core/utils/type'); +import $ from 'jquery'; +import * as animationFrame from 'common/core/animation/frame'; +import * as coreUtilsType from 'core/utils/type'; QUnit.module('animation frame'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.browser.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.browser.tests.js index 3b130918c3e8..73f57f1e2e9e 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.browser.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.browser.tests.js @@ -1,4 +1,4 @@ -const browser = require('core/utils/browser'); +import browser from 'core/utils/browser'; const userAgents = { webkit: 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Custom/43.0.2357.124', diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.callOnce.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.callOnce.tests.js index 40d37d5e9842..25f6af0c10ec 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.callOnce.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.callOnce.tests.js @@ -1,4 +1,4 @@ -const callOnce = require('core/utils/call_once'); +import callOnce from 'core/utils/call_once'; QUnit.module('callOnce'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.callbacks.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.callbacks.tests.js index 655765914043..7979d8f50a12 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.callbacks.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.callbacks.tests.js @@ -1,4 +1,4 @@ -const Callbacks = require('core/utils/callbacks'); +import Callbacks from 'core/utils/callbacks'; QUnit.module('Methods', { beforeEach: function() { diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.date.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.date.tests.js index 33b63f0f13cc..57094138f274 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.date.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.date.tests.js @@ -1,4 +1,4 @@ -const dateUtils = require('core/utils/date'); +import dateUtils from 'core/utils/date'; const WEEK_DAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']; diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.date_parser.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.date_parser.tests.js index 0f362cd3cf90..2adb57a35cb8 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.date_parser.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.date_parser.tests.js @@ -1,5 +1,5 @@ -const dateSerialization = require('core/utils/date_serialization'); -const config = require('core/config'); +import dateSerialization from 'core/utils/date_serialization'; +import config from 'core/config'; QUnit.module('Default DX Formats'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.date_serialization.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.date_serialization.tests.js index 52caaf89815c..1ef84b2d5312 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.date_serialization.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.date_serialization.tests.js @@ -1,5 +1,5 @@ -const dateSerialization = require('core/utils/date_serialization'); -const config = require('core/config'); +import dateSerialization from 'core/utils/date_serialization'; +import config from 'core/config'; QUnit.module('date serialization tests', { beforeEach: function() { diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.deferred.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.deferred.tests.js index 00e03da93ee7..59d3b42bb705 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.deferred.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.deferred.tests.js @@ -1,12 +1,9 @@ -define(function(require) { - const isFunction = require('core/utils/type').isFunction; - const deferredUtils = require('core/utils/deferred'); - const Deferred = deferredUtils.Deferred; +import { isFunction } from 'core/utils/type'; +import * as deferredUtils from 'core/utils/deferred'; - if(!QUnit.urlParams['nojquery']) { - return; - } +const { Deferred } = deferredUtils; +if(QUnit.urlParams['nojquery']) { QUnit.module('when'); QUnit.test('when should be resolved synchronously', function(assert) { @@ -491,4 +488,4 @@ define(function(require) { deferred.resolve(1); }); -}); +} diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.dependencyInjector.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.dependencyInjector.tests.js index e0038433ce04..0c128e2bba9c 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.dependencyInjector.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.dependencyInjector.tests.js @@ -1,4 +1,4 @@ -const dependencyInjector = require('core/utils/dependency_injector'); +import dependencyInjector from 'core/utils/dependency_injector'; QUnit.module('dependencyInjector'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.inflector.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.inflector.tests.js index d89fb09febc9..d3821edba406 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.inflector.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.inflector.tests.js @@ -1,4 +1,4 @@ -const inflector = require('core/utils/inflector'); +import * as inflector from 'core/utils/inflector'; QUnit.module('inflector'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.math.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.math.tests.js index 08bad03e0d61..a6a12f9e637e 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.math.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.math.tests.js @@ -1,4 +1,4 @@ -const mathUtils = require('core/utils/math'); +import * as mathUtils from 'core/utils/math'; const adjust = mathUtils.adjust; QUnit.test('fitIntoRange', function(assert) { diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.object.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.object.tests.js index ee2de0cafc59..8626f70f98e6 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.object.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.object.tests.js @@ -1,4 +1,4 @@ -const objectUtils = require('core/utils/object'); +import * as objectUtils from 'core/utils/object'; QUnit.test('orderEach', function(assert) { const checkOrderEach = function(mapKeys, keys) { diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.queue.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.queue.tests.js index e45b3e012d1e..4b9152f6ab6f 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.queue.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.queue.tests.js @@ -1,5 +1,5 @@ -const $ = require('jquery'); -const queueUtils = require('core/utils/queue'); +import $ from 'jquery'; +import * as queueUtils from 'core/utils/queue'; QUnit.module('enqueue'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.ready_callbacks.js b/packages/devextreme/testing/tests/DevExpress.core/utils.ready_callbacks.js index d34014597f44..d5b31ae3320e 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.ready_callbacks.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.ready_callbacks.js @@ -1,4 +1,4 @@ -const readyCallbacks = require('core/utils/ready_callbacks'); +import readyCallbacks from 'core/utils/ready_callbacks'; QUnit.module('readyCallbacks injection', { afterEach: function() { diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.string.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.string.tests.js index 7d741058029f..dd40da14f95f 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.string.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.string.tests.js @@ -1,4 +1,4 @@ -const stringUtils = require('core/utils/string'); +import * as stringUtils from 'core/utils/string'; QUnit.module('String utils'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.topOverlay.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.topOverlay.tests.js index e166fe4a77b8..4a16594e8e4b 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.topOverlay.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.topOverlay.tests.js @@ -1,5 +1,5 @@ -const hideTopOverlay = require('common/core/environment/hide_top_overlay'); -const hideTopOverlayCallback = require('common/core/environment/hide_callback').hideCallback; +import hideTopOverlay from 'common/core/environment/hide_top_overlay'; +import { hideCallback as hideTopOverlayCallback } from 'common/core/environment/hide_callback'; QUnit.module('top overlay util'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.type.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.type.tests.js index 64fc102e8fbf..f9b83d4d1f72 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.type.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.type.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const typeUtils = require('core/utils/type'); -const Deferred = require('core/utils/deferred').Deferred; -const renderer = require('core/renderer'); -const eventsEngine = require('common/core/events/core/events_engine'); +import $ from 'jquery'; +import * as typeUtils from 'core/utils/type'; +import { Deferred } from 'core/utils/deferred'; +import renderer from 'core/renderer'; +import eventsEngine from 'common/core/events/core/events_engine'; QUnit.module('Type checking'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.variableWrapper.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.variableWrapper.tests.js index 6826b0d54b22..2d501deaa2bd 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.variableWrapper.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.variableWrapper.tests.js @@ -1,5 +1,5 @@ -const variableWrapper = require('core/utils/variable_wrapper'); -const { logger } = require('core/utils/console'); +import variableWrapper from 'core/utils/variable_wrapper'; +import { logger } from 'core/utils/console'; QUnit.test('Base wrapper methods', function(assert) { assert.strictEqual(variableWrapper.isWrapped(3), false, 'isWrapped method'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.version.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.version.tests.js index 52ac8ad732c5..7d92557fef71 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.version.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.version.tests.js @@ -1,4 +1,4 @@ -const compare = require('core/utils/version').compare; +import { compare } from 'core/utils/version'; QUnit.module('version'); diff --git a/packages/devextreme/testing/tests/DevExpress.core/utils.viewPort.tests.js b/packages/devextreme/testing/tests/DevExpress.core/utils.viewPort.tests.js index d221fc4188d7..2764eb8ea107 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/utils.viewPort.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/utils.viewPort.tests.js @@ -1,5 +1,5 @@ -const $ = require('jquery'); -const viewPortUtils = require('core/utils/view_port'); +import $ from 'jquery'; +import * as viewPortUtils from 'core/utils/view_port'; const viewPort = viewPortUtils.value; const viewPortChanged = viewPortUtils.changeCallback; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/accordion.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/accordion.tests.js index 1aa8ec8d966b..73fb8de9fa96 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/accordion.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/accordion.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const ko = require('knockout'); +import $ from 'jquery'; +import ko from 'knockout'; -require('ui/accordion'); -require('integration/knockout'); +import 'ui/accordion'; +import 'integration/knockout'; if(QUnit.urlParams['nocsp']) { QUnit.module('accordion'); diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/actionSheet.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/actionSheet.tests.js index 915242f80339..7f9b0f8be278 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/actionSheet.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/actionSheet.tests.js @@ -1,9 +1,9 @@ -const $ = require('jquery'); -const noop = require('core/utils/common').noop; -const ko = require('knockout'); +import $ from 'jquery'; +import { noop } from 'core/utils/common'; +import ko from 'knockout'; -require('ui/action_sheet'); -require('integration/knockout'); +import 'ui/action_sheet'; +import 'integration/knockout'; if(QUnit.urlParams['nocsp']) { QUnit.module('actionSheet'); diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/autocomplete.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/autocomplete.tests.js index 75e68a92ef42..051095d87f9e 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/autocomplete.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/autocomplete.tests.js @@ -1,9 +1,9 @@ -const $ = require('jquery'); -const keyboardMock = require('../../helpers/keyboardMock.js'); -const ko = require('knockout'); -const Autocomplete = require('ui/autocomplete'); +import $ from 'jquery'; +import keyboardMock from '../../helpers/keyboardMock.js'; +import ko from 'knockout'; +import Autocomplete from 'ui/autocomplete'; -require('integration/knockout'); +import 'integration/knockout'; if(QUnit.urlParams['nocsp']) { QUnit.module('autocomplete'); diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/box.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/box.tests.js index dcf294de0542..895ea354435f 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/box.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/box.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const ko = require('knockout'); +import $ from 'jquery'; +import ko from 'knockout'; -require('ui/box'); -require('integration/knockout'); +import 'ui/box'; +import 'integration/knockout'; if(QUnit.urlParams['nocsp']) { QUnit.module('box'); diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/calendar.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/calendar.tests.js index 67b304370855..36c48366dbfa 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/calendar.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/calendar.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const ko = require('knockout'); +import $ from 'jquery'; +import ko from 'knockout'; -require('integration/knockout'); -require('ui/calendar'); +import 'integration/knockout'; +import 'ui/calendar'; if(QUnit.urlParams['nocsp']) { QUnit.module('calendar'); diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/cleanNode.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/cleanNode.tests.js index 09d033a2cb0f..18cfac3f7b09 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/cleanNode.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/cleanNode.tests.js @@ -1,8 +1,8 @@ -require('integration/knockout'); +import 'integration/knockout'; -const $ = require('jquery'); -const ko = require('knockout'); -const dataUtils = require('core/element_data'); +import $ from 'jquery'; +import ko from 'knockout'; +import * as dataUtils from 'core/element_data'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/collectionWidget.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/collectionWidget.tests.js index 85fc6c1a9364..782302d79e69 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/collectionWidget.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/collectionWidget.tests.js @@ -1,10 +1,10 @@ -const $ = require('jquery'); -const ko = require('knockout'); -const registerComponent = require('core/component_registrator'); -const CollectionWidget = require('ui/collection/ui.collection_widget.edit'); -const executeAsyncMock = require('../../helpers/executeAsyncMock.js'); +import $ from 'jquery'; +import ko from 'knockout'; +import registerComponent from 'core/component_registrator'; +import CollectionWidget from 'ui/collection/ui.collection_widget.edit'; +import executeAsyncMock from '../../helpers/executeAsyncMock.js'; -require('integration/knockout'); +import 'integration/knockout'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/componentRegistration.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/componentRegistration.tests.js index 0eb69968ab12..5642133ce0b0 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/componentRegistration.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/componentRegistration.tests.js @@ -1,17 +1,17 @@ -const $ = require('jquery'); -const noop = require('core/utils/common').noop; -const ko = require('knockout'); -const registerComponent = require('core/component_registrator'); -const DOMComponent = require('core/dom_component'); -const Widget = require('ui/widget/ui.widget'); -const KoTemplate = require('__internal/integration/knockout/template').KoTemplate; -const CollectionWidget = require('ui/collection/ui.collection_widget.edit'); -const config = require('core/config'); -const dataUtils = require('core/element_data'); - -require('ui/select_box'); -require('ui/lookup'); -require('integration/knockout'); +import $ from 'jquery'; +import { noop } from 'core/utils/common'; +import ko from 'knockout'; +import registerComponent from 'core/component_registrator'; +import DOMComponent from 'core/dom_component'; +import Widget from 'ui/widget/ui.widget'; +import { KoTemplate } from '__internal/integration/knockout/template'; +import CollectionWidget from 'ui/collection/ui.collection_widget.edit'; +import config from 'core/config'; +import * as dataUtils from 'core/element_data'; + +import 'ui/select_box'; +import 'ui/lookup'; +import 'integration/knockout'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/contextMenu.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/contextMenu.tests.js index 2e00952a03ae..007675bd338a 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/contextMenu.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/contextMenu.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const ko = require('knockout'); +import $ from 'jquery'; +import ko from 'knockout'; -require('ui/context_menu'); -require('integration/knockout'); +import 'ui/context_menu'; +import 'integration/knockout'; if(QUnit.urlParams['nocsp']) { QUnit.module('contextMenu'); diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/draggable.test.js b/packages/devextreme/testing/tests/DevExpress.knockout/draggable.test.js index 158144782ee3..3fd767fb6891 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/draggable.test.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/draggable.test.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const ko = require('knockout'); +import $ from 'jquery'; +import ko from 'knockout'; -require('ui/draggable'); -require('integration/knockout'); +import 'ui/draggable'; +import 'integration/knockout'; if(QUnit.urlParams['nocsp']) { QUnit.module('draggable'); diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/dropDownEditor.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/dropDownEditor.tests.js index 71c25bda8a73..b37dce285d97 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/dropDownEditor.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/dropDownEditor.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const ko = require('knockout'); +import $ from 'jquery'; +import ko from 'knockout'; -require('integration/knockout'); -require('ui/drop_down_editor/ui.drop_down_editor'); +import 'integration/knockout'; +import 'ui/drop_down_editor/ui.drop_down_editor'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/eventRegistration.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/eventRegistration.tests.js index d361180f9fd4..9f374cff9ec4 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/eventRegistration.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/eventRegistration.tests.js @@ -1,13 +1,13 @@ -const $ = require('jquery'); -const ko = require('knockout'); -const registerEvent = require('common/core/events/core/event_registrator'); -const dragEvents = require('common/core/events/drag'); -const clickEvent = require('common/core/events/click'); -const holdEvent = require('common/core/events/hold'); -const pointerEvents = require('common/core/events/pointer'); -const swipeEvents = require('common/core/events/swipe'); - -require('integration/knockout'); +import $ from 'jquery'; +import ko from 'knockout'; +import registerEvent from 'common/core/events/core/event_registrator'; +import * as dragEvents from 'common/core/events/drag'; +import * as clickEvent from 'common/core/events/click'; +import holdEvent from 'common/core/events/hold'; +import pointerEvents from 'common/core/events/pointer'; +import * as swipeEvents from 'common/core/events/swipe'; + +import 'integration/knockout'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/fieldset_bundled.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/fieldset_bundled.tests.js index fca674de95b1..a06d1f04ed40 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/fieldset_bundled.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/fieldset_bundled.tests.js @@ -1,12 +1,12 @@ -const $ = require('jquery'); -const ko = require('knockout'); -const browser = require('core/utils/browser'); -const devices = require('core/devices'); - -require('fluent_blue_light.css!'); -require('../../helpers/executeAsyncMock.js'); -require('integration/knockout'); -require('bundles/modules/parts/widgets-web'); +import $ from 'jquery'; +import ko from 'knockout'; +import browser from 'core/utils/browser'; +import devices from 'core/devices'; + +import 'fluent_blue_light.css!'; +import '../../helpers/executeAsyncMock.js'; +import 'integration/knockout'; +import 'bundles/modules/parts/widgets-web'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/list.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/list.tests.js index ccaef0f8ac54..e714b13b60fa 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/list.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/list.tests.js @@ -1,13 +1,13 @@ // eslint-disable-next-line spellcheck/spell-checker -const { rerender } = require('inferno'); -const $ = require('jquery'); -const ko = require('knockout'); -const executeAsyncMock = require('../../helpers/executeAsyncMock.js'); +import { rerender } from 'inferno'; +import $ from 'jquery'; +import ko from 'knockout'; +import executeAsyncMock from '../../helpers/executeAsyncMock.js'; -require('ui/list'); -require('integration/knockout'); +import 'ui/list'; +import 'integration/knockout'; -require('fluent_blue_light.css!'); +import 'fluent_blue_light.css!'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/loadPanel.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/loadPanel.tests.js index fd1a488e1d02..1c0bac242b33 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/loadPanel.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/loadPanel.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const ko = require('knockout'); +import $ from 'jquery'; +import ko from 'knockout'; -require('ui/load_panel'); -require('integration/knockout'); +import 'ui/load_panel'; +import 'integration/knockout'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/lookup.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/lookup.tests.js index dce97a7ad480..e8a4e4f54572 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/lookup.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/lookup.tests.js @@ -1,10 +1,10 @@ -const $ = require('jquery'); -const fx = require('common/core/animation/fx'); -const executeAsyncMock = require('../../helpers/executeAsyncMock.js'); -const ko = require('knockout'); +import $ from 'jquery'; +import fx from 'common/core/animation/fx'; +import executeAsyncMock from '../../helpers/executeAsyncMock.js'; +import ko from 'knockout'; -require('ui/lookup'); -require('integration/knockout'); +import 'ui/lookup'; +import 'integration/knockout'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/objectUtils.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/objectUtils.tests.js index 957c8333967d..40473d14344f 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/objectUtils.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/objectUtils.tests.js @@ -1,8 +1,8 @@ -const ko = require('knockout'); -const variableWrapper = require('core/utils/variable_wrapper'); -const objectUtils = require('core/utils/object'); +import ko from 'knockout'; +import variableWrapper from 'core/utils/variable_wrapper'; +import * as objectUtils from 'core/utils/object'; -require('integration/knockout'); +import 'integration/knockout'; if(QUnit.urlParams['nocsp']) { QUnit.module('objectUtils'); diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/overlay.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/overlay.tests.js index 43e88500b53c..589945083c9d 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/overlay.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/overlay.tests.js @@ -1,12 +1,12 @@ -const $ = require('jquery'); -const fx = require('common/core/animation/fx'); -const ko = require('knockout'); +import $ from 'jquery'; +import fx from 'common/core/animation/fx'; +import ko from 'knockout'; -require('ui/overlay/ui.overlay'); -require('ui/slider'); -require('integration/knockout'); +import 'ui/overlay/ui.overlay'; +import 'ui/slider'; +import 'integration/knockout'; -require('fluent_blue_light.css!'); +import 'fluent_blue_light.css!'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/pivotGrid.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/pivotGrid.tests.js index 371579a4c8f6..8bba7db3198d 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/pivotGrid.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/pivotGrid.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const ko = require('knockout'); +import $ from 'jquery'; +import ko from 'knockout'; -require('ui/pivot_grid/ui.pivot_grid'); -require('integration/knockout'); +import 'ui/pivot_grid/ui.pivot_grid'; +import 'integration/knockout'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/popup.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/popup.tests.js index 7674a1d2da9b..786a39b98e49 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/popup.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/popup.tests.js @@ -1,11 +1,11 @@ -const $ = require('jquery'); -const viewPort = require('core/utils/view_port').value; -const devices = require('core/devices'); -const themes = require('ui/themes'); -const ko = require('knockout'); - -require('ui/popup'); -require('integration/knockout'); +import $ from 'jquery'; +import { value as viewPort } from 'core/utils/view_port'; +import devices from 'core/devices'; +import themes from 'ui/themes'; +import ko from 'knockout'; + +import 'ui/popup'; +import 'integration/knockout'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/scheduler.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/scheduler.tests.js index 9e4e250dd210..7c7d4a27cbb3 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/scheduler.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/scheduler.tests.js @@ -1,11 +1,11 @@ -const $ = require('jquery'); -const ko = require('knockout'); +import $ from 'jquery'; +import ko from 'knockout'; -require('integration/knockout'); -require('ui/scheduler'); -const { waitAsync } = require('../../helpers/scheduler/waitForAsync.js'); +import 'integration/knockout'; +import 'ui/scheduler'; +import { waitAsync } from '../../helpers/scheduler/waitForAsync.js'; -require('fluent_blue_light.css!'); +import 'fluent_blue_light.css!'; if(QUnit.urlParams['nocsp']) { QUnit.module('scheduler'); diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/selectBox.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/selectBox.tests.js index e1ef4e07e3a6..ebbcd6d86678 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/selectBox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/selectBox.tests.js @@ -1,9 +1,9 @@ -const $ = require('jquery'); -const SelectBox = require('ui/select_box'); -const fx = require('common/core/animation/fx'); -const ko = require('knockout'); +import $ from 'jquery'; +import SelectBox from 'ui/select_box'; +import fx from 'common/core/animation/fx'; +import ko from 'knockout'; -require('integration/knockout'); +import 'integration/knockout'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/sortable.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/sortable.tests.js index d8ed65f0ad23..2a957de9f147 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/sortable.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/sortable.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const ko = require('knockout'); +import $ from 'jquery'; +import ko from 'knockout'; -require('ui/sortable'); -require('integration/knockout'); +import 'ui/sortable'; +import 'integration/knockout'; if(QUnit.urlParams['nocsp']) { QUnit.module('sortable'); diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/tabs.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/tabs.tests.js index 04b7d4ecb257..6f0e24c9e0c5 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/tabs.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/tabs.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const ko = require('knockout'); +import $ from 'jquery'; +import ko from 'knockout'; -require('ui/tabs'); -require('integration/knockout'); +import 'ui/tabs'; +import 'integration/knockout'; if(QUnit.urlParams['nocsp']) { QUnit.module('tabs'); diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/tagBox.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/tagBox.tests.js index 0669839de5d5..a3da1992fc6c 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/tagBox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/tagBox.tests.js @@ -1,9 +1,9 @@ -const $ = require('jquery'); -const TagBox = require('ui/tag_box'); -const fx = require('common/core/animation/fx'); -const ko = require('knockout'); +import $ from 'jquery'; +import TagBox from 'ui/tag_box'; +import fx from 'common/core/animation/fx'; +import ko from 'knockout'; -require('integration/knockout'); +import 'integration/knockout'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/template.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/template.tests.js index d1c93959a99b..0a0e61558a83 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/template.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/template.tests.js @@ -1,7 +1,7 @@ -const $ = require('jquery'); -const noop = require('core/utils/common').noop; -const ko = require('knockout'); -const KoTemplate = require('__internal/integration/knockout/template').KoTemplate; +import $ from 'jquery'; +import { noop } from 'core/utils/common'; +import ko from 'knockout'; +import { KoTemplate } from '__internal/integration/knockout/template'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/toolbar.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/toolbar.tests.js index c062021fd46d..feed2c66c09f 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/toolbar.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/toolbar.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const ko = require('knockout'); +import $ from 'jquery'; +import ko from 'knockout'; -require('ui/toolbar'); -require('integration/knockout'); +import 'ui/toolbar'; +import 'integration/knockout'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/treeList.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/treeList.tests.js index c373b4e03a6c..cd28b27a44cb 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/treeList.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/treeList.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const ko = require('knockout'); +import $ from 'jquery'; +import ko from 'knockout'; -require('ui/tree_list'); -require('integration/knockout'); +import 'ui/tree_list'; +import 'integration/knockout'; if(QUnit.urlParams['nocsp']) { QUnit.module('treeList'); diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/treeView.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/treeView.tests.js index f36d202feda9..e315f3c49d4e 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/treeView.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/treeView.tests.js @@ -1,10 +1,10 @@ -const $ = require('jquery'); -const noop = require('core/utils/common').noop; -const ko = require('knockout'); +import $ from 'jquery'; +import { noop } from 'core/utils/common'; +import ko from 'knockout'; -require('ui/button'); -require('ui/tree_view'); -require('integration/knockout'); +import 'ui/button'; +import 'ui/tree_view'; +import 'integration/knockout'; if(QUnit.urlParams['nocsp']) { QUnit.module('treeView'); diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/validationGroup.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/validationGroup.tests.js index 53552dd61d28..03cafdd745ad 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/validationGroup.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/validationGroup.tests.js @@ -1,11 +1,11 @@ -const $ = require('jquery'); -const ko = require('knockout'); -const ValidationEngine = require('ui/validation_engine'); - -require('ui/text_box'); -require('ui/validation_group'); -require('ui/validator'); -require('integration/knockout'); +import $ from 'jquery'; +import ko from 'knockout'; +import ValidationEngine from 'ui/validation_engine'; + +import 'ui/text_box'; +import 'ui/validation_group'; +import 'ui/validator'; +import 'integration/knockout'; const moduleWithoutCsp = QUnit.urlParams['nocsp'] ? QUnit.module : QUnit.module.skip; diff --git a/packages/devextreme/testing/tests/DevExpress.knockout/variableWrapperUtils.tests.js b/packages/devextreme/testing/tests/DevExpress.knockout/variableWrapperUtils.tests.js index a43c88e1ab7f..bc793dc7d40c 100644 --- a/packages/devextreme/testing/tests/DevExpress.knockout/variableWrapperUtils.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.knockout/variableWrapperUtils.tests.js @@ -1,8 +1,8 @@ -const ko = require('knockout'); -const variableWrapper = require('core/utils/variable_wrapper'); -const { logger } = require('core/utils/console'); +import ko from 'knockout'; +import variableWrapper from 'core/utils/variable_wrapper'; +import { logger } from 'core/utils/console'; -require('integration/knockout'); +import 'integration/knockout'; if(QUnit.urlParams['nocsp']) { QUnit.module('variableWrapperUtils'); diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/autocomplete.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/autocomplete.tests.js index 96bbb0814273..1465ec1041b3 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/autocomplete.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/autocomplete.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/autocomplete.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/autocomplete.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/calendar.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/calendar.tests.js index e66ea9a02d22..2e12f7ce1934 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/calendar.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/calendar.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/calendar.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/calendar.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/calendarView.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/calendarView.tests.js index 379d0c3a2bde..1df0b685f22d 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/calendarView.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/calendarView.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/calendarView.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/calendarView.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/checkbox.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/checkbox.tests.js index c1b0d6e44add..b5fc2724d7ee 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/checkbox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/checkbox.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/checkbox.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/checkbox.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/colorBox.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/colorBox.tests.js index 3bc387fd14fe..982ff39cba8b 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/colorBox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/colorBox.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/colorBox.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/colorBox.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/colorView.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/colorView.tests.js index c201e83bda6d..f583b2c317b0 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/colorView.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/colorView.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/colorView.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/colorView.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/dataGrid.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/dataGrid.tests.js index ec74c8ebdb22..08524be4e186 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/dataGrid.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/dataGrid.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.dataGrid/dataGrid.markup.tests.js'); +import '../DevExpress.ui.widgets.dataGrid/dataGrid.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/datebox.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/datebox.tests.js index 83b3da7dae74..1abfc6833567 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/datebox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/datebox.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/datebox.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/datebox.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/dropDownBox.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/dropDownBox.tests.js index 7f0b377d0e1c..0a924c4d3ddd 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/dropDownBox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/dropDownBox.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/dropDownBox.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/dropDownBox.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/dropDownEditor.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/dropDownEditor.tests.js index db2ecf9228a4..75ed630f0be3 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/dropDownEditor.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/dropDownEditor.tests.js @@ -1,6 +1,6 @@ -require('../DevExpress.ui.widgets.editors/dropDownEditor.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/dropDownEditor.markup.tests.js'; -const $ = require('jquery'); +import $ from 'jquery'; QUnit.testStart(function() { const markup = diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/editor.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/editor.tests.js index 44c141bfad1c..35d3c16459a1 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/editor.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/editor.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/editor.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/editor.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/fieldChooser.js b/packages/devextreme/testing/tests/DevExpress.serverSide/fieldChooser.js index 6dcfd49d807f..e149cec5a68a 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/fieldChooser.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/fieldChooser.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.pivotGrid/fieldChooser.markup.tests.js'); +import '../DevExpress.ui.widgets.pivotGrid/fieldChooser.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/fileManager.test.js b/packages/devextreme/testing/tests/DevExpress.serverSide/fileManager.test.js index 99cab6583dd4..3279f15e81fc 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/fileManager.test.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/fileManager.test.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets/fileManagerParts/markup.tests.js'); +import '../DevExpress.ui.widgets/fileManagerParts/markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/fileUploader.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/fileUploader.tests.js index f4589a68023c..2bec0f8ddd17 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/fileUploader.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/fileUploader.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/fileUploader.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/fileUploader.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/filterBuilder.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/filterBuilder.tests.js index 8a0776fe2cf4..6ef6b145c922 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/filterBuilder.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/filterBuilder.tests.js @@ -1,4 +1,4 @@ -const $ = require('jquery'); +import $ from 'jquery'; QUnit.testStart(function() { $('#qunit-fixture').html('
'); @@ -6,4 +6,4 @@ QUnit.testStart(function() { QUnit.module('Filter Builder markup'); -require('../DevExpress.ui.widgets/filterBuilderParts/markupTests.js'); +import '../DevExpress.ui.widgets/filterBuilderParts/markupTests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/gantt.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/gantt.tests.js index 1be9953591fc..a729ff53a995 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/gantt.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/gantt.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets/gantt.markup.tests.js'); +import '../DevExpress.ui.widgets/gantt.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/localization.intl.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/localization.intl.tests.js index e7d178cf6c91..b76ef02a5a17 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/localization.intl.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/localization.intl.tests.js @@ -1 +1 @@ -require('../DevExpress.localization/localization.intl.tests.js'); +import '../DevExpress.localization/localization.intl.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/lookup.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/lookup.tests.js index ad9f60381275..2117e3c204f0 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/lookup.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/lookup.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/lookup.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/lookup.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/numberBox.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/numberBox.tests.js index 19ef38e94b32..a0a3b0669b1e 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/numberBox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/numberBox.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/numberBox.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/numberBox.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/overlay.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/overlay.tests.js index e522acc25f38..dcb97e2244d4 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/overlay.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/overlay.tests.js @@ -1,6 +1,6 @@ -const $ = require('jquery'); +import $ from 'jquery'; -require('ui/overlay/ui.overlay'); +import 'ui/overlay/ui.overlay'; QUnit.testStart(function() { const markup = '
'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/pivotGrid.test.js b/packages/devextreme/testing/tests/DevExpress.serverSide/pivotGrid.test.js index f77edd20916f..28c2b5db5f05 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/pivotGrid.test.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/pivotGrid.test.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.pivotGrid/pivotGrid.markup.tests.js'); +import '../DevExpress.ui.widgets.pivotGrid/pivotGrid.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/progressBar.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/progressBar.tests.js index eb4872b71ad4..02ef76eea59b 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/progressBar.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/progressBar.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets/progressBar.markup.tests.js'); +import '../DevExpress.ui.widgets/progressBar.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/rangeSlider.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/rangeSlider.tests.js index 79c5b0289c8f..394299a66e6d 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/rangeSlider.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/rangeSlider.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/rangeSlider.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/rangeSlider.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/selectBox.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/selectBox.tests.js index ecc17d5906c9..2182ec5303da 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/selectBox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/selectBox.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/selectBox.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/selectBox.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/slider.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/slider.tests.js index a668a821e87f..ee9f7e4166fd 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/slider.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/slider.tests.js @@ -1,4 +1,4 @@ -const $ = require('jquery'); +import $ from 'jquery'; const SLIDER_HANDLE_CLASS = 'dx-slider-handle'; const TOOLTIP_CLASS = 'dx-tooltip'; @@ -27,5 +27,5 @@ QUnit.test('there is no tooltip in markup on server', function(assert) { assert.notOk($tooltip.length); }); -require('../DevExpress.ui.widgets.editors/slider.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/slider.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/switch.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/switch.tests.js index b91ca3f996d2..87f85ba12381 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/switch.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/switch.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/switch.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/switch.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/tagBox.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/tagBox.tests.js index f710d02b08a8..329ed5c3ec78 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/tagBox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/tagBox.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/tagBox.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/tagBox.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/textArea.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/textArea.tests.js index cf7894744cf6..a6a89cfc7dbd 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/textArea.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/textArea.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/textArea.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/textArea.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/textBox.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/textBox.tests.js index 6a78b3b280f3..1dda1bebd5ff 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/textBox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/textBox.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/textbox.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/textbox.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/textEditor.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/textEditor.tests.js index 830fe319edde..15a76356118b 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/textEditor.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/textEditor.tests.js @@ -4,4 +4,4 @@ QUnit.testStart(function() { document.getElementById('qunit-fixture').innerHTML = markup; }); -require('../DevExpress.ui.widgets.editors/textEditorParts/markup.tests.js'); +import '../DevExpress.ui.widgets.editors/textEditorParts/markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/trackBar.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/trackBar.tests.js index f461dea2be50..b5424648c678 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/trackBar.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/trackBar.tests.js @@ -1,8 +1,8 @@ -require('../DevExpress.ui.widgets.editors/trackBar.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/trackBar.markup.tests.js'; -const $ = require('jquery'); +import $ from 'jquery'; -require('ui/track_bar'); +import 'ui/track_bar'; QUnit.testStart(function() { const markup = diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/treeList.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/treeList.tests.js index a12733657c3a..c8711b637d5f 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/treeList.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/treeList.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.treeList/treeList.markup.tests.js'); +import '../DevExpress.ui.widgets.treeList/treeList.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/utils.ready_callbacks.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/utils.ready_callbacks.tests.js index 31683ada9350..a9d6c21a0d4f 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/utils.ready_callbacks.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/utils.ready_callbacks.tests.js @@ -1,4 +1,4 @@ -const readyCallbacks = require('core/utils/ready_callbacks'); +import readyCallbacks from 'core/utils/ready_callbacks'; QUnit.module('readyCallbacks injection', { afterEach: function() { diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/validationGroup.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/validationGroup.tests.js index add3678c14f1..6bea69aa6175 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/validationGroup.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/validationGroup.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/validationGroup.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/validationGroup.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/validationSummary.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/validationSummary.tests.js index b1a3df75a59e..9ba926ac4497 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/validationSummary.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/validationSummary.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/validationSummary.markup.tests.js'); +import '../DevExpress.ui.widgets.editors/validationSummary.markup.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/validator.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/validator.tests.js index d6eadca67b34..a6305d78403c 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/validator.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/validator.tests.js @@ -1 +1 @@ -require('../DevExpress.ui.widgets.editors/validator.tests.js'); +import '../DevExpress.ui.widgets.editors/validator.tests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.serverSide/widgetsCreation.tests.js b/packages/devextreme/testing/tests/DevExpress.serverSide/widgetsCreation.tests.js index 86030b7adb10..090386d3d9ff 100644 --- a/packages/devextreme/testing/tests/DevExpress.serverSide/widgetsCreation.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.serverSide/widgetsCreation.tests.js @@ -1,6 +1,6 @@ -const widgets = require('../../helpers/widgetsList.js').widgetsList; +import { widgetsList as widgets } from '../../helpers/widgetsList.js'; -const DataSource = require('common/data/data_source'); +import DataSource from 'common/data/data_source'; QUnit.module('Widget creation', { beforeEach: function() { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/contextmenu.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/contextmenu.tests.js index b2fbf79af553..cc79ce03817d 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/contextmenu.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/contextmenu.tests.js @@ -1,9 +1,9 @@ -const $ = require('jquery'); -const noop = require('core/utils/common').noop; -const devices = require('core/devices'); -const support = require('core/utils/support'); -const holdEvent = require('common/core/events/hold'); -const contextMenuEvent = require('common/core/events/contextmenu'); +import $ from 'jquery'; +import { noop } from 'core/utils/common'; +import devices from 'core/devices'; +import * as support from 'core/utils/support'; +import holdEvent from 'common/core/events/hold'; +import * as contextMenuEvent from 'common/core/events/contextmenu'; QUnit.testStart(function() { const markup = diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/dblclick.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/dblclick.tests.js index 0a29dd77b7f3..710bd34ab977 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/dblclick.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/dblclick.tests.js @@ -1,7 +1,7 @@ -const $ = require('jquery'); -const dblclickEvent = require('common/core/events/dblclick'); -const { dblClick } = require('__internal/events/m_dblclick'); -const pointerMock = require('../../helpers/pointerMock.js'); +import $ from 'jquery'; +import dblclickEvent from 'common/core/events/dblclick'; +import { dblClick } from '__internal/events/m_dblclick'; +import pointerMock from '../../helpers/pointerMock.js'; QUnit.testStart(function() { const markup = diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/drag.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/drag.tests.js index 182e9b32063c..cdcad45ebffa 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/drag.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/drag.tests.js @@ -1,10 +1,10 @@ -const $ = require('jquery'); -const noop = require('core/utils/common').noop; -const dragEvents = require('common/core/events/drag'); -const support = require('core/utils/support'); -const GestureEmitter = require('common/core/events/gesture/emitter.gesture'); +import $ from 'jquery'; +import { noop } from 'core/utils/common'; +import * as dragEvents from 'common/core/events/drag'; +import * as support from 'core/utils/support'; +import GestureEmitter from 'common/core/events/gesture/emitter.gesture'; const dropTargets = dragEvents.dropTargets; -const pointerMock = require('../../helpers/pointerMock.js'); +import pointerMock from '../../helpers/pointerMock.js'; $('#qunit-fixture').addClass('qunit-fixture-visible'); QUnit.testStart(function() { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/feedback.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/feedback.tests.js index 6458f0852da3..ee54e87596ba 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/feedback.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/feedback.tests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const noop = require('core/utils/common').noop; -const devices = require('core/devices'); -const feedbackEvents = require('common/core/events/core/emitter.feedback'); -const pointerMock = require('../../helpers/pointerMock.js'); +import $ from 'jquery'; +import { noop } from 'core/utils/common'; +import devices from 'core/devices'; +import * as feedbackEvents from 'common/core/events/core/emitter.feedback'; +import pointerMock from '../../helpers/pointerMock.js'; QUnit.testStart(function() { const markup = diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/hold.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/hold.tests.js index 78a4db9961b1..a00284ee8a34 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/hold.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/hold.tests.js @@ -1,6 +1,6 @@ -const $ = require('jquery'); -const holdEvent = require('common/core/events/hold'); -const pointerMock = require('../../helpers/pointerMock.js'); +import $ from 'jquery'; +import holdEvent from 'common/core/events/hold'; +import pointerMock from '../../helpers/pointerMock.js'; QUnit.testStart(function() { const markup = diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/hover.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/hover.tests.js index a358fb58f39d..791e7fc26416 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/hover.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/hover.tests.js @@ -1,6 +1,6 @@ -const $ = require('jquery'); -const devices = require('core/devices'); -const hoverEvents = require('common/core/events/hover'); +import $ from 'jquery'; +import devices from 'core/devices'; +import * as hoverEvents from 'common/core/events/hover'; QUnit.testStart(function() { const markup = diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/pointer.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/pointer.tests.js index 93b47fdba064..fb85cd963e47 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/pointer.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/pointer.tests.js @@ -1,4 +1,4 @@ -const $ = require('jquery'); +import $ from 'jquery'; QUnit.testStart(function() { const markup = @@ -9,8 +9,8 @@ QUnit.testStart(function() { $('#qunit-fixture').html(markup); }); -require('./pointerParts/baseTests.js'); -require('./pointerParts/mouseTests.js'); -require('./pointerParts/touchTests.js'); -require('./pointerParts/mouseAndTouchTests.js'); -require('./pointerParts/strategySelectionTests.js'); +import './pointerParts/baseTests.js'; +import './pointerParts/mouseTests.js'; +import './pointerParts/touchTests.js'; +import './pointerParts/mouseAndTouchTests.js'; +import './pointerParts/strategySelectionTests.js'; diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/baseTests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/baseTests.js index af476b785267..fdfb40692a7c 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/baseTests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/baseTests.js @@ -1,9 +1,9 @@ -const $ = require('jquery'); -const noop = require('core/utils/common').noop; -const BaseStrategy = require('common/core/events/pointer/base'); -const registerEvent = require('common/core/events/core/event_registrator'); -const typeUtils = require('core/utils/type'); -const special = require('../../../helpers/eventHelper.js').special; +import $ from 'jquery'; +import { noop } from 'core/utils/common'; +import BaseStrategy from 'common/core/events/pointer/base'; +import registerEvent from 'common/core/events/core/event_registrator'; +import * as typeUtils from 'core/utils/type'; +import { special } from '../../../helpers/eventHelper.js'; const BubbledTestEventMap = { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/mouseAndTouchTests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/mouseAndTouchTests.js index ac065b0129b6..9f407cde1721 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/mouseAndTouchTests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/mouseAndTouchTests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const MouseAndTouchStrategy = require('common/core/events/pointer/mouse_and_touch'); -const registerEvent = require('common/core/events/core/event_registrator'); -const nativePointerMock = require('../../../helpers/nativePointerMock.js'); -const special = require('../../../helpers/eventHelper.js').special; +import $ from 'jquery'; +import MouseAndTouchStrategy from 'common/core/events/pointer/mouse_and_touch'; +import registerEvent from 'common/core/events/core/event_registrator'; +import nativePointerMock from '../../../helpers/nativePointerMock.js'; +import { special } from '../../../helpers/eventHelper.js'; QUnit.module('mouse and touch events', { beforeEach: function() { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/mouseTests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/mouseTests.js index 8733017ed2d0..2b69eafcfbec 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/mouseTests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/mouseTests.js @@ -1,8 +1,8 @@ -const $ = require('jquery'); -const MouseStrategy = require('common/core/events/pointer/mouse'); -const registerEvent = require('common/core/events/core/event_registrator'); -const nativePointerMock = require('../../../helpers/nativePointerMock.js'); -const special = require('../../../helpers/eventHelper.js').special; +import $ from 'jquery'; +import MouseStrategy from 'common/core/events/pointer/mouse'; +import registerEvent from 'common/core/events/core/event_registrator'; +import nativePointerMock from '../../../helpers/nativePointerMock.js'; +import { special } from '../../../helpers/eventHelper.js'; QUnit.module('mouse events', { beforeEach: function() { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/touchTests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/touchTests.js index 78cf41582d81..8cc336fa4fb2 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/touchTests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/pointerParts/touchTests.js @@ -1,10 +1,10 @@ -const $ = require('jquery'); -const TouchStrategy = require('common/core/events/pointer/touch'); -const registerEvent = require('common/core/events/core/event_registrator'); -const nativePointerMock = require('../../../helpers/nativePointerMock.js'); -const noop = require('core/utils/common').noop; -const special = require('../../../helpers/eventHelper.js').special; -const eventsEngine = require('common/core/events/core/events_engine'); +import $ from 'jquery'; +import TouchStrategy from 'common/core/events/pointer/touch'; +import registerEvent from 'common/core/events/core/event_registrator'; +import nativePointerMock from '../../../helpers/nativePointerMock.js'; +import { noop } from 'core/utils/common'; +import { special } from '../../../helpers/eventHelper.js'; +import eventsEngine from 'common/core/events/core/events_engine'; QUnit.module('touch events', { beforeEach: function() { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/scroll.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/scroll.tests.js index d80ac13750a1..f4738fd8e668 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/scroll.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/scroll.tests.js @@ -1,12 +1,12 @@ -const $ = require('jquery'); -const noop = require('core/utils/common').noop; -const scrollEvents = require('common/core/events/gesture/emitter.gesture.scroll'); -const GestureEmitter = require('common/core/events/gesture/emitter.gesture'); -const eventUtils = require('common/core/events/utils/index'); -const devices = require('core/devices'); -const compareVersions = require('core/utils/version').compare; -const animationFrame = require('common/core/animation/frame'); -const pointerMock = require('../../helpers/pointerMock.js'); +import $ from 'jquery'; +import { noop } from 'core/utils/common'; +import scrollEvents from 'common/core/events/gesture/emitter.gesture.scroll'; +import GestureEmitter from 'common/core/events/gesture/emitter.gesture'; +import * as eventUtils from 'common/core/events/utils/index'; +import devices from 'core/devices'; +import { compare as compareVersions } from 'core/utils/version'; +import * as animationFrame from 'common/core/animation/frame'; +import pointerMock from '../../helpers/pointerMock.js'; QUnit.testStart(function() { const markup = diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/transformation.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/transformation.tests.js index a0e83e63a5a6..e4422f6b6700 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/transformation.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/transformation.tests.js @@ -1,5 +1,5 @@ -const $ = require('jquery'); -const transformEvent = require('common/core/events/transform'); +import $ from 'jquery'; +import * as transformEvent from 'common/core/events/transform'; $('#qunit-fixture').addClass('qunit-fixture-visible'); QUnit.testStart(function() { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.events/wheel.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.events/wheel.tests.js index f2f68c750db5..57f4ef469f58 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.events/wheel.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.events/wheel.tests.js @@ -1,6 +1,6 @@ -const $ = require('jquery'); -const wheelEvent = require('common/core/events/core/wheel'); -const nativePointerMock = require('../../helpers/nativePointerMock.js'); +import $ from 'jquery'; +import * as wheelEvent from 'common/core/events/core/wheel'; +import nativePointerMock from '../../helpers/nativePointerMock.js'; QUnit.testStart(function() { const markup = From 61e1e367d8fdf5e541c43fb06671725e7bc93626 Mon Sep 17 00:00:00 2001 From: Vladislav Volkov Date: Tue, 18 Aug 2026 13:31:38 +0400 Subject: [PATCH 4/4] Convert CJS imports to ESM (final wave: jquery + remaining helpers) (#34798) --- .../devextreme/testing/helpers/ajaxMock.js | 21 +- .../devextreme/testing/helpers/exportMocks.js | 2 +- .../helpers/renovationScrollViewHelper.js | 10 +- .../helpers/renovationScrollableHelper.js | 8 +- .../helpers/serverSideDOMAdapterPatch.js | 8 +- .../devextreme/testing/helpers/ssrEmulator.js | 4 +- .../devextreme/testing/helpers/trackerMock.js | 15 +- .../devextreme/testing/helpers/widgetsList.js | 234 ++++++++++++------ .../testing/helpers/wrapRenovatedWidget.js | 6 +- packages/devextreme/testing/runner/README.md | 13 +- .../testing/runner/lib/cjsInterop.ts | 108 +------- .../SvgElement.tests.js | 22 +- 12 files changed, 214 insertions(+), 237 deletions(-) diff --git a/packages/devextreme/testing/helpers/ajaxMock.js b/packages/devextreme/testing/helpers/ajaxMock.js index c29c8181937e..462ef5951119 100644 --- a/packages/devextreme/testing/helpers/ajaxMock.js +++ b/packages/devextreme/testing/helpers/ajaxMock.js @@ -1,7 +1,8 @@ -const ajax = require('core/utils/ajax'); -const extend = require('core/utils/extend').extend; -const typeUtils = require('core/utils/type'); -const $ = require('jquery'); +import $ from 'jquery'; +import ajax from 'core/utils/ajax'; +import { extend } from 'core/utils/extend'; +import { isDefined } from 'core/utils/type'; + const originSendRequest = ajax.sendRequest; let urlMap = {}; const timers = []; @@ -20,7 +21,7 @@ const findUrlOptions = function(requestUrl) { } }; -exports.setup = function(options) { +export function setup(options) { urlMap[options.url] = options; ajax.sendRequest = function(request) { @@ -29,7 +30,7 @@ exports.setup = function(options) { const mockOptions = findUrlOptions(request.url); const jQueryTextStatus = mockOptions.jQueryTextStatus; - response.status = typeUtils.isDefined(mockOptions.status) ? mockOptions.status : 200; + response.status = isDefined(mockOptions.status) ? mockOptions.status : 200; response.statusText = mockOptions.statusText || '200 OK'; response.responseText = mockOptions.responseText; @@ -48,12 +49,14 @@ exports.setup = function(options) { return deferred.promise(); }; -}; +} -exports.clear = function() { +export function clear() { ajax.sendRequest = originSendRequest; urlMap = {}; timers.forEach(function(timerId) { clearTimeout(timerId); }); -}; +} + +export default { setup, clear }; diff --git a/packages/devextreme/testing/helpers/exportMocks.js b/packages/devextreme/testing/helpers/exportMocks.js index 9e7f6998f16b..d6eab28c27fc 100644 --- a/packages/devextreme/testing/helpers/exportMocks.js +++ b/packages/devextreme/testing/helpers/exportMocks.js @@ -1,4 +1,4 @@ -const $ = require('jquery'); +import $ from 'jquery'; exports.MockDataProvider = function(data, columns) { data = data || [ diff --git a/packages/devextreme/testing/helpers/renovationScrollViewHelper.js b/packages/devextreme/testing/helpers/renovationScrollViewHelper.js index c64026d17a8e..64c7d0e96760 100644 --- a/packages/devextreme/testing/helpers/renovationScrollViewHelper.js +++ b/packages/devextreme/testing/helpers/renovationScrollViewHelper.js @@ -1,9 +1,9 @@ -const RenovatedScrollView = require('renovation/ui/scroll_view/scroll_view.j.js'); +import RenovatedScrollView from 'renovation/ui/scroll_view/scroll_view.j.js'; // eslint-disable-next-line spellcheck/spell-checker -const reRender = require('inferno').rerender; -const Deferred = require('core/utils/deferred').Deferred; +import { rerender as reRender } from 'inferno'; +import { Deferred } from 'core/utils/deferred'; -exports.WrappedWidget = class WrappedWidget extends RenovatedScrollView { +export class WrappedWidget extends RenovatedScrollView { _initMarkup() { super._initMarkup.apply(this, arguments); @@ -82,4 +82,4 @@ exports.WrappedWidget = class WrappedWidget extends RenovatedScrollView { return new Deferred().resolve(); } -}; +} diff --git a/packages/devextreme/testing/helpers/renovationScrollableHelper.js b/packages/devextreme/testing/helpers/renovationScrollableHelper.js index a40b168a796a..62e25aa7b735 100644 --- a/packages/devextreme/testing/helpers/renovationScrollableHelper.js +++ b/packages/devextreme/testing/helpers/renovationScrollableHelper.js @@ -1,8 +1,8 @@ -const RenovatedScrollable = require('renovation/ui/scroll_view/scrollable.j.js'); +import RenovatedScrollable from 'renovation/ui/scroll_view/scrollable.j.js'; // eslint-disable-next-line spellcheck/spell-checker -const reRender = require('inferno').rerender; +import { rerender as reRender } from 'inferno'; -exports.WrappedWidget = class WrappedWidget extends RenovatedScrollable { +export class WrappedWidget extends RenovatedScrollable { _initMarkup() { super._initMarkup.apply(this, arguments); @@ -59,4 +59,4 @@ exports.WrappedWidget = class WrappedWidget extends RenovatedScrollable { super.scrollToElement.apply(this, arguments); reRender(); } -}; +} diff --git a/packages/devextreme/testing/helpers/serverSideDOMAdapterPatch.js b/packages/devextreme/testing/helpers/serverSideDOMAdapterPatch.js index d5cdcebf932a..17fefbb7f08a 100644 --- a/packages/devextreme/testing/helpers/serverSideDOMAdapterPatch.js +++ b/packages/devextreme/testing/helpers/serverSideDOMAdapterPatch.js @@ -1,5 +1,5 @@ -const domAdapter = require('core/dom_adapter'); -const readyCallbacks = require('core/utils/ready_callbacks'); +import domAdapter from 'core/dom_adapter'; +import readyCallbacks from 'core/utils/ready_callbacks'; const documentMock = (function() { const documentMock = { @@ -20,7 +20,7 @@ const documentMock = (function() { return documentMock; })(); -exports.set = function() { +export function set() { // Emulate Angular DOM Adapter considering it's restricitons domAdapter.inject({ // `document` should be used only as is @@ -73,4 +73,4 @@ exports.set = function() { // Ready callbacks should be fired by the integration readyCallbacks.fire(); -}; +} diff --git a/packages/devextreme/testing/helpers/ssrEmulator.js b/packages/devextreme/testing/helpers/ssrEmulator.js index 80b30943691b..59c00165506b 100644 --- a/packages/devextreme/testing/helpers/ssrEmulator.js +++ b/packages/devextreme/testing/helpers/ssrEmulator.js @@ -1,6 +1,6 @@ import domAdapter from '__internal/core/m_dom_adapter'; import windowUtils from 'core/utils/window'; -import serverSideDOMAdapter from './serverSideDOMAdapterPatch.js'; +import { set as setServerSideDOMAdapter } from './serverSideDOMAdapterPatch.js'; (function emulateNoContains() { const originalContains = Element.prototype.contains; @@ -229,5 +229,5 @@ QUnit.begin(function() { // Now domAdapter is allowed to use restoreOriginalDomAdapter(); // Emulate DOMAdapter integration - serverSideDOMAdapter.set(); + setServerSideDOMAdapter(); }); diff --git a/packages/devextreme/testing/helpers/trackerMock.js b/packages/devextreme/testing/helpers/trackerMock.js index 3a930364f4d5..70c00a82ab46 100644 --- a/packages/devextreme/testing/helpers/trackerMock.js +++ b/packages/devextreme/testing/helpers/trackerMock.js @@ -1,15 +1,14 @@ -const vizMocks = require('./vizMocks.js'); +import { stubClass } from './vizMocks.js'; // Mutate the import-map facade (see esm-shims/viz_chart_tracker.js). -const trackerModule = require('viz/chart_components/tracker'); +import trackerModule from 'viz/chart_components/tracker'; -const ChartTrackerStub = vizMocks.stubClass(trackerModule.ChartTracker); -const PieTrackerStub = vizMocks.stubClass(trackerModule.PieTracker); +const ChartTrackerStub = stubClass(trackerModule.ChartTracker); +const PieTrackerStub = stubClass(trackerModule.PieTracker); trackerModule.ChartTracker = sinon.spy((parameters) => new ChartTrackerStub(parameters)); trackerModule.PieTracker = sinon.spy((parameters) => new PieTrackerStub(parameters)); -exports.default = trackerModule; -exports.__esModule = true; +export default trackerModule; -exports.ChartTracker = trackerModule.ChartTracker; -exports.PieTracker = trackerModule.PieTracker; +export const ChartTracker = trackerModule.ChartTracker; +export const PieTracker = trackerModule.PieTracker; diff --git a/packages/devextreme/testing/helpers/widgetsList.js b/packages/devextreme/testing/helpers/widgetsList.js index 39a55a632040..eaf7b2dc9221 100644 --- a/packages/devextreme/testing/helpers/widgetsList.js +++ b/packages/devextreme/testing/helpers/widgetsList.js @@ -1,87 +1,159 @@ +import Accordion from 'ui/accordion'; +import ActionSheet from 'ui/action_sheet'; +import Autocomplete from 'ui/autocomplete'; +import BarGauge from 'viz/bar_gauge'; +import Box from 'ui/box'; +import Bullet from 'viz/bullet'; +import Button from 'ui/button'; +import Calendar from 'ui/calendar'; +import Chart from 'viz/chart'; +import CheckBox from 'ui/check_box'; +import CircularGauge from 'viz/circular_gauge'; +import ColorBox from 'ui/color_box'; +import ContextMenu from 'ui/context_menu'; +import DataGrid from 'ui/data_grid'; +import DateBox from 'ui/date_box'; +import DateRangeBox from 'ui/date_range_box'; +import Drawer from 'ui/drawer'; +import DropDownBox from 'ui/drop_down_box'; +import FileManager from 'ui/file_manager'; +import FileUploader from 'ui/file_uploader'; +import FilterBuilder from 'ui/filter_builder'; +import Form from 'ui/form'; +import Funnel from 'viz/funnel'; +import Gallery from 'ui/gallery'; +import Gantt from 'ui/gantt'; +import HtmlEditor from 'ui/html_editor'; +import LinearGauge from 'viz/linear_gauge'; +import List from 'ui/list'; +import LoadIndicator from 'ui/load_indicator'; +import LoadPanel from 'ui/load_panel'; +import Lookup from 'ui/lookup'; +import Map from 'ui/map'; +import Menu from 'ui/menu'; +import MultiView from 'ui/multi_view'; +import NumberBox from 'ui/number_box'; +import PieChart from 'viz/pie_chart'; +import PivotGrid from 'ui/pivot_grid'; +import PivotGridFieldChooser from 'ui/pivot_grid_field_chooser'; +import PolarChart from 'viz/polar_chart'; +import Popover from 'ui/popover'; +import Popup from 'ui/popup'; +import ProgressBar from 'ui/progress_bar'; +import RangeSelector from 'viz/range_selector'; +import RangeSlider from 'ui/range_slider'; +import RadioGroup from 'ui/radio_group'; +import Resizable from 'ui/resizable'; +import ResponsiveBox from 'ui/responsive_box'; +import Sankey from 'viz/sankey'; +import Scheduler from 'ui/scheduler'; +import ScrollView from 'ui/scroll_view'; +import SelectBox from 'ui/select_box'; +import Slider from 'ui/slider'; +import Sparkline from 'viz/sparkline'; +import Switch from 'ui/switch'; +import TabPanel from 'ui/tab_panel'; +import Tabs from 'ui/tabs'; +import TagBox from 'ui/tag_box'; +import TextArea from 'ui/text_area'; +import TextBox from 'ui/text_box'; +import TileView from 'ui/tile_view'; +import Toast from 'ui/toast'; +import Toolbar from 'ui/toolbar'; +import Tooltip from 'ui/tooltip'; +import TreeList from 'ui/tree_list'; +import TreeMap from 'viz/tree_map'; +import TreeView from 'ui/tree_view'; +import ValidationGroup from 'ui/validation_group'; +import ValidationSummary from 'ui/validation_summary'; +import VectorMap from 'viz/vector_map'; +import DropDownButton from 'ui/drop_down_button'; +import DxDropDownEditor from 'ui/drop_down_editor/ui.drop_down_editor'; +import DxDropDownList from 'ui/drop_down_editor/ui.drop_down_list'; + const widgetsList = { - Accordion: require('ui/accordion'), - ActionSheet: require('ui/action_sheet'), - Autocomplete: require('ui/autocomplete'), - BarGauge: require('viz/bar_gauge'), - Box: require('ui/box'), - Bullet: require('viz/bullet'), - Button: require('ui/button'), - Calendar: require('ui/calendar'), - Chart: require('viz/chart'), - CheckBox: require('ui/check_box'), - CircularGauge: require('viz/circular_gauge'), - ColorBox: require('ui/color_box'), - ContextMenu: require('ui/context_menu'), - DataGrid: require('ui/data_grid'), - DateBox: require('ui/date_box'), - DateRangeBox: require('ui/date_range_box'), - Drawer: require('ui/drawer'), - DropDownBox: require('ui/drop_down_box'), - FileManager: require('ui/file_manager'), - FileUploader: require('ui/file_uploader'), - FilterBuilder: require('ui/filter_builder'), - Form: require('ui/form'), - Funnel: require('viz/funnel'), - Gallery: require('ui/gallery'), - Gantt: require('ui/gantt'), - HtmlEditor: require('ui/html_editor'), - LinearGauge: require('viz/linear_gauge'), - List: require('ui/list'), - LoadIndicator: require('ui/load_indicator'), - LoadPanel: require('ui/load_panel'), - Lookup: require('ui/lookup'), - Map: require('ui/map'), - Menu: require('ui/menu'), - MultiView: require('ui/multi_view'), - NumberBox: require('ui/number_box'), - PieChart: require('viz/pie_chart'), - PivotGrid: require('ui/pivot_grid'), - PivotGridFieldChooser: require('ui/pivot_grid_field_chooser'), - PolarChart: require('viz/polar_chart'), - Popover: require('ui/popover'), - Popup: require('ui/popup'), - ProgressBar: require('ui/progress_bar'), - RangeSelector: require('viz/range_selector'), - RangeSlider: require('ui/range_slider'), - RadioGroup: require('ui/radio_group'), - Resizable: require('ui/resizable'), - ResponsiveBox: require('ui/responsive_box'), - Sankey: require('viz/sankey'), - Scheduler: require('ui/scheduler'), - ScrollView: require('ui/scroll_view'), - SelectBox: require('ui/select_box'), - Slider: require('ui/slider'), - Sparkline: require('viz/sparkline'), - Switch: require('ui/switch'), - TabPanel: require('ui/tab_panel'), - Tabs: require('ui/tabs'), - TagBox: require('ui/tag_box'), - TextArea: require('ui/text_area'), - TextBox: require('ui/text_box'), - TileView: require('ui/tile_view'), - Toast: require('ui/toast'), - Toolbar: require('ui/toolbar'), - Tooltip: require('ui/tooltip'), - TreeList: require('ui/tree_list'), - TreeMap: require('viz/tree_map'), - TreeView: require('ui/tree_view'), - ValidationGroup: require('ui/validation_group'), - ValidationSummary: require('ui/validation_summary'), - VectorMap: require('viz/vector_map') + Accordion, + ActionSheet, + Autocomplete, + BarGauge, + Box, + Bullet, + Button, + Calendar, + Chart, + CheckBox, + CircularGauge, + ColorBox, + ContextMenu, + DataGrid, + DateBox, + DateRangeBox, + Drawer, + DropDownBox, + FileManager, + FileUploader, + FilterBuilder, + Form, + Funnel, + Gallery, + Gantt, + HtmlEditor, + LinearGauge, + List, + LoadIndicator, + LoadPanel, + Lookup, + Map, + Menu, + MultiView, + NumberBox, + PieChart, + PivotGrid, + PivotGridFieldChooser, + PolarChart, + Popover, + Popup, + ProgressBar, + RangeSelector, + RangeSlider, + RadioGroup, + Resizable, + ResponsiveBox, + Sankey, + Scheduler, + ScrollView, + SelectBox, + Slider, + Sparkline, + Switch, + TabPanel, + Tabs, + TagBox, + TextArea, + TextBox, + TileView, + Toast, + Toolbar, + Tooltip, + TreeList, + TreeMap, + TreeView, + ValidationGroup, + ValidationSummary, + VectorMap }; const dropDownEditorsList = { - dxAutocomplete: require('ui/autocomplete'), - dxColorBox: require('ui/color_box'), - dxDateBox: require('ui/date_box'), - dxDateRangeBox: require('ui/date_range_box'), - dxDropDownBox: require('ui/drop_down_box'), - dxDropDownButton: require('ui/drop_down_button'), - dxSelectBox: require('ui/select_box'), - dxTagBox: require('ui/tag_box'), - dxDropDownEditor: require('ui/drop_down_editor/ui.drop_down_editor'), - dxDropDownList: require('ui/drop_down_editor/ui.drop_down_list'), + dxAutocomplete: Autocomplete, + dxColorBox: ColorBox, + dxDateBox: DateBox, + dxDateRangeBox: DateRangeBox, + dxDropDownBox: DropDownBox, + dxDropDownButton: DropDownButton, + dxSelectBox: SelectBox, + dxTagBox: TagBox, + dxDropDownEditor: DxDropDownEditor, + dxDropDownList: DxDropDownList, }; -exports.widgetsList = widgetsList; -exports.dropDownEditorsList = dropDownEditorsList; +export { widgetsList, dropDownEditorsList }; diff --git a/packages/devextreme/testing/helpers/wrapRenovatedWidget.js b/packages/devextreme/testing/helpers/wrapRenovatedWidget.js index 318697106789..6de4bb42ab62 100644 --- a/packages/devextreme/testing/helpers/wrapRenovatedWidget.js +++ b/packages/devextreme/testing/helpers/wrapRenovatedWidget.js @@ -1,7 +1,7 @@ // eslint-disable-next-line spellcheck/spell-checker -const reRender = require('inferno').rerender; +import { rerender as reRender } from 'inferno'; -exports.wrapRenovatedWidget = function wrapRenovatedWidget(renovatedWidget) { +export function wrapRenovatedWidget(renovatedWidget) { class WrappedWidget extends renovatedWidget { callMethod(name, ...args) { const result = super[name](...args); @@ -28,4 +28,4 @@ exports.wrapRenovatedWidget = function wrapRenovatedWidget(renovatedWidget) { const result = WrappedWidget; result.IS_RENOVATED_WIDGET = true; return result; -}; +} diff --git a/packages/devextreme/testing/runner/README.md b/packages/devextreme/testing/runner/README.md index 825019920821..e35639ae1ce2 100644 --- a/packages/devextreme/testing/runner/README.md +++ b/packages/devextreme/testing/runner/README.md @@ -37,16 +37,15 @@ This module is the integration point: almost every special-case rewrite for QUni Serve-time **CJS → ESM** source rewrites for QUnit tests, helpers, and bundle templates. -Legacy suites still use `require()`, `module.exports` / `exports.*`, AMD `define(function () { … })`, and CJS-style `import x from 'bare-specifier'`. Native ESM cannot load those as-is. +`testing/tests/**` and `testing/helpers/**` are now fully native ESM (no `require()`/`module.exports`/AMD left) — the CJS/AMD rewrites below only still fire for `build/bundle-templates/**` (bundler-input sources, out of scope for the QUnit migration). CJS-style `import x from 'bare-specifier'` (bare default/named imports on modules with an imperfect export shape) is still common everywhere and always rewritten, except `jquery` — its shim has a real `export default $`, so it's excluded and loads natively. **What it does:** -1. **`require('…')`** → hoisted `import * as __dxReq_N` plus `('default' in ns ? ns.default : { …ns })` at the call site (keeps explicit `default: null` for noJQuery/…; mutable shallow copy only when there is no default — needed when tests assign onto the module object). -2. **`module.exports` / `exports.*`** → wrap the file with a synthetic `module`/`exports` object and emit `export default` + named exports. -3. **Bare default / named imports** → namespace import + CJS default interop (`'default' in ns ? ns.default : …`, merge default object/function into named bindings when needed). -4. **AMD `define(function () { … })`** → IIFE, with imports hoisted to file top (imports inside `if (define.amd)` are illegal in ESM). -5. **Plugin-style JSON** (`file.json!` / `file.json!json`) → absolute URLs with `?esm-export=1`. -6. **`aspnet.js`** → dedicated UMD → ESM conversion (`rewriteAspnetArtifactToEsm`). +1. **`require('…')`** (bundle templates only) → hoisted `import * as __dxReq_N` plus `('default' in ns ? ns.default : { …ns })` at the call site (keeps explicit `default: null` for noJQuery/…; mutable shallow copy only when there is no default — needed when tests assign onto the module object). +2. **`module.exports` / `exports.*`** (bundle templates only) → wrap the file with a synthetic `module`/`exports` object and emit `export default` + named exports. +3. **Bare default / named imports** → namespace import + CJS default interop (`'default' in ns ? ns.default : …`, merge default object/function into named bindings when needed); `jquery` is excluded and passes through untouched. +4. **Plugin-style JSON** (`file.json!` / `file.json!json`, bundle templates only) → absolute URLs with `?esm-export=1`. +5. **`aspnet.js`** → dedicated UMD → ESM conversion (`rewriteAspnetArtifactToEsm`). `esm-shims/` files are **excluded** from this pipeline (`isQunitTestOrHelperPath`) — they are already real ESM. diff --git a/packages/devextreme/testing/runner/lib/cjsInterop.ts b/packages/devextreme/testing/runner/lib/cjsInterop.ts index b55e6883f064..caaed4d983da 100644 --- a/packages/devextreme/testing/runner/lib/cjsInterop.ts +++ b/packages/devextreme/testing/runner/lib/cjsInterop.ts @@ -2,8 +2,11 @@ * Serve-time CJS → ESM helpers for QUnit tests/helpers under native ESM. * * 1) `import x from 'mod'` → namespace + `'default' in ns ? ns.default : {…ns}` - * 2) `require(...)` → equivalent ESM imports + * (skipped for `jquery` — its shim has a real `export default $`) + * 2) `require(...)` → equivalent ESM imports (only fires for `build/bundle-templates/` + * sources now — `testing/tests/**`/`testing/helpers/**` are require()-free) * 3) CJS `module.exports` / `exports.*` → `export default` + named exports + * (same: bundle-templates only) */ const MIXED_DEFAULT_NAMED_RE = /import\s+([A-Za-z_$][\w$]*)\s*,\s*(\{[^}]*\})\s*from\s*('[^']+'|"[^"]+")/g; @@ -118,59 +121,6 @@ function isOffsetInsideComment(source: string, offset: number): boolean { return false; } -/** - * Index of the matching `}` for `{` at `openIndex`, skipping strings, - * template literals, and comments. - */ -function findMatchingBrace(source: string, openIndex: number): number { - if (source[openIndex] !== '{') { - return -1; - } - - let depth = 0; - let i = openIndex; - while (i < source.length) { - if (source.startsWith('/*', i)) { - const end = source.indexOf('*/', i + 2); - i = end < 0 ? source.length : end + 2; - } else if (source.startsWith('//', i)) { - const end = source.indexOf('\n', i); - i = end < 0 ? source.length : end + 1; - } else { - const ch = source[i]; - if (ch === '"' || ch === '\'') { - i = skipQuotedString(source, i); - } else if (ch === '`') { - i += 1; - while (i < source.length) { - if (source[i] === '\\') { - i += 2; - } else if (source[i] === '`') { - i += 1; - break; - } else if (source[i] === '$' && source[i + 1] === '{') { - const innerClose = findMatchingBrace(source, i + 1); - i = innerClose < 0 ? source.length : innerClose + 1; - } else { - i += 1; - } - } - } else { - if (ch === '{') { - depth += 1; - } else if (ch === '}') { - depth -= 1; - if (depth === 0) { - return i; - } - } - i += 1; - } - } - } - return -1; -} - /** * Plugin-style json specs (`file.json!` / `file.json!json`) must not stay as * bare specifiers under a package prefix map — browsers resolve @@ -372,49 +322,6 @@ function hoistImportsFromSource(source: string): { imports: string[]; body: stri }; } -function rewriteAmdDefineFactory(source: string): string { - const defineStartRe = /define\s*\(\s*function\s*\([^)]*\)\s*\{/g; - const hoistedImports: string[] = []; - let next = ''; - let lastIndex = 0; - let match = defineStartRe.exec(source); - - // Replace define(function () { ... }) with an IIFE; hoist imports to file top - // (imports inside `if (define.amd)` are a SyntaxError under native ESM). - while (match) { - const openBrace = match.index + match[0].length - 1; - const closeBrace = findMatchingBrace(source, openBrace); - if (closeBrace < 0) { - break; - } - - let end = closeBrace + 1; - const after = /^\s*\)\s*;?/.exec(source.slice(end)); - if (after) { - end += after[0].length; - } - - next += source.slice(lastIndex, match.index); - const body = source.slice(openBrace + 1, closeBrace); - // One pass only — do not mix mid-body `import` insertion (duplicates bindings). - const rewrittenBody = rewriteRequiresToEsm(body); - const { imports, body: bodyScript } = hoistImportsFromSource(rewrittenBody); - hoistedImports.push(...imports); - next += `(function() {\n${bodyScript}\n})();`; - lastIndex = end; - defineStartRe.lastIndex = end; - match = defineStartRe.exec(source); - } - - next += source.slice(lastIndex); - - if (!hoistedImports.length) { - return next; - } - - return `${[...new Set(hoistedImports)].join('\n')}\n${next}`; -} - /** Collect `exports.foo` / `module.exports.foo` assignment names for ESM named re-exports. */ function collectCjsExportNames(source: string): string[] { const names = new Set(); @@ -503,8 +410,7 @@ ${namedExports ? `${namedExports}\n` : ''}`; export function rewriteQunitTestHelperSource(source: string, sourcePath?: string): string { resetRewriteCounters(); - let next = rewriteAmdDefineFactory(source); - next = normalizeBundleTemplateRelativeEsmSpecifiers(next, sourcePath); + let next = normalizeBundleTemplateRelativeEsmSpecifiers(source, sourcePath); next = rewriteRequiresToEsm(next, sourcePath); next = wrapCjsModuleExports(next, sourcePath); next = rewriteCjsStyleDefaultImports(next); @@ -541,7 +447,7 @@ export function rewriteAspnetArtifactToEsm(source: string, sourcePath?: string): let body = source.slice(match.index + match[0].length); body = body.replace(/\}\)\s*;?\s*$/, ''); - return `import * as __dxAspnetJquery from 'jquery'; + return `import __dxAspnetJquery from 'jquery'; import * as __dxAspnetTemplateEngineRegistry from './core/templates/template_engine_registry'; import * as __dxAspnetTemplateBase from './core/templates/template_base'; import * as __dxAspnetGuid from './core/guid'; @@ -556,7 +462,7 @@ ${body} }; const __dxAspnet = __dxAspnetFactory( - ${cjsDefaultExpr('__dxAspnetJquery')}, + __dxAspnetJquery, __dxAspnetTemplateEngineRegistry.setTemplateEngine, __dxAspnetTemplateBase.renderedCallbacks, ${cjsDefaultExpr('__dxAspnetGuid')}, diff --git a/packages/devextreme/testing/tests/DevExpress.viz.renderers/SvgElement.tests.js b/packages/devextreme/testing/tests/DevExpress.viz.renderers/SvgElement.tests.js index b86cd6bc5562..983aef44d59a 100644 --- a/packages/devextreme/testing/tests/DevExpress.viz.renderers/SvgElement.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.viz.renderers/SvgElement.tests.js @@ -562,12 +562,11 @@ function checkDashStyle(assert, elem, result, style, value) { this.Element = renderer.SvgElement; - this.jQuery = $; - $ = coreRenderer; + this.$ = coreRenderer; this.eventsEngine = eventsEngine; this.rendererStub = { fake: 'fake', root: { element: document.createElement('div') } }; - this.$emptyStub = sinon.stub($.fn, 'empty'); - this.$removeStub = sinon.stub($.fn, 'remove').callsFake(function() { return this; }); + this.$emptyStub = sinon.stub(this.$.fn, 'empty'); + this.$removeStub = sinon.stub(this.$.fn, 'remove').callsFake(function() { return this; }); this.$onStub = sinon.stub(this.eventsEngine, 'on'); this.$offStub = sinon.stub(this.eventsEngine, 'off'); this.$triggerStub = sinon.stub(this.eventsEngine, 'trigger'); @@ -578,7 +577,6 @@ function checkDashStyle(assert, elem, result, style, value) { this.$onStub.restore(); this.$offStub.restore(); this.$triggerStub.restore(); - $ = this.jQuery; } }); @@ -588,8 +586,8 @@ function checkDashStyle(assert, elem, result, style, value) { const result = elem.clear(); assert.equal(result, elem); - assert.ok($.fn.empty.calledOnce); - assert.equal($.fn.empty.firstCall.thisValue.get(0), $(elem.element).get(0)); + assert.ok(this.$.fn.empty.calledOnce); + assert.equal(this.$.fn.empty.firstCall.thisValue.get(0), this.$(elem.element).get(0)); }); QUnit.test('Disposing', function(assert) { @@ -598,8 +596,8 @@ function checkDashStyle(assert, elem, result, style, value) { const result = elem.dispose(); assert.equal(result, elem); - assert.ok($.fn.remove.calledOnce); - assert.equal($.fn.remove.firstCall.thisValue.get(0), $(elem.element).get(0)); + assert.ok(this.$.fn.remove.calledOnce); + assert.equal(this.$.fn.remove.firstCall.thisValue.get(0), this.$(elem.element).get(0)); }); QUnit.test('On', function(assert) { @@ -610,7 +608,7 @@ function checkDashStyle(assert, elem, result, style, value) { assert.equal(result, elem); assert.ok(this.eventsEngine.on.calledOnce); assert.deepEqual(this.eventsEngine.on.firstCall.args.slice(1), [1, 2, 3, 4]); - assert.equal(this.eventsEngine.on.firstCall.args[0].get(0), $(elem.element).get(0)); + assert.equal(this.eventsEngine.on.firstCall.args[0].get(0), this.$(elem.element).get(0)); }); QUnit.test('Off', function(assert) { @@ -622,7 +620,7 @@ function checkDashStyle(assert, elem, result, style, value) { assert.ok(this.eventsEngine.off.calledOnce); assert.deepEqual(this.eventsEngine.off.firstCall.args.slice(1), [1, 2, 3, 4]); - assert.equal(this.eventsEngine.off.firstCall.args[0].get(0), $(elem.element).get(0)); + assert.equal(this.eventsEngine.off.firstCall.args[0].get(0), this.$(elem.element).get(0)); }); QUnit.test('Trigger', function(assert) { @@ -635,7 +633,7 @@ function checkDashStyle(assert, elem, result, style, value) { assert.ok(this.eventsEngine.trigger.calledOnce); assert.deepEqual(this.eventsEngine.trigger.firstCall.args.slice(1), [1, 2, 3, 4]); assert.equal(this.eventsEngine.trigger.firstCall.args[0].length, 1); - assert.equal(this.eventsEngine.trigger.firstCall.args[0].get(0), $(elem.element).get(0)); + assert.equal(this.eventsEngine.trigger.firstCall.args[0].get(0), this.$(elem.element).get(0)); }); QUnit.module('SvgElement. attr API, set attrs', {