@@ -790,4 +790,204 @@ describe('ContentFeature class', () => {
790
790
expect ( result ) . toBe ( false ) ;
791
791
} ) ;
792
792
} ) ;
793
+
794
+ describe ( 'internal condition' , ( ) => {
795
+ it ( 'should match when internal is true and condition is true' , ( ) => {
796
+ class MyTestFeature extends ContentFeature {
797
+ testMatchInternalConditional ( conditionBlock ) {
798
+ return this . _matchInternalConditional ( conditionBlock ) ;
799
+ }
800
+ }
801
+
802
+ const args = {
803
+ site : {
804
+ domain : 'example.com' ,
805
+ url : 'http://example.com' ,
806
+ } ,
807
+ platform : {
808
+ name : 'test' ,
809
+ internal : true ,
810
+ } ,
811
+ } ;
812
+
813
+ const feature = new MyTestFeature ( 'test' , { } , args ) ;
814
+ const result = feature . testMatchInternalConditional ( {
815
+ internal : true ,
816
+ } ) ;
817
+ expect ( result ) . toBe ( true ) ;
818
+ } ) ;
819
+
820
+ it ( 'should match when internal is false and condition is false' , ( ) => {
821
+ class MyTestFeature extends ContentFeature {
822
+ testMatchInternalConditional ( conditionBlock ) {
823
+ return this . _matchInternalConditional ( conditionBlock ) ;
824
+ }
825
+ }
826
+
827
+ const args = {
828
+ site : {
829
+ domain : 'example.com' ,
830
+ url : 'http://example.com' ,
831
+ } ,
832
+ platform : {
833
+ name : 'test' ,
834
+ internal : false ,
835
+ } ,
836
+ } ;
837
+
838
+ const feature = new MyTestFeature ( 'test' , { } , args ) ;
839
+ const result = feature . testMatchInternalConditional ( {
840
+ internal : false ,
841
+ } ) ;
842
+ expect ( result ) . toBe ( true ) ;
843
+ } ) ;
844
+
845
+ it ( 'should not match when internal is true but condition is false' , ( ) => {
846
+ class MyTestFeature extends ContentFeature {
847
+ testMatchInternalConditional ( conditionBlock ) {
848
+ return this . _matchInternalConditional ( conditionBlock ) ;
849
+ }
850
+ }
851
+
852
+ const args = {
853
+ site : {
854
+ domain : 'example.com' ,
855
+ url : 'http://example.com' ,
856
+ } ,
857
+ platform : {
858
+ name : 'test' ,
859
+ internal : true ,
860
+ } ,
861
+ } ;
862
+
863
+ const feature = new MyTestFeature ( 'test' , { } , args ) ;
864
+ const result = feature . testMatchInternalConditional ( {
865
+ internal : false ,
866
+ } ) ;
867
+ expect ( result ) . toBe ( false ) ;
868
+ } ) ;
869
+
870
+ it ( 'should not match when internal is false but condition is true' , ( ) => {
871
+ class MyTestFeature extends ContentFeature {
872
+ testMatchInternalConditional ( conditionBlock ) {
873
+ return this . _matchInternalConditional ( conditionBlock ) ;
874
+ }
875
+ }
876
+
877
+ const args = {
878
+ site : {
879
+ domain : 'example.com' ,
880
+ url : 'http://example.com' ,
881
+ } ,
882
+ platform : {
883
+ name : 'test' ,
884
+ internal : false ,
885
+ } ,
886
+ } ;
887
+
888
+ const feature = new MyTestFeature ( 'test' , { } , args ) ;
889
+ const result = feature . testMatchInternalConditional ( {
890
+ internal : true ,
891
+ } ) ;
892
+ expect ( result ) . toBe ( false ) ;
893
+ } ) ;
894
+
895
+ it ( 'should handle undefined internal state gracefully' , ( ) => {
896
+ class MyTestFeature extends ContentFeature {
897
+ testMatchInternalConditional ( conditionBlock ) {
898
+ return this . _matchInternalConditional ( conditionBlock ) ;
899
+ }
900
+ }
901
+
902
+ const args = {
903
+ site : {
904
+ domain : 'example.com' ,
905
+ url : 'http://example.com' ,
906
+ } ,
907
+ platform : {
908
+ name : 'test' ,
909
+ // internal not set
910
+ } ,
911
+ } ;
912
+
913
+ const feature = new MyTestFeature ( 'test' , { } , args ) ;
914
+ const result = feature . testMatchInternalConditional ( {
915
+ internal : true ,
916
+ } ) ;
917
+ expect ( result ) . toBe ( false ) ;
918
+ } ) ;
919
+
920
+ it ( 'should handle missing internal condition' , ( ) => {
921
+ class MyTestFeature extends ContentFeature {
922
+ testMatchInternalConditional ( conditionBlock ) {
923
+ return this . _matchInternalConditional ( conditionBlock ) ;
924
+ }
925
+ }
926
+
927
+ const args = {
928
+ site : {
929
+ domain : 'example.com' ,
930
+ url : 'http://example.com' ,
931
+ } ,
932
+ platform : {
933
+ name : 'test' ,
934
+ internal : true ,
935
+ } ,
936
+ } ;
937
+
938
+ const feature = new MyTestFeature ( 'test' , { } , args ) ;
939
+ const result = feature . testMatchInternalConditional ( { } ) ;
940
+ expect ( result ) . toBe ( false ) ;
941
+ } ) ;
942
+
943
+ it ( 'should handle truthy values for internal condition' , ( ) => {
944
+ class MyTestFeature extends ContentFeature {
945
+ testMatchInternalConditional ( conditionBlock ) {
946
+ return this . _matchInternalConditional ( conditionBlock ) ;
947
+ }
948
+ }
949
+
950
+ const args = {
951
+ site : {
952
+ domain : 'example.com' ,
953
+ url : 'http://example.com' ,
954
+ } ,
955
+ platform : {
956
+ name : 'test' ,
957
+ internal : 1 , // truthy value
958
+ } ,
959
+ } ;
960
+
961
+ const feature = new MyTestFeature ( 'test' , { } , args ) ;
962
+ const result = feature . testMatchInternalConditional ( {
963
+ internal : true ,
964
+ } ) ;
965
+ expect ( result ) . toBe ( true ) ;
966
+ } ) ;
967
+
968
+ it ( 'should handle falsy values for internal condition' , ( ) => {
969
+ class MyTestFeature extends ContentFeature {
970
+ testMatchInternalConditional ( conditionBlock ) {
971
+ return this . _matchInternalConditional ( conditionBlock ) ;
972
+ }
973
+ }
974
+
975
+ const args = {
976
+ site : {
977
+ domain : 'example.com' ,
978
+ url : 'http://example.com' ,
979
+ } ,
980
+ platform : {
981
+ name : 'test' ,
982
+ internal : 0 , // falsy value
983
+ } ,
984
+ } ;
985
+
986
+ const feature = new MyTestFeature ( 'test' , { } , args ) ;
987
+ const result = feature . testMatchInternalConditional ( {
988
+ internal : false ,
989
+ } ) ;
990
+ expect ( result ) . toBe ( true ) ;
991
+ } ) ;
992
+ } ) ;
793
993
} ) ;
0 commit comments