From 7d967d289d2f8a8a97ac0713ce05853b227024e0 Mon Sep 17 00:00:00 2001 From: mohamedsalem401 Date: Tue, 7 Jan 2025 14:09:31 +0200 Subject: [PATCH] Update tests for collection symbols --- .../CollectionComponent.ts | 57 ++++++++++++------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/packages/core/test/specs/data_sources/model/collection_component/CollectionComponent.ts b/packages/core/test/specs/data_sources/model/collection_component/CollectionComponent.ts index 983624cfd..685fccffa 100644 --- a/packages/core/test/specs/data_sources/model/collection_component/CollectionComponent.ts +++ b/packages/core/test/specs/data_sources/model/collection_component/CollectionComponent.ts @@ -1,3 +1,4 @@ +import { isSymbol } from 'underscore'; import { Component, DataSource, DataSourceManager } from '../../../../../src'; import { DataVariableType } from '../../../../../src/data_sources/model/DataVariable'; import { @@ -5,8 +6,10 @@ import { CollectionVariableType, } from '../../../../../src/data_sources/model/collection_component/constants'; import { CollectionStateVariableType } from '../../../../../src/data_sources/model/collection_component/types'; +import { keySymbol } from '../../../../../src/dom_components/model/Component'; import EditorModel from '../../../../../src/editor/model/Editor'; import { filterObjectForSnapshot, setupTestEditor } from '../../../../common'; +import { getSymbolMain, getSymbolTop } from '../../../../../src/dom_components/model/SymbolUtils'; describe('Collection component', () => { let em: EditorModel; @@ -31,37 +34,53 @@ describe('Collection component', () => { em.destroy(); }); - test('Should be undroppable', () => { + test('Should be undroppable', () => { const cmp = wrapper.components({ type: CollectionComponentType, + collectionDefinition: { + block: { + type: 'default', + }, + config: { + dataSource: { + type: DataVariableType, + path: 'my_data_source_id', + }, + }, + }, })[0]; expect(cmp.get('droppable')).toBe(false); }); - describe('Collection symbols', () => { - test('Basic usage', () => { - const cmp = wrapper.components({ - type: CollectionComponentType, - collectionDefinition: { - block: { - type: 'default', - }, - config: { - dataSource: { - type: DataVariableType, - path: 'my_data_source_id', + test('Collection items should be symbols', () => { + const cmp = wrapper.components({ + type: CollectionComponentType, + collectionDefinition: { + block: { + type: 'default', + components: [ + { + type: 'default', }, + ], + }, + config: { + dataSource: { + type: DataVariableType, + path: 'my_data_source_id', }, }, - })[0]; + }, + })[0]; - expect(cmp.components()).toHaveLength(3); - const firstChild = cmp.components().at(0); - const secondChild = cmp.components().at(1); + expect(cmp.components()).toHaveLength(3); + cmp.components().forEach((child) => expect(child.get('type')).toBe('default')); + const children = cmp.components(); + const firstChild = children.at(0); - expect(firstChild.get('type')).toBe('default'); - expect(secondChild.get('type')).toBe('default'); + children.slice(1).forEach((component) => { + expect(getSymbolMain(component)).toBe(firstChild); }); });