File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ exports.iciba = (data, options = {}) => {
2424 }
2525
2626 // phonetic symbol
27- data . ps ?. forEach ( ( item , i ) => {
27+ data . ps ?. forEach ?. ( ( item , i ) => {
2828 firstLine += chalk . magenta ( ` ${ i === 0 ? '英' : '美' } [ ${ item } ] ` ) ;
2929 } ) ;
3030
@@ -35,7 +35,7 @@ exports.iciba = (data, options = {}) => {
3535 }
3636
3737 // pos & acceptation
38- data . pos ?. forEach ( ( item , i ) => {
38+ data . pos ?. forEach ?. ( ( item , i ) => {
3939 if ( typeof data . pos [ i ] !== 'string' || ! data . pos [ i ] ) {
4040 return ;
4141 }
@@ -48,7 +48,7 @@ exports.iciba = (data, options = {}) => {
4848 log ( ) ;
4949 }
5050
51- data . sent ?. forEach ( ( item , i ) => {
51+ data . sent ?. forEach ?. ( ( item , i ) => {
5252 if ( typeof item . orig !== 'string' && item . orig [ 0 ] ) {
5353 item . orig = item . orig [ 0 ] . trim ( ) ;
5454 }
Original file line number Diff line number Diff line change @@ -71,4 +71,9 @@ describe('fanyi CLI', () => {
7171 const { stdout } = await runScript ( [ 'list' ] ) ;
7272 expect ( stdout ) . toContain ( 'fanyi history:' ) ;
7373 } ) ;
74+
75+ it ( 'should not print error when translate "ant love"' , async ( ) => {
76+ const { stderr } = await runScript ( [ 'ant love' ] ) ;
77+ expect ( stderr ) . not . toContain ( '访问 iciba 失败' ) ;
78+ } ) ;
7479} ) ;
You can’t perform that action at this time.
0 commit comments