@@ -203,7 +203,11 @@ describe('Neovis', () => {
203
203
container_id,
204
204
labels : {
205
205
[ label1 ] : {
206
- sizeCypher : sizeCypher
206
+ [ NEOVIS_ADVANCED_CONFIG ] : {
207
+ cypher : {
208
+ value : sizeCypher
209
+ }
210
+ }
207
211
}
208
212
}
209
213
} ;
@@ -213,14 +217,14 @@ describe('Neovis', () => {
213
217
214
218
// TODO: session.readTransaction needs to be properly mocked
215
219
// skipping this test until mock is added
216
- it . skip ( 'should call sizeCypher and save return value to data set value' , async ( ) => {
220
+ it ( 'should call sizeCypher and save return value to data set value' , async ( ) => {
217
221
const node = testUtils . makeNode ( [ label1 ] ) ;
218
222
testUtils . mockFullRunSubscribe ( {
219
223
[ initial_cypher ] : {
220
224
default : [ testUtils . makeRecord ( [ node ] ) ]
221
225
} ,
222
226
[ sizeCypher ] : {
223
- [ node . identity . toInt ( ) ] : [ testUtils . makeRecord ( [ Neo4j . int ( 1 ) ] ) ]
227
+ [ node . identity ] : [ testUtils . makeRecord ( [ Neo4j . int ( 1 ) ] ) ]
224
228
}
225
229
} ) ;
226
230
@@ -278,105 +282,41 @@ describe('Neovis', () => {
278
282
} ) ;
279
283
} ) ;
280
284
281
- describe ( 'neovis config test' , ( ) => {
282
- const imageUrl = 'https://visjs.org/images/visjs_logo.png' ;
283
- const fontSize = 28 ;
284
- const fontColor = '#00FF00' ;
285
- let config = {
286
- container_id : container_id ,
287
- labels : {
288
- [ label1 ] : {
289
- [ NEOVIS_ADVANCED_CONFIG ] : {
290
- 'static' : {
291
- image : imageUrl ,
292
- font : {
293
- 'size' : fontSize ,
294
- 'color' : fontColor ,
295
- }
296
- }
297
- }
298
- }
299
- } ,
300
- initial_cypher : initial_cypher
301
- } ;
302
- beforeEach ( ( ) => {
303
- neovis = new Neovis ( config ) ;
304
- } ) ;
305
-
306
- it ( 'image field in config should reflect in node data' , async ( ) => {
307
- const node1 = testUtils . makeNode ( [ label1 ] ) ;
308
- testUtils . mockFullRunSubscribe ( {
309
- [ initial_cypher ] : {
310
- default : [ testUtils . makeRecord ( [ node1 ] ) ]
311
- }
312
- } ) ;
313
-
314
- neovis . render ( ) ;
315
- await testUtils . neovisRenderDonePromise ( neovis ) ;
316
- expect ( neovis . _data . nodes . get ( 1 ) ) . toHaveProperty ( 'image' , imageUrl ) ;
317
- } ) ;
318
-
319
- it ( 'image field for type not specified in config should not reflect in node data' , async ( ) => {
320
- const node1 = testUtils . makeNode ( [ label2 ] ) ;
321
- testUtils . mockFullRunSubscribe ( {
322
- [ initial_cypher ] : {
323
- default : [ testUtils . makeRecord ( [ node1 ] ) ]
324
- }
325
- } ) ;
326
-
327
- neovis . render ( ) ;
328
- await testUtils . neovisRenderDonePromise ( neovis ) ;
329
- expect ( neovis . _data . nodes . get ( 1 ) ) . toHaveProperty ( 'image' , undefined ) ;
330
- } ) ;
331
-
332
- it ( 'font field in config should reflect in node data' , async ( ) => {
333
- const node1 = testUtils . makeNode ( [ label1 ] ) ;
334
- testUtils . mockFullRunSubscribe ( {
335
- [ initial_cypher ] : {
336
- default : [ testUtils . makeRecord ( [ node1 ] ) ]
337
- }
338
- } ) ;
339
-
340
- neovis . render ( ) ;
341
- await testUtils . neovisRenderDonePromise ( neovis ) ;
342
- expect ( neovis . _data . nodes . get ( 1 ) . font ) . toBeDefined ( ) ;
343
- expect ( neovis . _data . nodes . get ( 1 ) . font . size ) . toBe ( fontSize ) ;
344
- expect ( neovis . _data . nodes . get ( 1 ) . font . color ) . toBe ( fontColor ) ;
345
- } ) ;
346
-
347
- it ( 'font field for type not specified in config should not reflect in node data' , async ( ) => {
348
- const node1 = testUtils . makeNode ( [ label2 ] ) ;
349
- testUtils . mockFullRunSubscribe ( {
350
- [ initial_cypher ] : {
351
- default : [ testUtils . makeRecord ( [ node1 ] ) ]
352
- }
353
- } ) ;
354
-
355
- neovis . render ( ) ;
356
- await testUtils . neovisRenderDonePromise ( neovis ) ;
357
- expect ( neovis . _data . nodes . get ( 1 ) ) . toHaveProperty ( 'font' , undefined ) ;
358
- } ) ;
359
- } ) ;
360
- describe ( 'neovis non flat config test' , ( ) => {
361
- const imageUrl = 'https://visjs.org/images/visjs_logo.png' ;
362
- const fontSize = 28 ;
363
- const fontColor = '#00FF00' ;
364
- let config = {
365
- container_id : container_id ,
366
- non_flat : true ,
367
- labels : {
368
- [ label1 ] : {
369
- 'static' : {
285
+ const imageUrl = 'https://visjs.org/images/visjs_logo.png' ;
286
+ const fontSize = 28 ;
287
+ const fontColor = '#00FF00' ;
288
+ describe . each ( [ [ 'config' , {
289
+ container_id,
290
+ labels : {
291
+ [ label1 ] : {
292
+ [ NEOVIS_ADVANCED_CONFIG ] : {
293
+ static : {
370
294
image : imageUrl ,
371
295
font : {
372
- ' size' : fontSize ,
373
- ' color' : fontColor ,
296
+ size : fontSize ,
297
+ color : fontColor ,
374
298
}
375
299
}
376
300
}
377
- } ,
378
- initial_cypher : initial_cypher
379
- } ;
301
+ }
302
+ } ,
303
+ initial_cypher : initial_cypher
304
+ } ] , [ 'non flat config' , {
305
+ container_id,
306
+ non_flat : true ,
307
+ labels : {
308
+ [ label1 ] : {
309
+ static : {
310
+ image : imageUrl ,
311
+ font : {
312
+ size : fontSize ,
313
+ color : fontColor ,
314
+ }
315
+ }
316
+ }
317
+ } ,
318
+ initial_cypher : initial_cypher
319
+ } ] ] ) ( 'neovis advance %s test' , ( configName , config ) => {
380
320
beforeEach ( ( ) => {
381
321
neovis = new Neovis ( config ) ;
382
322
} ) ;
@@ -572,15 +512,15 @@ describe('Neovis', () => {
572
512
573
513
// TODO: session.readTransaction needs to be properly mocked
574
514
// skipping this test until mock is added
575
- it . skip ( 'should merge cypher type to vis.js config properly' , async ( ) => {
515
+ it ( 'should merge cypher type to vis.js config properly' , async ( ) => {
576
516
const sizeCypher = 'sizeCypher' ;
577
517
let config = {
578
518
container_id : container_id ,
579
519
labels : {
580
520
[ label1 ] : {
581
521
[ NEOVIS_ADVANCED_CONFIG ] : {
582
- ' cypher' : {
583
- ' label' : sizeCypher
522
+ cypher : {
523
+ label : sizeCypher
584
524
}
585
525
}
586
526
}
@@ -592,11 +532,14 @@ describe('Neovis', () => {
592
532
testUtils . mockFullRunSubscribe ( {
593
533
[ initial_cypher ] : {
594
534
default : [ testUtils . makeRecord ( [ node1 ] ) ]
535
+ } ,
536
+ [ sizeCypher ] : {
537
+ [ node1 . identity ] : [ testUtils . makeRecord ( [ intProperityValue ] ) ]
595
538
}
596
539
} ) ;
597
540
neovis . render ( ) ;
598
541
await testUtils . neovisRenderDonePromise ( neovis ) ;
599
- expect ( Neo4jMock . mockSessionRun ) . toHaveBeenCalledTimes ( 1 ) ;
542
+ expect ( Neo4jMock . mockSessionRun ) . toHaveBeenCalledTimes ( 2 ) ;
600
543
expect ( neovis . _data . nodes . get ( 1 ) ) . toHaveProperty ( 'label' , intProperityValue ) ;
601
544
} ) ;
602
545
0 commit comments