Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb7946a4

Browse files
committed
wip: fix tests with expected warnings
1 parent00c137f commitb7946a4

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

‎test/unit/modules/compiler/codegen.spec.js‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function assertCodegen (template, generatedCode, ...args) {
3232
describe('codegen',()=>{
3333
it('generate directive',()=>{
3434
assertCodegen(
35-
'<p v-custom1:arg1.modifier="value1" v-custom2><p>',
35+
'<p v-custom1:arg1.modifier="value1" v-custom2></p>',
3636
`with(this){return _h('p',{directives:[{name:"custom1",rawName:"v-custom1:arg1.modifier",value:(value1),expression:"value1",arg:"arg1",modifiers:{"modifier":true}},{name:"custom2",rawName:"v-custom2",arg:"arg1"}]})}`
3737
)
3838
})
@@ -46,26 +46,26 @@ describe('codegen', () => {
4646

4747
it('generate v-for directive',()=>{
4848
assertCodegen(
49-
'<li v-for="item in items" :key="item.uid"></li>',
50-
`with(this){return _l((items),function(item){return _h('li',{key:item.uid})})}`
49+
'<div><li v-for="item in items" :key="item.uid"></li></div>',
50+
`with(this){return_h('div',[_l((items),function(item){return _h('li',{key:item.uid})})])}`
5151
)
5252
// iterator syntax
5353
assertCodegen(
54-
'<li v-for="(item, i) in items"></li>',
55-
`with(this){return _l((items),function(item,i){return _h('li')})}`
54+
'<div><li v-for="(item, i) in items"></li></div>',
55+
`with(this){return_h('div',[_l((items),function(item,i){return _h('li')})])}`
5656
)
5757
assertCodegen(
58-
'<li v-for="(item, key, index) in items"></li>',
59-
`with(this){return _l((items),function(item,key,index){return _h('li')})}`
58+
'<div><li v-for="(item, key, index) in items"></li></div>',
59+
`with(this){return_h('div',[_l((items),function(item,key,index){return _h('li')})])}`
6060
)
6161
// destructuring
6262
assertCodegen(
63-
'<li v-for="{ a, b } in items"></li>',
64-
`with(this){return _l((items),function({ a, b }){return _h('li')})}`
63+
'<div><li v-for="{ a, b } in items"></li></div>',
64+
`with(this){return_h('div',[_l((items),function({ a, b }){return _h('li')})])}`
6565
)
6666
assertCodegen(
67-
'<li v-for="({ a, b }, key, index) in items"></li>',
68-
`with(this){return _l((items),function({ a, b },key,index){return _h('li')})}`
67+
'<div><li v-for="({ a, b }, key, index) in items"></li></div>',
68+
`with(this){return_h('div',[_l((items),function({ a, b },key,index){return _h('li')})])}`
6969
)
7070
})
7171

@@ -127,29 +127,29 @@ describe('codegen', () => {
127127

128128
it('generate template tag',()=>{
129129
assertCodegen(
130-
'<template><p>{{hello}}</p></template>',
131-
`with(this){return[_h('p',[_s(hello)])]}`
130+
'<div><template><p>{{hello}}</p></template></div>',
131+
`with(this){return_h('div',[[_h('p',[_s(hello)])]])}`
132132
)
133133
})
134134

135135
it('generate single slot',()=>{
136136
assertCodegen(
137-
'<slot></slot>',
138-
`with(this){return _t("default")}`
137+
'<div><slot></slot></div>',
138+
`with(this){return_h('div',[_t("default")])}`
139139
)
140140
})
141141

142142
it('generate named slot',()=>{
143143
assertCodegen(
144-
'<slot name="one"></slot>',
145-
`with(this){return _t("one")}`
144+
'<div><slot name="one"></slot></div>',
145+
`with(this){return_h('div',[_t("one")])}`
146146
)
147147
})
148148

149149
it('generate slot fallback content',()=>{
150150
assertCodegen(
151-
'<slot><div>hi</div></slot>',
152-
`with(this){return _t("default",[_h('div',["hi"])])}`
151+
'<div><slot><div>hi</div></slot></div>',
152+
`with(this){return_h('div',[_t("default",[_h('div',["hi"])])])}`
153153
)
154154
})
155155

@@ -356,8 +356,8 @@ describe('codegen', () => {
356356

357357
it('generate multiple event handlers',()=>{
358358
assertCodegen(
359-
'<input @input="curent++" @input="onInput">',
360-
`with(this){return _h('input',{on:{"input":[function($event){curent++},onInput]}})}`
359+
'<input @input="curent++" @input.stop="onInput">',
360+
`with(this){return _h('input',{on:{"input":[function($event){curent++},function($event){$event.stopPropagation();onInput($event)}]}})}`
361361
)
362362
})
363363

‎test/unit/modules/compiler/optimizer.spec.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,17 @@ describe('optimizer', () => {
9898
})
9999

100100
it('single slot',()=>{
101-
constast=parse('<slot>hello</slot>',baseOptions)
101+
constast=parse('<div><slot>hello</slot></div>',baseOptions)
102102
optimize(ast,baseOptions)
103-
expect(ast.static).toBe(false)// slot
104-
expect(ast.children[0].static).toBe(true)// text node
103+
expect(ast.children[0].static).toBe(false)// slot
104+
expect(ast.children[0].children[0].static).toBe(true)// text node
105105
})
106106

107107
it('named slot',()=>{
108-
constast=parse('<slot name="one">hello world</slot>',baseOptions)
108+
constast=parse('<div><slot name="one">hello world</slot></div>',baseOptions)
109109
optimize(ast,baseOptions)
110-
expect(ast.static).toBe(false)// slot
111-
expect(ast.children[0].static).toBe(true)// text node
110+
expect(ast.children[0].static).toBe(false)// slot
111+
expect(ast.children[0].children[0].static).toBe(true)// text node
112112
})
113113

114114
it('slot target',()=>{

‎test/unit/modules/compiler/parser.spec.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,15 @@ describe('parser', () => {
306306
})
307307

308308
it('slot tag single syntax',()=>{
309-
constast=parse('<slot></slot>',baseOptions)
310-
expect(ast.tag).toBe('slot')
311-
expect(ast.slotName).toBeUndefined()
309+
constast=parse('<div><slot></slot></div>',baseOptions)
310+
expect(ast.children[0].tag).toBe('slot')
311+
expect(ast.children[0].slotName).toBeUndefined()
312312
})
313313

314314
it('slot tag namped syntax',()=>{
315-
constast=parse('<slot name="one">hello world</slot>',baseOptions)
316-
expect(ast.tag).toBe('slot')
317-
expect(ast.slotName).toBe('"one"')
315+
constast=parse('<div><slot name="one">hello world</slot></div>',baseOptions)
316+
expect(ast.children[0].tag).toBe('slot')
317+
expect(ast.children[0].slotName).toBe('"one"')
318318
})
319319

320320
it('slot target',()=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp