Skip to content

Commit 6024e0b

Browse files
committed
more test cases for transition+repeat
1 parent a575cbb commit 6024e0b

File tree

2 files changed

+48
-12
lines changed

2 files changed

+48
-12
lines changed

test/functional/fixtures/transition.html

+13-8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
.v-leave {
2424
background-color: #0f0;
2525
}
26+
ul {
27+
padding: 0;
28+
}
2629
</style>
2730

2831
<div id="test">
@@ -34,14 +37,16 @@
3437
<button class="pop" v-on="click:pop">pop</button>
3538
<button class="splice" v-on="click:splice">splice</button>
3639
</div>
37-
<div
38-
class="test"
39-
v-repeat="items"
40-
v-show="filter(this)"
41-
v-transition
42-
v-attr="data-id:a">
43-
{{a}}
44-
</div>
40+
<ul>
41+
<li
42+
class="test"
43+
v-repeat="items"
44+
v-show="filter(this)"
45+
v-transition
46+
v-attr="data-id:a">
47+
{{a}}
48+
</li>
49+
</ul>
4550
<div class="test if" v-transition v-if="items.length > 1">This is only visible when item.length > 1</div>
4651
</div>
4752
<h1 style="margin:0">123</h1>

test/functional/specs/transition.js

+35-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
casper.test.begin('CSS Transition', 20, function (test) {
1+
casper.test.begin('CSS Transition', 37, function (test) {
22

33
var minWait = 50,
44
transDuration = 200
@@ -42,20 +42,51 @@ casper.test.begin('CSS Transition', 20, function (test) {
4242
.wait(transDuration, function () {
4343
test.assertNotVisible('.test.if')
4444
test.assertNotVisible('.test[data-id="1"]')
45-
test.assertNotVisible('.test[data-id="2"]')
4645
})
4746
.thenClick('.splice')
4847
.wait(minWait, function () {
4948
test.assertVisible('.test[data-id="99"]')
5049
})
5150
// test Array swapping with transition
5251
.thenEvaluate(function () {
53-
test.items = [test.items[0], {a:3}]
52+
test.items = [{a:1}, {a:2}, {a:3}, {a:4}, {a:5}]
5453
})
5554
.wait(minWait, function () {
5655
test.assertVisible('.test.if')
57-
test.assertVisible('.test[data-id="99"]')
56+
test.assertElementCount('.test', 7)
57+
test.assertElementCount('.test[data-id="99"].v-leave', 1)
58+
test.assertNotVisible('.test[data-id="1"]')
59+
test.assertNotVisible('.test[data-id="2"]')
5860
test.assertVisible('.test[data-id="3"]')
61+
test.assertVisible('.test[data-id="4"]')
62+
test.assertVisible('.test[data-id="5"]')
63+
})
64+
.wait(transDuration, function () {
65+
// old one should be removed now
66+
test.assertElementCount('.test', 6)
67+
test.assertElementCount('.test.v-leave', 0)
68+
test.assertElementCount('.test[data-id="99"]', 0)
69+
})
70+
// test Array diffing with transition
71+
.thenEvaluate(function () {
72+
test.items = [test.items[4], {a:6}, test.items[2], {a:7}, test.items[0]]
73+
})
74+
.wait(minWait, function () {
75+
// reusing 3 existing, one of the destroyed (a=2) is hidden, so only 1 item should be leaving
76+
test.assertElementCount('.test.v-leave', 1)
77+
// only 2 new items should be in the DOM, the hidden element is removed immediately
78+
// so should have 5 + 1 + 1 = 7 items
79+
test.assertElementCount('.test', 7)
80+
})
81+
.wait(transDuration, function () {
82+
test.assertElementCount('.test.v-leave', 0)
83+
test.assertElementCount('.test', 6)
84+
test.assertSelectorHasText('li.test:nth-child(1)', '5')
85+
test.assertSelectorHasText('li.test:nth-child(2)', '6')
86+
test.assertSelectorHasText('li.test:nth-child(3)', '3')
87+
test.assertSelectorHasText('li.test:nth-child(4)', '7')
88+
test.assertSelectorHasText('li.test:nth-child(5)', '1')
89+
test.assertNotVisible('li.test:nth-child(5)')
5990
})
6091
.run(function () {
6192
test.done()

0 commit comments

Comments
 (0)