@@ -497,229 +497,4 @@ describe('IntacctExportSettingsComponent', () => {
497
497
expect ( component . exportSettingsForm . get ( 'employeeFieldMapping' ) ?. enabled ) . toBeTrue ( ) ;
498
498
} ) ;
499
499
} ) ;
500
-
501
- describe ( 'Watchers' , ( ) => {
502
- beforeEach ( ( ) => {
503
- fixture . detectChanges ( ) ;
504
- } ) ;
505
-
506
- describe ( 'Reimbursable Expense Toggle Watcher' , ( ) => {
507
- it ( 'should enable fields on enabling reimbursable expenses' , fakeAsync ( ( ) => {
508
- component . exportSettingsForm . get ( 'reimbursableExpense' ) ?. setValue ( true ) ;
509
- tick ( ) ;
510
-
511
- expect ( component . exportSettingsForm . get ( 'reimbursableExportType' ) ?. hasValidator ( Validators . required ) ) . toBeTrue ( ) ;
512
- expect ( component . exportSettingsForm . get ( 'reimbursableExportGroup' ) ?. hasValidator ( Validators . required ) ) . toBeTrue ( ) ;
513
- expect ( component . exportSettingsForm . get ( 'reimbursableExportDate' ) ?. hasValidator ( Validators . required ) ) . toBeTrue ( ) ;
514
- } ) ) ;
515
-
516
- it ( 'should disable fields on disabling reimbursable expenses' , fakeAsync ( ( ) => {
517
- component . exportSettingsForm . get ( 'reimbursableExpense' ) ?. setValue ( false ) ;
518
- tick ( ) ;
519
-
520
- expect ( component . exportSettingsForm . get ( 'reimbursableExportType' ) ?. hasValidator ( Validators . required ) ) . toBeFalse ( ) ;
521
- expect ( component . exportSettingsForm . get ( 'reimbursableExportGroup' ) ?. hasValidator ( Validators . required ) ) . toBeFalse ( ) ;
522
- expect ( component . exportSettingsForm . get ( 'reimbursableExportDate' ) ?. hasValidator ( Validators . required ) ) . toBeFalse ( ) ;
523
- expect ( component . exportSettingsForm . get ( 'reimbursableExportType' ) ?. value ) . toBeNull ( ) ;
524
- } ) ) ;
525
- } ) ;
526
-
527
- describe ( 'Reimbursable Export Type Watchers' , ( ) => {
528
-
529
- it ( 'should handle reimbursableExportType being changed to Journal Entry' , fakeAsync ( ( ) => {
530
- component . exportSettingsForm . get ( 'reimbursableExportType' ) ?. setValue ( IntacctReimbursableExpensesObject . JOURNAL_ENTRY ) ;
531
- tick ( ) ;
532
-
533
- expect ( component . exportSettingsForm . get ( 'glAccount' ) ?. hasValidator ( Validators . required ) ) . toBeTrue ( ) ;
534
- expect ( component . exportSettingsForm . get ( 'employeeFieldMapping' ) ?. enabled ) . toBeTrue ( ) ;
535
- } ) ) ;
536
-
537
- it ( 'should handle reimbursableExportType being changed to Expense Report' , fakeAsync ( ( ) => {
538
- component . exportSettingsForm . get ( 'reimbursableExportType' ) ?. setValue ( IntacctReimbursableExpensesObject . EXPENSE_REPORT ) ;
539
- tick ( ) ;
540
-
541
- expect ( component . exportSettingsForm . get ( 'employeeFieldMapping' ) ?. value ) . toBe ( FyleField . EMPLOYEE ) ;
542
- expect ( component . exportSettingsForm . get ( 'employeeFieldMapping' ) ?. disabled ) . toBeTrue ( ) ;
543
- } ) ) ;
544
-
545
- it ( 'should handle reimbursableExportType being changed to Bill' , fakeAsync ( ( ) => {
546
- component . exportSettingsForm . get ( 'reimbursableExportType' ) ?. setValue ( IntacctReimbursableExpensesObject . BILL ) ;
547
- tick ( ) ;
548
-
549
- expect ( component . exportSettingsForm . get ( 'employeeFieldMapping' ) ?. value ) . toBe ( FyleField . VENDOR ) ;
550
- expect ( component . exportSettingsForm . get ( 'employeeFieldMapping' ) ?. disabled ) . toBeTrue ( ) ;
551
- } ) ) ;
552
- } ) ;
553
-
554
- describe ( 'Credit Card Expense Toggle Watcher' , ( ) => {
555
- it ( 'should enable fields on enabling CCC expenses' , fakeAsync ( ( ) => {
556
- component . exportSettingsForm . get ( 'creditCardExpense' ) ?. setValue ( true ) ;
557
- tick ( ) ;
558
-
559
- expect ( component . exportSettingsForm . get ( 'cccExportType' ) ?. hasValidator ( Validators . required ) ) . toBeTrue ( ) ;
560
- expect ( component . exportSettingsForm . get ( 'cccExportGroup' ) ?. hasValidator ( Validators . required ) ) . toBeTrue ( ) ;
561
- expect ( component . exportSettingsForm . get ( 'cccExportDate' ) ?. hasValidator ( Validators . required ) ) . toBeTrue ( ) ;
562
- } ) ) ;
563
-
564
- it ( 'should disable fields on disabling CCC expenses' , fakeAsync ( ( ) => {
565
- component . exportSettingsForm . get ( 'creditCardExpense' ) ?. setValue ( false ) ;
566
- tick ( ) ;
567
-
568
- expect ( component . exportSettingsForm . get ( 'cccExportType' ) ?. hasValidator ( Validators . required ) ) . toBeFalse ( ) ;
569
- expect ( component . exportSettingsForm . get ( 'cccExportGroup' ) ?. hasValidator ( Validators . required ) ) . toBeFalse ( ) ;
570
- expect ( component . exportSettingsForm . get ( 'cccExportDate' ) ?. hasValidator ( Validators . required ) ) . toBeFalse ( ) ;
571
- expect ( component . exportSettingsForm . get ( 'cccExportType' ) ?. value ) . toBeNull ( ) ;
572
- } ) ) ;
573
- } ) ;
574
-
575
- describe ( 'CCC Export Type Watchers' , ( ) => {
576
- it ( 'should handle cccExportType being changed to Charge Card Transaction' , fakeAsync ( ( ) => {
577
- component . exportSettingsForm . get ( 'cccExportType' ) ?. setValue ( IntacctCorporateCreditCardExpensesObject . CHARGE_CARD_TRANSACTION ) ;
578
- tick ( ) ;
579
-
580
- expect ( component . exportSettingsForm . get ( 'chargeCard' ) ?. hasValidator ( Validators . required ) ) . toBeTrue ( ) ;
581
- expect ( component . exportSettingsForm . get ( 'cccExportGroup' ) ?. disabled ) . toBeTrue ( ) ;
582
- expect ( component . exportSettingsForm . get ( 'cccExportGroup' ) ?. value ) . toBe ( ExpenseGroupingFieldOption . EXPENSE_ID ) ;
583
- } ) ) ;
584
-
585
- it ( 'should handle cccExportType being changed to Bill' , fakeAsync ( ( ) => {
586
- component . exportSettingsForm . get ( 'cccExportType' ) ?. setValue ( IntacctCorporateCreditCardExpensesObject . BILL ) ;
587
- tick ( ) ;
588
-
589
- expect ( component . exportSettingsForm . get ( 'creditCardVendor' ) ?. hasValidator ( Validators . required ) ) . toBeTrue ( ) ;
590
- } ) ) ;
591
-
592
- it ( 'should handle cccExportType being changed to Expense Report' , fakeAsync ( ( ) => {
593
- component . exportSettingsForm . get ( 'cccExportType' ) ?. setValue ( IntacctCorporateCreditCardExpensesObject . EXPENSE_REPORT ) ;
594
- tick ( ) ;
595
-
596
- expect ( component . exportSettingsForm . get ( 'employeeFieldMapping' ) ?. value ) . toBe ( EmployeeFieldMapping . EMPLOYEE ) ;
597
- expect ( component . exportSettingsForm . get ( 'cccExpensePaymentType' ) ?. hasValidator ( Validators . required ) ) . toBeTrue ( ) ;
598
- } ) ) ;
599
- } ) ;
600
-
601
- describe ( 'Custom Watchers' , ( ) => {
602
- beforeEach ( ( ) => {
603
- brandingConfig . brandId = 'fyle' ;
604
- } ) ;
605
-
606
- it ( 'should update reimbursable expense grouping date options when group changes' , fakeAsync ( ( ) => {
607
- fixture . detectChanges ( ) ;
608
- component . exportSettingsForm . get ( 'reimbursableExportGroup' ) ?. setValue ( ExpenseGroupingFieldOption . CLAIM_NUMBER ) ;
609
- tick ( ) ;
610
-
611
- expect ( component . reimbursableExpenseGroupingDateOptions ) . not . toContain ( {
612
- label : 'Spend date' ,
613
- value : ExportDateType . SPENT_AT
614
- } ) ;
615
- } ) ) ;
616
-
617
- it ( 'should update CCC expense grouping date options when group changes' , fakeAsync ( ( ) => {
618
- spyOn < IntacctExportSettingsComponent , any > ( component , 'setCCExpenseDateOptions' ) . and . callThrough ( ) ;
619
- spyOn ( IntacctExportSettingModel , 'getExpenseGroupingDateOptions' ) . and . callThrough ( ) ;
620
- spyOn ( ExportSettingModel , 'constructGroupingDateOptions' ) . and . callThrough ( ) ;
621
-
622
- component . exportSettingsForm . get ( 'cccExportType' ) ?. setValue ( IntacctCorporateCreditCardExpensesObject . CHARGE_CARD_TRANSACTION ) ;
623
- component . exportSettingsForm . get ( 'cccExportGroup' ) ?. setValue ( ExpenseGroupingFieldOption . CLAIM_NUMBER ) ;
624
-
625
- tick ( ) ;
626
-
627
- expect ( IntacctExportSettingModel . getExpenseGroupingDateOptions ) . toHaveBeenCalledWith ( ) ;
628
- expect ( ExportSettingModel . constructGroupingDateOptions ) . toHaveBeenCalledWith (
629
- ExpenseGroupingFieldOption . CLAIM_NUMBER ,
630
- IntacctExportSettingModel . getExpenseGroupingDateOptions ( )
631
- ) ;
632
- expect ( component [ 'setCCExpenseDateOptions' ] ) . toHaveBeenCalled ( ) ;
633
- } ) ) ;
634
- } ) ;
635
-
636
- describe ( 'Export Selection Validator' , ( ) => {
637
- beforeEach ( ( ) => {
638
- fixture . detectChanges ( ) ;
639
- } ) ;
640
-
641
- it ( 'should invalidate form when neither reimbursable nor credit card expense is selected' , ( ) => {
642
- component . exportSettingsForm . get ( 'reimbursableExpense' ) ?. setValue ( false ) ;
643
- component . exportSettingsForm . get ( 'creditCardExpense' ) ?. setValue ( false ) ;
644
-
645
- expect ( component . exportSettingsForm . valid ) . toBeFalse ( ) ;
646
- } ) ;
647
-
648
- it ( 'should validate the form when at least one export type is selected' , ( ) => {
649
- component . exportSettingsForm . get ( 'reimbursableExpense' ) ?. setValue ( true ) ;
650
- component . exportSettingsForm . get ( 'creditCardExpense' ) ?. setValue ( false ) ;
651
-
652
- expect ( component . exportSettingsForm . valid ) . toBeTrue ( ) ;
653
- } ) ;
654
- } ) ;
655
-
656
- describe ( 'Destination Options Handling' , ( ) => {
657
- beforeEach ( ( ) => {
658
- fixture . detectChanges ( ) ;
659
- } ) ;
660
-
661
- it ( 'should handle option search for reimbursable expense payment type' , fakeAsync ( ( ) => {
662
- const searchEvent = {
663
- searchTerm : 'test' ,
664
- destinationOptionKey : 'EXPENSE_PAYMENT_TYPE'
665
- } as ExportSettingOptionSearch ;
666
-
667
- mappingService . getPaginatedDestinationAttributes . and . returnValue (
668
- of ( mockPaginatedDestinationAttributes . EXPENSE_PAYMENT_TYPE as unknown as PaginatedintacctDestinationAttribute )
669
- ) ;
670
-
671
- component . searchOptionsDropdown ( searchEvent ) ;
672
- tick ( 1000 ) ;
673
-
674
- const isReimbursable = ( option : IntacctDestinationAttribute ) => (
675
- option . detail ? option . detail . is_reimbursable : true
676
- ) ;
677
-
678
- expect ( mappingService . getPaginatedDestinationAttributes ) . toHaveBeenCalledWith ( 'EXPENSE_PAYMENT_TYPE' , 'test' ) ;
679
- expect ( component . destinationOptions . EXPENSE_PAYMENT_TYPE . every ( isReimbursable ) ) . toBeTrue ( ) ;
680
- expect ( component . isOptionSearchInProgress ) . toBeFalse ( ) ;
681
- } ) ) ;
682
-
683
- it ( 'should handle option search for CCC expense payment type' , fakeAsync ( ( ) => {
684
- const searchEvent = {
685
- searchTerm : 'test' ,
686
- destinationOptionKey : 'CCC_EXPENSE_PAYMENT_TYPE'
687
- } ;
688
-
689
- mappingService . getPaginatedDestinationAttributes . and . returnValue (
690
- of ( mockPaginatedDestinationAttributes . EXPENSE_PAYMENT_TYPE as unknown as PaginatedintacctDestinationAttribute )
691
- ) ;
692
-
693
- component . searchOptionsDropdown ( searchEvent as ExportSettingOptionSearch ) ;
694
- tick ( 1000 ) ;
695
-
696
- expect ( mappingService . getPaginatedDestinationAttributes ) . toHaveBeenCalledWith ( 'EXPENSE_PAYMENT_TYPE' , 'test' ) ;
697
- expect ( component . destinationOptions . CCC_EXPENSE_PAYMENT_TYPE . every ( option => (
698
- option . detail ? ! option . detail . is_reimbursable : true
699
- ) ) ) . toBeTrue ( ) ;
700
- expect ( component . isOptionSearchInProgress ) . toBeFalse ( ) ;
701
- } ) ) ;
702
- } ) ;
703
-
704
-
705
- } ) ;
706
-
707
-
708
- describe ( 'C1 Specific Behavior' , ( ) => {
709
- it ( 'should handle setup with c1 branding' , ( ) => {
710
- brandingConfig . brandId = 'co' ;
711
-
712
- fixture = TestBed . createComponent ( IntacctExportSettingsComponent ) ;
713
- component = fixture . componentInstance ;
714
- fixture . detectChanges ( ) ;
715
-
716
- expect ( component . exportSettingsForm . get ( 'creditCardExpense' ) ?. value ) . toBeTrue ( ) ;
717
- expect ( component . exportSettingsForm . get ( 'employeeFieldMapping' ) ?. value ) . toBe ( FyleField . VENDOR ) ;
718
- expect ( component . isMultiLineOption ) . toBeFalse ( ) ;
719
- } ) ;
720
-
721
- afterAll ( ( ) => {
722
- brandingConfig . brandId = 'fyle' ;
723
- } ) ;
724
- } ) ;
725
500
} ) ;
0 commit comments