@@ -44,7 +44,20 @@ it('not transform with dynamic params', () => {
4444 expect ( ast . i18n ) . toBeFalsy ( )
4545 expect ( render ) . toEqual ( `with(this){return _c('p',{directives:[{name:"t",rawName:"v-t",value:(hello),expression:"hello"}]})}` )
4646 expect ( errors ) . toEqual ( [ ] )
47- expect ( spy . mock . calls [ 0 ] [ 0 ] ) . toEqual ( '[vue-i18n-extensions] pre-localization with v-t support only static params' )
47+ expect ( spy . mock . calls [ 0 ] [ 0 ] ) . toEqual ( '[vue-i18n-extensions] not support params in pre-localization' )
48+ spy . mockReset ( )
49+ spy . mockRestore ( )
50+ } )
51+
52+ it ( 'not support ecmascript keywords' , ( ) => {
53+ const spy = jest . spyOn ( global . console , 'warn' )
54+ spy . mockImplementation ( x => x )
55+ const { ast, render, errors } = compile ( `<p v-t="while(true){alert('!');"></p>` , { modules : [ i18nModule ] } )
56+ expect ( ast . i18n ) . toBeFalsy ( )
57+ expect ( render ) . toEqual ( `with(this){return _c('p',{directives:[{name:"t",rawName:"v-t",value:(while(true){alert('!');),expression:"while(true){alert('!');"}]})}` )
58+ expect ( errors ) . toEqual ( [ `avoid using JavaScript keyword as property name: \"while\"
59+ Raw expression: v-t=\"while(true){alert('!');\"` ] )
60+ expect ( spy . mock . calls [ 0 ] [ 0 ] ) . toEqual ( '[vue-i18n-extensions] not support params in pre-localization' )
4861 spy . mockReset ( )
4962 spy . mockRestore ( )
5063} )
@@ -56,7 +69,7 @@ it('not support value warning', () => {
5669 expect ( ast . i18n ) . toBeFalsy ( )
5770 expect ( render ) . toEqual ( `with(this){return _c('p',{directives:[{name:"t",rawName:"v-t",value:([1]),expression:"[1]"}]})}` )
5871 expect ( errors ) . toEqual ( [ ] )
59- expect ( spy . mock . calls [ 0 ] [ 0 ] ) . toEqual ( '[vue-i18n-extensions] not support value type ' )
72+ expect ( spy . mock . calls [ 0 ] [ 0 ] ) . toEqual ( '[vue-i18n-extensions] not support params in pre-localization ' )
6073 spy . mockReset ( )
6174 spy . mockRestore ( )
6275} )
@@ -77,6 +90,6 @@ it('detect missing translation', done => {
7790it ( 'fallback custom directive' , ( ) => {
7891 const { ast, render, errors } = compile ( `<p v-t="'foo.bar'"></p>` )
7992 expect ( ast . i18n ) . toBeFalsy ( )
80- expect ( ast . directives [ 0 ] ) . toEqual ( { name : 't' , rawName : ' v-t' , value : '\' foo.bar\'' , arg : null , modifiers : undefined } )
93+ expect ( ast . directives [ 0 ] ) . toEqual ( { "arg" : null , "isDynamicArg" : false , "modifiers" : undefined , " name" : "t" , " rawName" : " v-t" , " value" : "' foo.bar'" } )
8194 expect ( errors ) . toEqual ( [ ] )
8295} )
0 commit comments