1
+ import { isSymbol } from 'underscore' ;
1
2
import { Component , DataSource , DataSourceManager } from '../../../../../src' ;
2
3
import { DataVariableType } from '../../../../../src/data_sources/model/DataVariable' ;
3
4
import {
4
5
CollectionComponentType ,
5
6
CollectionVariableType ,
6
7
} from '../../../../../src/data_sources/model/collection_component/constants' ;
7
8
import { CollectionStateVariableType } from '../../../../../src/data_sources/model/collection_component/types' ;
9
+ import { keySymbol } from '../../../../../src/dom_components/model/Component' ;
8
10
import EditorModel from '../../../../../src/editor/model/Editor' ;
9
11
import { filterObjectForSnapshot , setupTestEditor } from '../../../../common' ;
12
+ import { getSymbolMain , getSymbolTop } from '../../../../../src/dom_components/model/SymbolUtils' ;
10
13
11
14
describe ( 'Collection component' , ( ) => {
12
15
let em : EditorModel ;
@@ -31,37 +34,53 @@ describe('Collection component', () => {
31
34
em . destroy ( ) ;
32
35
} ) ;
33
36
34
- test ( 'Should be undroppable' , ( ) => {
37
+ test ( 'Should be undroppable' , ( ) => {
35
38
const cmp = wrapper . components ( {
36
39
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
+ } ,
37
51
} ) [ 0 ] ;
38
52
39
53
expect ( cmp . get ( 'droppable' ) ) . toBe ( false ) ;
40
54
} ) ;
41
55
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' ,
54
65
} ,
66
+ ] ,
67
+ } ,
68
+ config : {
69
+ dataSource : {
70
+ type : DataVariableType ,
71
+ path : 'my_data_source_id' ,
55
72
} ,
56
73
} ,
57
- } ) [ 0 ] ;
74
+ } ,
75
+ } ) [ 0 ] ;
58
76
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 ) ;
62
81
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 ) ;
65
84
} ) ;
66
85
} ) ;
67
86
0 commit comments