diff --git a/src/shared/modules/__tests__/helpers.test.ts b/src/shared/modules/__tests__/helpers.test.ts index b8a3b74..1d6c27b 100644 --- a/src/shared/modules/__tests__/helpers.test.ts +++ b/src/shared/modules/__tests__/helpers.test.ts @@ -6,7 +6,6 @@ import { pickExceptActionParamsFromParams, transformParamsToActionParams, } from '../helpers'; -import {getItemsParams} from '../state-and-params'; const DEFAULT_CONTROL_ID = 'controlId'; const DEFAULT_WIDGET_ID = 'widgetId'; @@ -94,149 +93,6 @@ const exeptActionParam3 = { }, }; -const config = { - id: '7kw', - items: [ - { - id: 'nvp', - data: { - tabs: [ - { - id: 'rkq', - title: 'test', - params: {}, - chartId: 'some-chart', - isDefault: true, - autoHeight: false, - description: '', - enableActionParams: true, - }, - ], - hideTitle: true, - }, - type: 'widget', - layout: { - h: 12, - w: 12, - }, - namespace: 'default', - }, - { - id: 'Q9K', - data: { - title: 'Year', - source: {}, - }, - type: 'control', - layout: { - h: 2, - w: 8, - }, - defaults: { - year_some_id: '', - }, - namespace: 'default', - }, - ], - title: 'test', - layout: [ - { - h: 12, - i: 'nvp', - w: 12, - x: 0, - y: 0, - }, - { - h: 2, - i: 'Q9K', - w: 8, - x: 12, - y: 0, - }, - ], - aliases: {}, - connections: [], - salt: '123', - counter: 1, -}; -const itemsStateAndParamsActionParamTest1 = { - nvp: { - params: { - _ap_year_some_id: ['2022'], - }, - }, - __meta__: { - queue: [ - { - id: 'nvp', - tabId: 'rkq', - }, - ], - version: 2, - }, -}; - -const stateAndParamsActionParamsRes1 = { - Q9K: { - year_some_id: ['2022'], - }, - nvp: { - _ap_year_some_id: ['2022'], - year_some_id: '', - }, -}; - -const plugins = [ - { - type: 'title', - defaultLayout: { - x: 0, - y: null, - w: 36, - h: 2, - minW: 4, - minH: 2, - }, - }, - { - type: 'text', - defaultLayout: { - x: 0, - y: null, - w: 12, - h: 6, - minW: 4, - minH: 2, - }, - }, - { - getDistincts: { - promise: {}, - }, - type: 'control', - defaultLayout: { - x: 0, - y: null, - w: 8, - h: 2, - minW: 4, - minH: 2, - }, - }, - { - type: 'widget', - defaultLayout: { - x: 0, - y: null, - w: 12, - h: 12, - minW: 4, - minH: 2, - }, - }, -]; - const getMockedWidgetItem = ({id = DEFAULT_WIDGET_ID, tabs}: MockedWidgetItemArgs): ConfigItem => ({ id, data: {tabs}, @@ -508,17 +364,4 @@ describe('modules.helpers', () => { ); }); }); - - describe('state and params with actionParams', () => { - it('check state 1', () => { - const res = getItemsParams({ - defaultGlobalParams: {}, - globalParams: {}, - config, - itemsStateAndParams: itemsStateAndParamsActionParamTest1, - plugins, - }); - expect(res).toEqual(stateAndParamsActionParamsRes1); - }); - }); }); diff --git a/src/shared/units/__tests__/state-and-params.test.ts b/src/shared/units/__tests__/state-and-params.test.ts index 37531c0..6117e11 100644 --- a/src/shared/units/__tests__/state-and-params.test.ts +++ b/src/shared/units/__tests__/state-and-params.test.ts @@ -599,3 +599,148 @@ describe('getItemsStateAndParams actionParams variants check', () => { }); }); }); + +const config = { + id: '7kw', + items: [ + { + id: 'nvp', + data: { + tabs: [ + { + id: 'rkq', + title: 'test', + params: {}, + chartId: 'some-chart', + isDefault: true, + autoHeight: false, + description: '', + enableActionParams: true, + }, + ], + hideTitle: true, + }, + type: 'widget', + layout: { + h: 12, + w: 12, + }, + namespace: 'default', + }, + { + id: 'Q9K', + data: { + title: 'Year', + source: {}, + }, + type: 'control', + layout: { + h: 2, + w: 8, + }, + defaults: { + year_some_id: '', + }, + namespace: 'default', + }, + ], + title: 'test', + layout: [ + { + h: 12, + i: 'nvp', + w: 12, + x: 0, + y: 0, + }, + { + h: 2, + i: 'Q9K', + w: 8, + x: 12, + y: 0, + }, + ], + aliases: {}, + connections: [], + salt: '123', + counter: 1, +}; +const itemsStateAndParamsActionParamTest1 = { + nvp: { + params: { + _ap_year_some_id: ['2022'], + }, + }, + __meta__: { + queue: [ + { + id: 'nvp', + tabId: 'rkq', + }, + ], + version: 2, + }, +}; +const stateAndParamsActionParamsRes1 = { + Q9K: { + year_some_id: ['2022'], + }, + nvp: { + _ap_year_some_id: ['2022'], + year_some_id: '', + }, +}; + +const itemsStateAndParamsActionParamTest2 = { + nvp: { + params: { + _ap_another: ['2022'], + }, + }, + __meta__: { + queue: [ + { + id: 'nvp', + tabId: 'rkq', + }, + ], + version: 2, + }, +}; + +const stateAndParamsActionParamsRes2 = { + Q9K: { + params: { + year_some_id: ['2022'], + }, + state: {}, + }, + nvp: { + params: { + _ap_year_some_id: ['2022'], + year_some_id: '', + }, + state: {}, + }, +}; + +describe('state and params with actionParams', () => { + it('check state', () => { + const res1 = getItemsStateAndParamsDL({ + defaultGlobalParams: {}, + globalParams: {}, + config, + itemsStateAndParams: itemsStateAndParamsActionParamTest1, + }); + expect(res1).toEqual(stateAndParamsActionParamsRes1); + + const res2 = getItemsStateAndParamsDL({ + defaultGlobalParams: {}, + globalParams: {}, + config, + itemsStateAndParams: itemsStateAndParamsActionParamTest2, + }); + expect(res2).toEqual(stateAndParamsActionParamsRes2); + }); +});