Skip to content

Commit 7d967d2

Browse files
Update tests for collection symbols
1 parent 6432a9c commit 7d967d2

File tree

1 file changed

+38
-19
lines changed

1 file changed

+38
-19
lines changed

packages/core/test/specs/data_sources/model/collection_component/CollectionComponent.ts

+38-19
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import { isSymbol } from 'underscore';
12
import { Component, DataSource, DataSourceManager } from '../../../../../src';
23
import { DataVariableType } from '../../../../../src/data_sources/model/DataVariable';
34
import {
45
CollectionComponentType,
56
CollectionVariableType,
67
} from '../../../../../src/data_sources/model/collection_component/constants';
78
import { CollectionStateVariableType } from '../../../../../src/data_sources/model/collection_component/types';
9+
import { keySymbol } from '../../../../../src/dom_components/model/Component';
810
import EditorModel from '../../../../../src/editor/model/Editor';
911
import { filterObjectForSnapshot, setupTestEditor } from '../../../../common';
12+
import { getSymbolMain, getSymbolTop } from '../../../../../src/dom_components/model/SymbolUtils';
1013

1114
describe('Collection component', () => {
1215
let em: EditorModel;
@@ -31,37 +34,53 @@ describe('Collection component', () => {
3134
em.destroy();
3235
});
3336

34-
test('Should be undroppable', () => {
37+
test('Should be undroppable', () => {
3538
const cmp = wrapper.components({
3639
type: CollectionComponentType,
40+
collectionDefinition: {
41+
block: {
42+
type: 'default',
43+
},
44+
config: {
45+
dataSource: {
46+
type: DataVariableType,
47+
path: 'my_data_source_id',
48+
},
49+
},
50+
},
3751
})[0];
3852

3953
expect(cmp.get('droppable')).toBe(false);
4054
});
4155

42-
describe('Collection symbols', () => {
43-
test('Basic usage', () => {
44-
const cmp = wrapper.components({
45-
type: CollectionComponentType,
46-
collectionDefinition: {
47-
block: {
48-
type: 'default',
49-
},
50-
config: {
51-
dataSource: {
52-
type: DataVariableType,
53-
path: 'my_data_source_id',
56+
test('Collection items should be symbols', () => {
57+
const cmp = wrapper.components({
58+
type: CollectionComponentType,
59+
collectionDefinition: {
60+
block: {
61+
type: 'default',
62+
components: [
63+
{
64+
type: 'default',
5465
},
66+
],
67+
},
68+
config: {
69+
dataSource: {
70+
type: DataVariableType,
71+
path: 'my_data_source_id',
5572
},
5673
},
57-
})[0];
74+
},
75+
})[0];
5876

59-
expect(cmp.components()).toHaveLength(3);
60-
const firstChild = cmp.components().at(0);
61-
const secondChild = cmp.components().at(1);
77+
expect(cmp.components()).toHaveLength(3);
78+
cmp.components().forEach((child) => expect(child.get('type')).toBe('default'));
79+
const children = cmp.components();
80+
const firstChild = children.at(0);
6281

63-
expect(firstChild.get('type')).toBe('default');
64-
expect(secondChild.get('type')).toBe('default');
82+
children.slice(1).forEach((component) => {
83+
expect(getSymbolMain(component)).toBe(firstChild);
6584
});
6685
});
6786

0 commit comments

Comments
 (0)