Skip to content

Commit 75d200c

Browse files
author
Evan You
committed
simplify functional test fixtures
1 parent 77ffd53 commit 75d200c

17 files changed

+838
-972
lines changed
Lines changed: 43 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,43 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<title>Component</title>
5-
<meta charset="utf-8">
6-
</head>
7-
<body>
8-
<div id="test">
9-
<!-- v-component + v-with -->
10-
<div id="component-and-with" v-component="avatar" v-with="user"></div>
11-
12-
<!-- custom element + v-with -->
13-
<avatar id="element-and-with" v-with="user"></avatar>
14-
15-
<!-- v-with alone -->
16-
<div id="with" v-with="user">{{hi}} {{name}}</div>
17-
18-
<!-- v-component alone -->
19-
<div id="component" v-component="simple"></div>
20-
21-
<!-- custom element alone -->
22-
<simple id="element"></simple>
23-
</div>
24-
<script src="../../../dist/vue.js"></script>
25-
<script>
26-
27-
Vue.config({debug: true})
28-
29-
Vue.component('avatar', {
30-
template: '{{hi}} {{name}}',
31-
ready: function () {
32-
console.log(JSON.stringify(this))
33-
}
34-
})
35-
36-
Vue.component('simple', {
37-
template: '{{hi}} {{user.name}}'
38-
})
39-
40-
var app = new Vue({
41-
el: '#test',
42-
data: {
43-
hi: '123',
44-
user: {
45-
name: 'Jack'
46-
}
47-
}
48-
})
49-
</script>
50-
</body>
51-
</html>
1+
<div id="test">
2+
<!-- v-component + v-with -->
3+
<div id="component-and-with" v-component="avatar" v-with="user"></div>
4+
5+
<!-- custom element + v-with -->
6+
<avatar id="element-and-with" v-with="user"></avatar>
7+
8+
<!-- v-with alone -->
9+
<div id="with" v-with="user">{{hi}} {{name}}</div>
10+
11+
<!-- v-component alone -->
12+
<div id="component" v-component="simple"></div>
13+
14+
<!-- custom element alone -->
15+
<simple id="element"></simple>
16+
</div>
17+
18+
<script src="../../../dist/vue.js"></script>
19+
<script>
20+
21+
Vue.config({debug: true})
22+
23+
Vue.component('avatar', {
24+
template: '{{hi}} {{name}}',
25+
ready: function () {
26+
console.log(JSON.stringify(this))
27+
}
28+
})
29+
30+
Vue.component('simple', {
31+
template: '{{hi}} {{user.name}}'
32+
})
33+
34+
var app = new Vue({
35+
el: '#test',
36+
data: {
37+
hi: '123',
38+
user: {
39+
name: 'Jack'
40+
}
41+
}
42+
})
43+
</script>
Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,33 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<title>Repeated form elements</title>
5-
<meta charset="utf-8">
6-
<script src="../../../dist/vue.js"></script>
7-
</head>
8-
<body>
9-
<form id="form">
10-
<p v-repeat="items">
11-
<input type="text" name="text{{$index}}" v-model="text">
12-
</p>
13-
<button v-on="click: add" id="add">Add</button>
14-
<p id="texts">{{texts}}</p>
15-
</form>
16-
<script>
17-
var app = new Vue({
18-
el: '#form',
19-
data: {
20-
items: [
21-
{ text: "a" },
22-
{ text: "b" }
23-
]
24-
},
25-
methods: {
26-
add: function(e) {
27-
this.items.push({ text: "c" })
28-
e.preventDefault()
29-
}
30-
},
31-
computed: {
32-
texts: function () {
33-
return this.items.map(function(item) {
34-
return item.text
35-
}).join(",")
36-
}
37-
}
38-
})
39-
</script>
40-
</body>
41-
</html>
1+
<form id="form">
2+
<p v-repeat="items">
3+
<input type="text" name="text{{$index}}" v-model="text">
4+
</p>
5+
<button v-on="click: add" id="add">Add</button>
6+
<p id="texts">{{texts}}</p>
7+
</form>
8+
9+
<script src="../../../dist/vue.js"></script>
10+
<script>
11+
var app = new Vue({
12+
el: '#form',
13+
data: {
14+
items: [
15+
{ text: "a" },
16+
{ text: "b" }
17+
]
18+
},
19+
methods: {
20+
add: function(e) {
21+
this.items.push({ text: "c" })
22+
e.preventDefault()
23+
}
24+
},
25+
computed: {
26+
texts: function () {
27+
return this.items.map(function(item) {
28+
return item.text
29+
}).join(",")
30+
}
31+
}
32+
})
33+
</script>
Lines changed: 63 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,68 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<title></title>
5-
<meta charset="utf-8">
6-
<script src="../../../dist/vue.js"></script>
7-
</head>
8-
<body>
9-
<div id="normal">
10-
<p v-text="one + ' ' + two.three + '!'"></p>
11-
<input id="one" v-model="one" name="one"> <input id="two" v-model="two.three" name="two">
12-
<button v-on="click: this.one = 'clicked'">click</button>
13-
</div>
14-
<div id="lazy">
15-
<p v-text="one + ' ' + two.three + '!'"></p>
16-
<form id="form">
17-
<input v-model="one" name="three"> <input v-model="two.three" name="four">
18-
</form>
19-
<button v-on="click: two.three = 'clicked'">click</button>
20-
</div>
21-
<div id="conditional">
22-
<p>{{ok ? yesMsg : noMsg}}</p>
23-
<button v-on="click: ok = !ok" class="toggle">toggle</button>
24-
<button v-on="click: noMsg = 'Nah'" class="change">change</button>
25-
</div>
26-
<div id="attrs" data-test="hi {{msg}} ha"></div>
27-
<div id="html">html {{{html}}} work</div>
28-
<script>
29-
Vue.config({debug:true})
1+
<div id="normal">
2+
<p v-text="one + ' ' + two.three + '!'"></p>
3+
<input id="one" v-model="one" name="one"> <input id="two" v-model="two.three" name="two">
4+
<button v-on="click: this.one = 'clicked'">click</button>
5+
</div>
6+
<div id="lazy">
7+
<p v-text="one + ' ' + two.three + '!'"></p>
8+
<form id="form">
9+
<input v-model="one" name="three"> <input v-model="two.three" name="four">
10+
</form>
11+
<button v-on="click: two.three = 'clicked'">click</button>
12+
</div>
13+
<div id="conditional">
14+
<p>{{ok ? yesMsg : noMsg}}</p>
15+
<button v-on="click: ok = !ok" class="toggle">toggle</button>
16+
<button v-on="click: noMsg = 'Nah'" class="change">change</button>
17+
</div>
18+
<div id="attrs" data-test="hi {{msg}} ha"></div>
19+
<div id="html">html {{{html}}} work</div>
3020

31-
var normal = new Vue({
32-
el: '#normal',
33-
data: {
34-
one: 'Hello',
35-
two: {
36-
three: 'World'
37-
}
38-
}
39-
})
21+
<script src="../../../dist/vue.js"></script>
22+
<script>
23+
Vue.config({debug:true})
4024

41-
var lazy = new Vue({
42-
el: '#lazy',
43-
lazy: true,
44-
data: {
45-
one: 'Hi',
46-
two: {
47-
three: 'Ho'
48-
}
49-
}
50-
})
25+
var normal = new Vue({
26+
el: '#normal',
27+
data: {
28+
one: 'Hello',
29+
two: {
30+
three: 'World'
31+
}
32+
}
33+
})
5134

52-
var conditional = new Vue({
53-
el: '#conditional',
54-
data: {
55-
ok: true,
56-
yesMsg: 'YES',
57-
noMsg: 'NO'
58-
}
59-
})
35+
var lazy = new Vue({
36+
el: '#lazy',
37+
lazy: true,
38+
data: {
39+
one: 'Hi',
40+
two: {
41+
three: 'Ho'
42+
}
43+
}
44+
})
6045

61-
var attrs = new Vue({
62-
el: '#attrs',
63-
data: {
64-
msg: 'ho'
65-
}
66-
})
46+
var conditional = new Vue({
47+
el: '#conditional',
48+
data: {
49+
ok: true,
50+
yesMsg: 'YES',
51+
noMsg: 'NO'
52+
}
53+
})
6754

68-
var html = new Vue({
69-
el: '#html',
70-
data: {
71-
html: '<p>should</p> <a>probably</a>'
72-
}
73-
})
74-
</script>
75-
</body>
76-
</html>
55+
var attrs = new Vue({
56+
el: '#attrs',
57+
data: {
58+
msg: 'ho'
59+
}
60+
})
61+
62+
var html = new Vue({
63+
el: '#html',
64+
data: {
65+
html: '<p>should</p> <a>probably</a>'
66+
}
67+
})
68+
</script>

0 commit comments

Comments
 (0)