@@ -227,22 +227,17 @@ describe("TranslateService", () => {
227
227
} ) ;
228
228
} ) ;
229
229
230
- it ( "should throw if you forget the key" , ( ) => {
230
+ it ( "Should ignore if you forget the key" , ( ) => {
231
231
translate . use ( "en" ) ;
232
232
233
- expect ( ( ) => {
234
- const key : Record < string , string > = { } ;
235
- translate . get ( key [ "x" ] ) ;
236
- } ) . toThrowError ( 'Parameter "key" is required and cannot be empty' ) ;
237
-
238
- expect ( ( ) => {
239
- translate . get ( "" ) ;
240
- } ) . toThrowError ( 'Parameter "key" is required and cannot be empty' ) ;
233
+ const key : Record < string , string > = { } ;
234
+ translate . get ( key [ "x" ] ) . subscribe ( ( res : Translation ) => {
235
+ expect ( res ) . toEqual ( "" ) ;
236
+ } ) ;
241
237
242
- expect ( ( ) => {
243
- const key : Record < string , string > = { } ;
244
- translate . instant ( key [ "x" ] ) ;
245
- } ) . toThrowError ( 'Parameter "key" is required and cannot be empty' ) ;
238
+ translate . get ( "" ) . subscribe ( ( res : Translation ) => {
239
+ expect ( res ) . toEqual ( "" ) ;
240
+ } ) ;
246
241
} ) ;
247
242
248
243
it ( "should be able to get translations with nested keys" , ( ) => {
@@ -1066,24 +1061,20 @@ describe("TranslateService (Error Conditions and Recovery)", () => {
1066
1061
1067
1062
describe ( "Invalid Parameter Handling" , ( ) => {
1068
1063
it ( "should handle null parameters gracefully" , ( ) => {
1069
- expect ( ( ) => {
1070
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1071
- translate . get ( null as any ) ;
1072
- } ) . toThrowError ( 'Parameter "key" is required and cannot be empty' ) ;
1073
- } ) ;
1064
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1065
+ translate . get ( null as any ) . subscribe ( ( res : Translation ) => {
1066
+ expect ( res ) . toEqual ( "" ) ;
1067
+ } ) ;
1074
1068
1075
- it ( "should handle undefined parameters gracefully" , ( ) => {
1076
- expect ( ( ) => {
1077
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1078
- translate . get ( undefined as any ) ;
1079
- } ) . toThrowError ( 'Parameter "key" is required and cannot be empty' ) ;
1080
- } ) ;
1069
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1070
+ translate . get ( undefined as any ) . subscribe ( ( res : Translation ) => {
1071
+ expect ( res ) . toEqual ( "" ) ;
1072
+ } ) ;
1081
1073
1082
- it ( "should handle non-string parameters gracefully" , ( ) => {
1083
- expect ( ( ) => {
1084
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1085
- translate . get ( 123 as any ) ;
1086
- } ) . toThrowError ( 'Parameter "key" is required and cannot be empty' ) ;
1074
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1075
+ translate . get ( 123 as any ) . subscribe ( ( res : Translation ) => {
1076
+ expect ( res ) . toEqual ( "" ) ;
1077
+ } ) ;
1087
1078
} ) ;
1088
1079
1089
1080
it ( "should handle array with invalid elements" , ( ) => {
0 commit comments