1
1
import AppConfig from 'config/config' ;
2
2
import * as ConfigUtils from 'config/config-utils' ;
3
+ import configDefault from 'config/config-default' ;
3
4
import {
4
5
BadgeStyle ,
5
6
NoticeSeverity ,
@@ -110,6 +111,14 @@ describe('getSourceIconClass', () => {
110
111
ConfigUtils . DEFAULT_DATABASE_ICON_CLASS
111
112
) ;
112
113
} ) ;
114
+
115
+ it ( 'returns default class for features' , ( ) => {
116
+ const testId = 'fakeName' ;
117
+
118
+ expect ( ConfigUtils . getSourceIconClass ( testId , ResourceType . feature ) ) . toBe (
119
+ ConfigUtils . DEFAULT_DATABASE_ICON_CLASS
120
+ ) ;
121
+ } ) ;
113
122
} ) ;
114
123
115
124
it ( 'returns empty string for unconfigured resource' , ( ) => {
@@ -606,27 +615,58 @@ describe('getUniqueValueStatTypeName', () => {
606
615
607
616
expect ( ConfigUtils . getUniqueValueStatTypeName ( ) ) . toBe ( expectedValue ) ;
608
617
} ) ;
618
+
619
+ describe ( 'when stats not defined' , ( ) => {
620
+ it ( 'returns undefined' , ( ) => {
621
+ const expected = undefined ;
622
+
623
+ AppConfig . resourceConfig [ ResourceType . table ] . stats = expected ;
624
+ const actual = ConfigUtils . getUniqueValueStatTypeName ( ) ;
625
+
626
+ expect ( actual ) . toBe ( expected ) ;
627
+ } ) ;
628
+ } ) ;
609
629
} ) ;
610
630
611
631
describe ( 'getIconNotRequiredStatTypes' , ( ) => {
612
- it ( 'returns the stat types where, if they are the only ones present, the stats icon will not be displayed' , ( ) => {
613
- const expectedValue = [ 'test' ] ;
632
+ it ( 'returns undefined by default' , ( ) => {
633
+ const expected = undefined ;
634
+ const actual = ConfigUtils . getIconNotRequiredStatTypes ( ) ;
614
635
615
- AppConfig . resourceConfig [ ResourceType . table ] . stats = {
616
- iconNotRequiredTypes : expectedValue ,
617
- } ;
636
+ expect ( actual ) . toBe ( expected ) ;
637
+ } ) ;
638
+
639
+ describe ( 'when defined' , ( ) => {
640
+ it ( 'returns the stat types where, if they are the only ones present, the stats icon will not be displayed' , ( ) => {
641
+ const expectedValue = [ 'test' ] ;
642
+
643
+ AppConfig . resourceConfig [ ResourceType . table ] . stats = {
644
+ iconNotRequiredTypes : expectedValue ,
645
+ } ;
618
646
619
- expect ( ConfigUtils . getIconNotRequiredStatTypes ( ) ) . toBe ( expectedValue ) ;
647
+ expect ( ConfigUtils . getIconNotRequiredStatTypes ( ) ) . toBe ( expectedValue ) ;
648
+ } ) ;
620
649
} ) ;
621
650
} ) ;
622
651
623
652
describe ( 'getTableSortCriterias' , ( ) => {
624
- it ( 'returns the sorting criterias for tables ' , ( ) => {
653
+ it ( 'returns the sorting criterias' , ( ) => {
625
654
const expectedValue =
626
655
AppConfig . resourceConfig [ ResourceType . table ] . sortCriterias ;
627
656
628
657
expect ( ConfigUtils . getTableSortCriterias ( ) ) . toBe ( expectedValue ) ;
629
658
} ) ;
659
+
660
+ describe ( 'when the sortCriteria is not defined' , ( ) => {
661
+ it ( 'returns an empty object' , ( ) => {
662
+ const expected = { } ;
663
+
664
+ AppConfig . resourceConfig [ ResourceType . table ] . sortCriterias = undefined ;
665
+ const actual = ConfigUtils . getTableSortCriterias ( ) ;
666
+
667
+ expect ( actual ) . toEqual ( expected ) ;
668
+ } ) ;
669
+ } ) ;
630
670
} ) ;
631
671
632
672
describe ( 'getBadgeConfig' , ( ) => {
@@ -741,36 +781,88 @@ describe('getIssueDescriptionTemplate', () => {
741
781
} ) ;
742
782
743
783
describe ( 'issueTrackingProjectSelectionEnabled' , ( ) => {
744
- it ( 'returns whether or not project selection within the issueTracking feature is enabled' , ( ) => {
745
- const config = AppConfig . issueTracking . projectSelection ;
784
+ describe ( 'when set' , ( ) => {
785
+ it ( 'returns whether or not project selection within the issueTracking feature is enabled' , ( ) => {
786
+ const config = AppConfig . issueTracking . projectSelection ;
746
787
747
- expect ( ConfigUtils . issueTrackingProjectSelectionEnabled ( ) ) . toBe (
748
- config ? config . enabled : false
749
- ) ;
788
+ expect ( ConfigUtils . issueTrackingProjectSelectionEnabled ( ) ) . toBe (
789
+ config ? config . enabled : false
790
+ ) ;
791
+ } ) ;
792
+ } ) ;
793
+
794
+ describe ( 'when un-set' , ( ) => {
795
+ it ( 'returns false' , ( ) => {
796
+ AppConfig . issueTracking . projectSelection = undefined ;
797
+ const expected = false ;
798
+ const actual = ConfigUtils . issueTrackingProjectSelectionEnabled ( ) ;
799
+
800
+ expect ( actual ) . toBe ( expected ) ;
801
+ } ) ;
750
802
} ) ;
751
803
} ) ;
752
804
753
805
describe ( 'getProjectSelectionTitle' , ( ) => {
754
- it ( 'returns an issue description template string' , ( ) => {
755
- const config = AppConfig . issueTracking . projectSelection ;
806
+ it ( 'returns the default settings' , ( ) => {
807
+ AppConfig . issueTracking . projectSelection =
808
+ configDefault . issueTracking . projectSelection ;
809
+ const expected = configDefault . issueTracking . projectSelection ?. title ;
810
+ const actual = ConfigUtils . getProjectSelectionTitle ( ) ;
756
811
757
- if ( config ) config . title = 'Project key' ;
812
+ expect ( actual ) . toBe ( expected ) ;
813
+ } ) ;
758
814
759
- expect ( ConfigUtils . getProjectSelectionTitle ( ) ) . toBe (
760
- config ? config . title : ''
761
- ) ;
815
+ describe ( 'when set' , ( ) => {
816
+ it ( 'returns an issue description template string' , ( ) => {
817
+ const config = AppConfig . issueTracking . projectSelection ;
818
+
819
+ if ( config ) config . title = 'Project key' ;
820
+
821
+ expect ( ConfigUtils . getProjectSelectionTitle ( ) ) . toBe (
822
+ config ? config . title : ''
823
+ ) ;
824
+ } ) ;
825
+ } ) ;
826
+
827
+ describe ( 'when un-set' , ( ) => {
828
+ it ( 'returns an empty string' , ( ) => {
829
+ AppConfig . issueTracking . projectSelection = undefined ;
830
+ const expected = '' ;
831
+ const actual = ConfigUtils . getProjectSelectionTitle ( ) ;
832
+
833
+ expect ( actual ) . toBe ( expected ) ;
834
+ } ) ;
762
835
} ) ;
763
836
} ) ;
764
837
765
838
describe ( 'getProjectSelectionHint' , ( ) => {
766
- it ( 'returns an issue description template string' , ( ) => {
767
- const config = AppConfig . issueTracking . projectSelection ;
839
+ it ( 'returns the default settings' , ( ) => {
840
+ const expected = configDefault . issueTracking . projectSelection ?. inputHint ;
841
+ const actual = ConfigUtils . getProjectSelectionHint ( ) ;
768
842
769
- if ( config ) config . inputHint = 'PROJECTKEY' ;
843
+ expect ( actual ) . toBe ( expected ) ;
844
+ } ) ;
770
845
771
- expect ( ConfigUtils . getProjectSelectionHint ( ) ) . toBe (
772
- config ? config . inputHint : ''
773
- ) ;
846
+ describe ( 'when set' , ( ) => {
847
+ it ( 'returns an issue description template string' , ( ) => {
848
+ const config = AppConfig . issueTracking . projectSelection ;
849
+
850
+ if ( config ) config . inputHint = 'PROJECTKEY' ;
851
+
852
+ expect ( ConfigUtils . getProjectSelectionHint ( ) ) . toBe (
853
+ config ? config . inputHint : ''
854
+ ) ;
855
+ } ) ;
856
+ } ) ;
857
+
858
+ describe ( 'when un-set' , ( ) => {
859
+ it ( 'returns an empty string' , ( ) => {
860
+ AppConfig . issueTracking . projectSelection = undefined ;
861
+ const expected = '' ;
862
+ const actual = ConfigUtils . getProjectSelectionHint ( ) ;
863
+
864
+ expect ( actual ) . toBe ( expected ) ;
865
+ } ) ;
774
866
} ) ;
775
867
} ) ;
776
868
@@ -782,6 +874,25 @@ describe('indexDashboardsEnabled', () => {
782
874
} ) ;
783
875
} ) ;
784
876
877
+ describe ( 'indexFeaturesEnabled' , ( ) => {
878
+ it ( 'returns false by default' , ( ) => {
879
+ expect ( ConfigUtils . indexFeaturesEnabled ( ) ) . toBe (
880
+ AppConfig . indexFeatures . enabled
881
+ ) ;
882
+ } ) ;
883
+
884
+ describe ( 'when setting it' , ( ) => {
885
+ it ( 'returns whether or not the indexFeatures feature is enabled' , ( ) => {
886
+ const expected = true ;
887
+
888
+ AppConfig . indexFeatures . enabled = expected ;
889
+ const actual = ConfigUtils . indexFeaturesEnabled ( ) ;
890
+
891
+ expect ( actual ) . toBe ( expected ) ;
892
+ } ) ;
893
+ } ) ;
894
+ } ) ;
895
+
785
896
describe ( 'indexUsersEnabled' , ( ) => {
786
897
it ( 'returns whether or not the indexUsers feature is enabled' , ( ) => {
787
898
expect ( ConfigUtils . indexUsersEnabled ( ) ) . toBe ( AppConfig . indexUsers . enabled ) ;
0 commit comments