@@ -227,22 +227,17 @@ describe("TranslateService", () => {
227227 } ) ;
228228 } ) ;
229229
230- it ( "should throw if you forget the key" , ( ) => {
230+ it ( "Should ignore if you forget the key" , ( ) => {
231231 translate . use ( "en" ) ;
232232
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+ } ) ;
241237
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+ } ) ;
246241 } ) ;
247242
248243 it ( "should be able to get translations with nested keys" , ( ) => {
@@ -1066,24 +1061,20 @@ describe("TranslateService (Error Conditions and Recovery)", () => {
10661061
10671062 describe ( "Invalid Parameter Handling" , ( ) => {
10681063 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+ } ) ;
10741068
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+ } ) ;
10811073
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+ } ) ;
10871078 } ) ;
10881079
10891080 it ( "should handle array with invalid elements" , ( ) => {
0 commit comments