File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ export const isMessageFunction = <T>(val: unknown): val is MessageFunction<T> =>
55
55
isFunction ( val )
56
56
57
57
export const isMessageAST = ( val : unknown ) : val is ResourceNode =>
58
- isObject ( val ) && val . type === 0 && 'body' in val
58
+ isObject ( val ) && val . type === 0 && ( 'body' in val || 'b' in val )
59
59
60
60
/**
61
61
* # translate
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ vi.mock('@intlify/shared', async () => {
13
13
} )
14
14
15
15
import { createCoreContext as context , NOT_REOSLVED } from '../src/context'
16
- import { translate } from '../src/translate'
16
+ import { translate , isMessageAST } from '../src/translate'
17
17
import { CoreErrorCodes , errorMessages } from '../src/errors'
18
18
import {
19
19
registerMessageCompiler ,
@@ -992,4 +992,24 @@ describe('AST passing', () => {
992
992
} )
993
993
} )
994
994
995
+ describe ( 'isMessageAST' , ( ) => {
996
+ describe ( 'basic AST' , ( ) => {
997
+ test ( 'should be true' , ( ) => {
998
+ expect ( isMessageAST ( { type : 0 , body : '' } ) ) . toBe ( true )
999
+ } )
1000
+ } )
1001
+
1002
+ describe ( 'minify AST' , ( ) => {
1003
+ test ( 'should be true' , ( ) => {
1004
+ expect ( isMessageAST ( { type : 0 , b : '' } ) ) . toBe ( true )
1005
+ } )
1006
+ } )
1007
+
1008
+ describe ( 'not message compiler AST format' , ( ) => {
1009
+ test ( 'should be false' , ( ) => {
1010
+ expect ( isMessageAST ( { b : '' } ) ) . toBe ( false )
1011
+ } )
1012
+ } )
1013
+ } )
1014
+
995
1015
/* eslint-enable @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any */
You can’t perform that action at this time.
0 commit comments