@@ -143,6 +143,8 @@ QUnit.module('HighlighterView', function(hooks) {
143
143
assert . equal ( joint . dia . HighlighterView . get ( elementView , highlighterId2 ) , null ) ;
144
144
assert . ok ( joint . dia . HighlighterView . get ( elementView2 , highlighterId1 ) ) ;
145
145
assert . equal ( joint . dia . HighlighterView . get ( elementView3 , highlighterId1 ) , null ) ;
146
+
147
+ paper2 . remove ( ) ;
146
148
} ) ;
147
149
148
150
QUnit . test ( 'removeAll(paper, id)' , function ( assert ) {
@@ -171,6 +173,74 @@ QUnit.module('HighlighterView', function(hooks) {
171
173
assert . ok ( joint . dia . HighlighterView . get ( elementView , highlighterId2 ) ) ;
172
174
assert . ok ( joint . dia . HighlighterView . get ( elementView2 , highlighterId1 ) ) ;
173
175
assert . equal ( joint . dia . HighlighterView . get ( elementView3 , highlighterId1 ) , null ) ;
176
+
177
+ paper2 . remove ( ) ;
178
+ } ) ;
179
+ } ) ;
180
+
181
+ QUnit . module ( 'static getAll()' , function ( ) {
182
+
183
+ QUnit . test ( 'getAll(paper)' , function ( assert ) {
184
+
185
+ const highlighterId1 = 'highlighter-id-1' ;
186
+ const highlighterId2 = 'highlighter-id-2' ;
187
+
188
+ const graph2 = new joint . dia . Graph ( { } , { cellNamespace : joint . shapes } ) ;
189
+ const paper2 = new joint . dia . Paper ( { model : graph2 , cellViewNamespace : joint . shapes } ) ;
190
+ const element2 = element . clone ( ) ;
191
+ const elementDifferentGraph = element . clone ( ) ;
192
+
193
+ element2 . addTo ( graph ) ;
194
+ elementDifferentGraph . addTo ( graph2 ) ;
195
+
196
+ const elementView2 = element2 . findView ( paper ) ;
197
+ const elementViewDifferentGraph = elementDifferentGraph . findView ( paper2 ) ;
198
+
199
+ const h1 = joint . dia . HighlighterView . add ( elementView , 'body' , highlighterId1 ) ;
200
+ const h2 = joint . dia . HighlighterView . add ( elementView , 'body' , highlighterId2 ) ;
201
+ const h3 = joint . dia . HighlighterView . add ( elementView2 , 'body' , highlighterId1 ) ;
202
+ const h4 = joint . dia . HighlighterView . add ( elementViewDifferentGraph , 'body' , highlighterId1 ) ;
203
+
204
+ const highlighters = joint . dia . HighlighterView . getAll ( paper ) ;
205
+ assert . equal ( highlighters . length , 3 ) ;
206
+ assert . ok ( highlighters . includes ( h1 ) ) ;
207
+ assert . ok ( highlighters . includes ( h2 ) ) ;
208
+ assert . ok ( highlighters . includes ( h3 ) ) ;
209
+ assert . notOk ( highlighters . includes ( h4 ) ) ;
210
+
211
+ paper2 . remove ( ) ;
212
+ } ) ;
213
+
214
+ QUnit . test ( 'getAll(paper, id)' , function ( assert ) {
215
+
216
+ const highlighterId1 = 'highlighter-id-1' ;
217
+ const highlighterId2 = 'highlighter-id-2' ;
218
+
219
+ const graph2 = new joint . dia . Graph ( { } , { cellNamespace : joint . shapes } ) ;
220
+ const paper2 = new joint . dia . Paper ( { model : graph2 , cellViewNamespace : joint . shapes } ) ;
221
+
222
+ const element2 = element . clone ( ) ;
223
+ const elementDifferentGraph = element . clone ( ) ;
224
+
225
+ element2 . addTo ( graph ) ;
226
+ elementDifferentGraph . addTo ( graph2 ) ;
227
+
228
+ const elementView2 = element2 . findView ( paper ) ;
229
+ const elementViewDifferentGraph = elementDifferentGraph . findView ( paper2 ) ;
230
+
231
+ const h1 = joint . dia . HighlighterView . add ( elementView , 'body' , highlighterId1 ) ;
232
+ const h2 = joint . dia . HighlighterView . add ( elementView , 'body' , highlighterId2 ) ;
233
+ const h3 = joint . dia . HighlighterView . add ( elementView2 , 'body' , highlighterId1 ) ;
234
+ const h4 = joint . dia . HighlighterView . add ( elementViewDifferentGraph , 'body' , highlighterId1 ) ;
235
+
236
+ const highlighters = joint . dia . HighlighterView . getAll ( paper , highlighterId1 ) ;
237
+ assert . equal ( highlighters . length , 2 ) ;
238
+ assert . ok ( highlighters . includes ( h1 ) ) ;
239
+ assert . notOk ( highlighters . includes ( h2 ) ) ;
240
+ assert . ok ( highlighters . includes ( h3 ) ) ;
241
+ assert . notOk ( highlighters . includes ( h4 ) ) ;
242
+
243
+ paper2 . remove ( ) ;
174
244
} ) ;
175
245
} ) ;
176
246
0 commit comments