@@ -291,6 +291,24 @@ describe('Test Dependencies', () => {
291
291
/////// HANDLERS ///////
292
292
////////////////////////////
293
293
294
+ const prevs = { //prevs for handleSUBJ and handleNOUN
295
+ ART : {
296
+ DEFAULT : 'a'
297
+ } ,
298
+ NOUN : {
299
+ DEFAULT : 'ART' ,
300
+ EXCEPTION : {
301
+ casa : 'en'
302
+ }
303
+ } ,
304
+ SUBJ : {
305
+ DEFAULT : 'a,ART' ,
306
+ EXCEPTION : {
307
+ mamá : 'mi'
308
+ }
309
+ }
310
+ }
311
+
294
312
describe ( 'Test VERB handlers' , ( ) => {
295
313
before ( ( ) => {
296
314
const { getApp } = require ( '../getter.js' )
@@ -420,7 +438,203 @@ describe('Test VERB handlers', () => {
420
438
} )
421
439
422
440
describe ( 'Test SUBJ handlers' , ( ) => {
441
+ before ( ( ) => {
442
+ this . testObj = [
443
+ {
444
+ words : [ 'mamá' ] ,
445
+ types : [ 'SUBJ' ] ,
446
+ composed : false ,
447
+ type : 'SUBJ' ,
448
+ children : [ ] ,
449
+ meta : { } ,
450
+ props : {
451
+ prev : prevs
452
+ } ,
453
+ position : 0 ,
454
+ headless : true
455
+ } ,
456
+ {
457
+ words : [ 'abuelo' , 'la' , 'abuela' ] ,
458
+ types : [ 'SUBJ' , 'ART' , 'SUBJ' ] ,
459
+ composed : true ,
460
+ type : 'SUBJ' ,
461
+ children : [
462
+ { position : 2 , type : 'ADJ' }
463
+ ] ,
464
+ meta : {
465
+ GENDER : 'ellos' ,
466
+ PERSON : 'ellos'
467
+ } ,
468
+ props : {
469
+ prev : prevs
470
+ } ,
471
+ position : 1 ,
472
+ headless : true ,
473
+ genders : [ 'él' , 'ella' ]
474
+ } ,
475
+ {
476
+ words : [ 'bueno' ] ,
477
+ types : [ 'ADJ' ] ,
478
+ composed : false ,
479
+ type : 'ADJ' ,
480
+ children : [ ] ,
481
+ meta : { } ,
482
+ props : { } ,
483
+ position : 2 ,
484
+ headless : false
485
+ }
486
+ ]
487
+ const langRef = require ( '../getter.js' ) . getApp ( ) . database ( ) . ref ( 'es' ) ;
488
+ const { handleType } = require ( '../handlers.js' ) ;
489
+ this . resultObjMain = handleType ( this . testObj [ 1 ] , this . testObj , langRef , 'static' , { } ) ;
490
+ this . resultObjException = handleType ( this . testObj [ 0 ] , this . testObj , langRef , 'static' , { } ) ;
491
+ } )
492
+
493
+ it ( 'Should properly prepend following props.prev' , async ( ) => {
494
+ const thisResult = await this . resultObjMain ;
495
+ expect ( thisResult . words [ 0 ] ) . to . equal ( 'a el' ) ; //HERE: this should be generalized
496
+ } )
497
+
498
+ it ( 'Shoud be able to manage exceptions on props.prev' , async ( ) => {
499
+ const thisResult = await this . resultObjException ;
500
+ expect ( thisResult . words [ 0 ] ) . to . equal ( 'mi mamá' ) ; //HERE: this should be generalized
501
+ expect ( thisResult . words [ 0 ] ) . not . to . equal ( 'a el' ) ; //HERE: this should be generalized
502
+ } )
503
+
504
+ it ( 'Should add connector if inexistent on composed SUBJ' , async ( ) => {
505
+ const thisResult = await this . resultObjMain ;
506
+ expect ( thisResult . types ) . to . include ( 'CON' )
507
+ } )
423
508
509
+ it ( 'Should lead to the conjugation of ADJ children' , async ( ) => {
510
+ const thisResult = await this . resultObjMain ;
511
+ expect ( this . testObj [ 1 ] . meta . PERSON ) . to . equal ( thisResult . meta . GENDER || thisResult . meta . PERSON )
512
+ } )
424
513
} )
425
514
426
- //HERE: For now only SUBJ and VERB are important because ADJ and ADV have mostly no function and NOUN is basically the same as SUBJ
515
+ describe ( 'Test NOUN handlers' , ( ) => {
516
+ before ( ( ) => {
517
+ this . testObj = [
518
+ {
519
+ words : [ 'casa' ] ,
520
+ types : [ 'NOUN' ] ,
521
+ composed : false ,
522
+ type : 'NOUN' ,
523
+ children : [ ] ,
524
+ meta : { } ,
525
+ props : {
526
+ prev : prevs
527
+ } ,
528
+ position : 0 ,
529
+ headless : true
530
+ } ,
531
+ {
532
+ words : [ 'bruja' , 'el' , 'ropero' ] ,
533
+ types : [ 'NOUN' , 'ART' , 'NOUN' ] ,
534
+ composed : true ,
535
+ type : 'NOUN' ,
536
+ children : [
537
+ { position : 2 , type : 'ADJ' }
538
+ ] ,
539
+ meta : {
540
+ GENDER : 'ellos' ,
541
+ PERSON : 'ellos'
542
+ } ,
543
+ props : {
544
+ prev : prevs
545
+ } ,
546
+ position : 1 ,
547
+ headless : true ,
548
+ genders : [ 'ella' , 'él' ]
549
+ } ,
550
+ {
551
+ words : [ 'hermoso' ] ,
552
+ types : [ 'ADJ' ] ,
553
+ composed : false ,
554
+ type : 'ADJ' ,
555
+ children : [ ] ,
556
+ meta : { } ,
557
+ props : { } ,
558
+ position : 2 ,
559
+ headless : false
560
+ }
561
+ ]
562
+ const langRef = require ( '../getter.js' ) . getApp ( ) . database ( ) . ref ( 'es' ) ;
563
+ const { handleType } = require ( '../handlers.js' ) ;
564
+ this . resultObjMain = handleType ( this . testObj [ 1 ] , this . testObj , langRef , 'static' , { } ) ;
565
+ this . resultObjException = handleType ( this . testObj [ 0 ] , this . testObj , langRef , 'static' , { } ) ;
566
+ } )
567
+
568
+ it ( 'Should properly prepend following props.prev' , async ( ) => {
569
+ const thisResult = await this . resultObjMain ;
570
+ expect ( thisResult . words [ 0 ] ) . to . equal ( 'la' ) ; //HERE: this should be generalized
571
+ } )
572
+
573
+ it ( 'Shoud be able to manage exceptions on props.prev' , async ( ) => {
574
+ const thisResult = await this . resultObjException ;
575
+ expect ( thisResult . words [ 0 ] ) . to . equal ( 'en casa' ) ; //HERE: this should be generalized
576
+ expect ( thisResult . words [ 0 ] ) . not . to . equal ( 'la' ) ; //HERE: this should be generalized
577
+ } )
578
+
579
+ it ( 'Should add connector if inexistent on composed NOUN' , async ( ) => {
580
+ const thisResult = await this . resultObjMain ;
581
+ expect ( thisResult . types ) . to . include ( 'CON' )
582
+ } )
583
+
584
+ it ( 'Should lead to the conjugation of ADJ children' , async ( ) => {
585
+ const thisResult = await this . resultObjMain ;
586
+ expect ( this . testObj [ 1 ] . meta . PERSON ) . to . equal ( thisResult . meta . GENDER || thisResult . meta . PERSON )
587
+ } )
588
+ } )
589
+
590
+ describe ( 'Test ADJ handlers' , ( ) => {
591
+ before ( ( ) => {
592
+ this . testObj = [
593
+ {
594
+ words : [ 'hermoso' ] ,
595
+ types : [ 'ADJ' ] ,
596
+ composed : false ,
597
+ type : 'ADJ' ,
598
+ children : [ ] ,
599
+ meta : { } ,
600
+ props : { } ,
601
+ position : 2 ,
602
+ headless : false
603
+ }
604
+ ]
605
+ const langRef = require ( '../getter.js' ) . getApp ( ) . database ( ) . ref ( 'es' ) ;
606
+ const { handleType } = require ( '../handlers.js' ) ;
607
+ this . resultObj = handleType ( this . testObj [ 1 ] , this . testObj , langRef , 'static' , { } ) ;
608
+ } )
609
+
610
+ it ( 'Should add connector if inexistent on composed ADJ' , async ( ) => {
611
+ const thisResult = await this . resultObj ;
612
+ expect ( thisResult . types ) . to . include ( 'CON' )
613
+ } )
614
+ } )
615
+
616
+ describe ( 'Test ADV handlers' , ( ) => {
617
+ before ( ( ) => {
618
+ this . testObj = [
619
+ {
620
+ words : [ 'rápido' ] ,
621
+ types : [ 'ADV' ] ,
622
+ composed : false ,
623
+ type : 'ADJ' ,
624
+ children : [ ] ,
625
+ meta : { } ,
626
+ props : { } ,
627
+ position : 2 ,
628
+ headless : false
629
+ }
630
+ ]
631
+ const langRef = require ( '../getter.js' ) . getApp ( ) . database ( ) . ref ( 'es' ) ;
632
+ const { handleType } = require ( '../handlers.js' ) ;
633
+ this . resultObj = handleType ( this . testObj [ 1 ] , this . testObj , langRef , 'static' , { } ) ;
634
+ } )
635
+
636
+ it ( 'Should add connector if inexistent on composed ADV' , async ( ) => {
637
+ const thisResult = await this . resultObj ;
638
+ expect ( thisResult . types ) . to . include ( 'CON' )
639
+ } )
640
+ } )
0 commit comments