@@ -44,7 +44,20 @@ it('not transform with dynamic params', () => {
44
44
expect ( ast . i18n ) . toBeFalsy ( )
45
45
expect ( render ) . toEqual ( `with(this){return _c('p',{directives:[{name:"t",rawName:"v-t",value:(hello),expression:"hello"}]})}` )
46
46
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' )
48
61
spy . mockReset ( )
49
62
spy . mockRestore ( )
50
63
} )
@@ -56,7 +69,7 @@ it('not support value warning', () => {
56
69
expect ( ast . i18n ) . toBeFalsy ( )
57
70
expect ( render ) . toEqual ( `with(this){return _c('p',{directives:[{name:"t",rawName:"v-t",value:([1]),expression:"[1]"}]})}` )
58
71
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 ' )
60
73
spy . mockReset ( )
61
74
spy . mockRestore ( )
62
75
} )
@@ -77,6 +90,6 @@ it('detect missing translation', done => {
77
90
it ( 'fallback custom directive' , ( ) => {
78
91
const { ast, render, errors } = compile ( `<p v-t="'foo.bar'"></p>` )
79
92
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'" } )
81
94
expect ( errors ) . toEqual ( [ ] )
82
95
} )
0 commit comments