Skip to content

Commit b5ec549

Browse files
committed
Add functional test for repeated form elements. Passes in casper but fails in browser.
1 parent f4a691a commit b5ec549

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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"><input type="text" name="text{{$index}}" v-model="text"></p>
11+
<button v-on="click: add" id="add">Add</button>
12+
<p id="texts">{{texts}}</p>
13+
</form>
14+
<script>
15+
var app = new Vue({
16+
el: '#form',
17+
data: {
18+
items: [
19+
{ text: "a" },
20+
{ text: "b" }
21+
]
22+
},
23+
methods: {
24+
add: function(e) {
25+
this.items.push({ text: "c" });
26+
e.preventDefault();
27+
}
28+
},
29+
computed: {
30+
texts: {
31+
$get: function () {
32+
return this.items.map(function(item) { return item.text; }).join(",");
33+
}
34+
}
35+
}
36+
})
37+
</script>
38+
</body>
39+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
casper.test.begin('Repeated form elements', 4, function (test) {
2+
3+
casper
4+
.start('./fixtures/repeated-form-elements.html')
5+
.then(function () {
6+
test.assertSelectorHasText('#texts', 'a,b')
7+
})
8+
.thenClick('#add', function () {
9+
test.assertSelectorHasText('#texts', 'a,b,c')
10+
})
11+
.then(function () {
12+
this.fill('#form', {
13+
"text0": 'd',
14+
"text1": 'e',
15+
"text2": 'f',
16+
})
17+
})
18+
.then(function () {
19+
test.assertField('text0', 'd')
20+
test.assertSelectorHasText('#texts', 'd,e,f')
21+
})
22+
.run(function () {
23+
test.done()
24+
})
25+
26+
})

0 commit comments

Comments
 (0)