@@ -974,6 +974,115 @@ async (t) => {
974
974
t . true ( t . context . logErrorSpy . notCalled , "No errors should be logged" ) ;
975
975
} ) ;
976
976
977
+ test ( "Application: sap.ui5/models: " +
978
+ "No warning when fallbackLocale is empty string and is part of supportedLocales" ,
979
+ async ( t ) => {
980
+ const { manifestEnhancer, fs, createResource} = t . context ;
981
+ const input = JSON . stringify ( {
982
+ "_version" : "1.58.0" ,
983
+ "sap.app" : {
984
+ "id" : "sap.ui.demo.app" ,
985
+ "type" : "application"
986
+ } ,
987
+ "sap.ui5" : {
988
+ "models" : {
989
+ "i18n" : {
990
+ "type" : "sap.ui.model.resource.ResourceModel" ,
991
+ "settings" : {
992
+ "bundleName" : "sap.ui.demo.app.i18nModel.i18n" ,
993
+ "fallbackLocale" : ""
994
+ }
995
+ }
996
+ }
997
+ }
998
+ } , null , 2 ) ;
999
+
1000
+ const expected = JSON . stringify ( {
1001
+ "_version" : "1.58.0" ,
1002
+ "sap.app" : {
1003
+ "id" : "sap.ui.demo.app" ,
1004
+ "type" : "application"
1005
+ } ,
1006
+ "sap.ui5" : {
1007
+ "models" : {
1008
+ "i18n" : {
1009
+ "type" : "sap.ui.model.resource.ResourceModel" ,
1010
+ "settings" : {
1011
+ "bundleName" : "sap.ui.demo.app.i18nModel.i18n" ,
1012
+ "fallbackLocale" : "" ,
1013
+ "supportedLocales" : [ "" ]
1014
+ }
1015
+ }
1016
+ }
1017
+ }
1018
+ } , null , 2 ) ;
1019
+
1020
+ const resource = createResource ( "/resources/sap/ui/demo/app/manifest.json" , true , input ) ;
1021
+
1022
+ fs . readdir . withArgs ( "/resources/sap/ui/demo/app/i18nModel" )
1023
+ . callsArgWith ( 1 , null , [ "i18n.properties" ] ) ;
1024
+
1025
+ const processedResources = await manifestEnhancer ( {
1026
+ resources : [ resource ] ,
1027
+ fs
1028
+ } ) ;
1029
+
1030
+ t . deepEqual ( processedResources , [ resource ] , "Input resource is returned" ) ;
1031
+
1032
+ t . is ( resource . setString . callCount , 1 , "setString should be called once" ) ;
1033
+ t . deepEqual ( resource . setString . getCall ( 0 ) . args , [ expected ] , "Correct file content should be set" ) ;
1034
+
1035
+ t . true ( t . context . logVerboseSpy . notCalled , "No verbose messages should be logged" ) ;
1036
+ t . true ( t . context . logWarnSpy . notCalled , "No warnings should be logged" ) ;
1037
+ t . true ( t . context . logErrorSpy . notCalled , "No errors should be logged" ) ;
1038
+ } ) ;
1039
+
1040
+ test ( "Application: sap.ui5/models: " +
1041
+ "Error when fallbackLocale is empty string and is not part of supportedLocales" ,
1042
+ async ( t ) => {
1043
+ const { manifestEnhancer, fs, createResource} = t . context ;
1044
+ const input = JSON . stringify ( {
1045
+ "_version" : "1.58.0" ,
1046
+ "sap.app" : {
1047
+ "id" : "sap.ui.demo.app" ,
1048
+ "type" : "application"
1049
+ } ,
1050
+ "sap.ui5" : {
1051
+ "models" : {
1052
+ "i18n" : {
1053
+ "type" : "sap.ui.model.resource.ResourceModel" ,
1054
+ "settings" : {
1055
+ "bundleName" : "sap.ui.demo.app.i18nModel.i18n" ,
1056
+ "fallbackLocale" : ""
1057
+ }
1058
+ }
1059
+ }
1060
+ }
1061
+ } , null , 2 ) ;
1062
+
1063
+ const resource = createResource ( "/resources/sap/ui/demo/app/manifest.json" , true , input ) ;
1064
+
1065
+ fs . readdir . withArgs ( "/resources/sap/ui/demo/app/i18nModel" )
1066
+ . callsArgWith ( 1 , null , [ "i18n_en.properties" ] ) ;
1067
+
1068
+ const processedResources = await manifestEnhancer ( {
1069
+ resources : [ resource ] ,
1070
+ fs
1071
+ } ) ;
1072
+
1073
+ t . deepEqual ( processedResources , [ ] , "Only enhanced resources are returned" ) ;
1074
+
1075
+ t . is ( resource . setString . callCount , 0 , "setString should not be called" ) ;
1076
+
1077
+ t . true ( t . context . logVerboseSpy . notCalled , "No verbose messages should be logged" ) ;
1078
+ t . true ( t . context . logWarnSpy . notCalled , "No warnings should be logged" ) ;
1079
+ t . is ( t . context . logErrorSpy . callCount , 1 , "One error should be logged" ) ;
1080
+ t . deepEqual ( t . context . logErrorSpy . getCall ( 0 ) . args , [
1081
+ "/resources/sap/ui/demo/app/manifest.json: Generated supported locales ('en') for " +
1082
+ "bundle 'i18nModel/i18n.properties' not containing the defined fallback locale ''. " +
1083
+ "Either provide a properties file for defined fallbackLocale or configure another available fallbackLocale" ] ) ;
1084
+ } ) ;
1085
+
977
1086
test ( "Application: sap.ui5/models: Log verbose if manifest version is not defined at all" , async ( t ) => {
978
1087
const { manifestEnhancer, fs, createResource} = t . context ;
979
1088
const input = JSON . stringify ( {
0 commit comments