@@ -44,12 +44,13 @@ describe('# Functional Test', () => {
44
44
45
45
describe ( '# Topic' , ( ) => {
46
46
it ( 'should be a lots of main topic added to rootTopic' , done => {
47
- const topics = [ 'main topic 1' , 'main topic 2' , 'main topic 3' , 'main topic 4' ] ;
47
+ const topics = [ 'main topic 1' , 'main topic 2' , 'main topic 3' , 'main topic 4' , '' ] ;
48
48
const { workbook, topic} = getComponents ( ) ;
49
49
topic . add ( { title : 'main topic 1' } )
50
50
. add ( { title : 'main topic 2' } )
51
51
. add ( { title : 'main topic 3' } )
52
- . add ( { title : 'main topic 4' } ) ;
52
+ . add ( { title : 'main topic 4' } )
53
+ . add ( { title : '' } ) ;
53
54
54
55
const children = workbook . toJSON ( ) [ 0 ] . rootTopic . children . attached ;
55
56
for ( let i = 0 ; i < children . length ; i ++ ) {
@@ -72,11 +73,12 @@ describe('# Functional Test', () => {
72
73
. on ( topic . cid ( ) )
73
74
. add ( { title : 'subtopic 1' } )
74
75
. add ( { title : 'subtopic 2' } )
75
- . add ( { title : 'subtopic 3' } ) ;
76
+ . add ( { title : 'subtopic 3' } )
77
+ . add ( { title : '' } ) ;
76
78
77
79
const subtopics = workbook . toJSON ( ) [ 0 ] . rootTopic . children . attached [ 0 ] . children . attached ;
78
80
for ( let i = 0 ; i < subtopics . length ; i ++ ) {
79
- expect ( subtopics [ i ] . title . startsWith ( 'subtopic' ) ) . to . be . true ;
81
+ expect ( subtopics [ i ] . title . startsWith ( 'subtopic' ) || subtopics [ i ] . title === '' ) . to . be . true ;
80
82
expect ( subtopics [ i ] . id ) . to . not . be . empty ;
81
83
}
82
84
done ( ) ;
@@ -97,14 +99,15 @@ describe('# Functional Test', () => {
97
99
const subTopic2Id = topic . cid ( ) ;
98
100
99
101
topic . add ( { title : 'subtopic 3' } ) ;
102
+ topic . add ( { title : '' } ) ;
100
103
topic . destroy ( subTopic2Id ) ;
101
104
// Do nothing if you have to remove topic twice
102
105
topic . destroy ( subTopic2Id ) ;
103
106
104
107
const subtopics = workbook . toJSON ( ) [ 0 ] . rootTopic . children . attached [ 0 ] . children . attached ;
105
- expect ( subtopics . length ) . to . be . eq ( 2 ) ;
108
+ expect ( subtopics . length ) . to . be . eq ( 3 ) ;
106
109
for ( let i = 0 ; i < subtopics . length ; i ++ ) {
107
- expect ( subtopics [ i ] . title . startsWith ( 'subtopic' ) ) . to . be . true ;
110
+ expect ( subtopics [ i ] . title . startsWith ( 'subtopic' ) || subtopics [ i ] . title === '' ) . to . be . true ;
108
111
expect ( subtopics [ i ] . id ) . to . not . be . empty ;
109
112
}
110
113
done ( ) ;
@@ -159,9 +162,11 @@ describe('# Functional Test', () => {
159
162
topic
160
163
. add ( { title : 'main topic 1' } )
161
164
. add ( { title : 'main topic 2' } )
162
- . add ( { title : 'main topic 3' } ) ;
165
+ . add ( { title : 'main topic 3' } )
166
+ . add ( { title : '' } ) ;
163
167
164
168
topic . destroy ( topic . cid ( 'main topic 2' ) ) ;
169
+ topic . destroy ( topic . cid ( '' ) ) ;
165
170
zip . save ( ) . then ( async status => {
166
171
expect ( status ) . to . be . true ;
167
172
const p = getBuildTemporaryPath ( 'default.xmind' ) ;
@@ -173,6 +178,7 @@ describe('# Functional Test', () => {
173
178
const { attached} = map . rootTopic . children ;
174
179
expect ( attached . length ) . to . be . eq ( 2 ) ;
175
180
expect ( attached . find ( child => child . title === topic . cid ( 'main topic 2' ) ) ) . to . be . undefined ;
181
+ expect ( attached . find ( child => child . title === topic . cid ( '' ) ) ) . to . be . undefined ;
176
182
fs . unlinkSync ( p ) ;
177
183
done ( ) ;
178
184
} ) ;
0 commit comments