Skip to content

Commit bb7300d

Browse files
author
Evan You
committed
functional test for routing
1 parent 2b57094 commit bb7300d

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

test/functional/fixtures/routing.html

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>route</title>
5+
<meta charset="utf-8">
6+
<script src="bind.js"></script>
7+
<script src="../../../dist/seed.js"></script>
8+
</head>
9+
<body>
10+
<div sd-if="route.hi">Hi! <a href="#ho">Next</a></div>
11+
<div sd-if="route.ho">Ho! <a href="#ha">Next</a></div>
12+
<div sd-if="route.ha">Ha! <a href="#hi">Next</a></div>
13+
<script>
14+
15+
var route = {
16+
hi: false,
17+
ho: false,
18+
ha: false
19+
}
20+
21+
window.addEventListener('hashchange', updateRoute)
22+
function updateRoute () {
23+
var path = location.hash.slice(1) || 'hi'
24+
for (var key in route) {
25+
route[key] = key === path
26+
}
27+
}
28+
29+
var app = new Seed({
30+
el: 'body'
31+
})
32+
app.route = route
33+
34+
updateRoute()
35+
</script>
36+
</body>
37+
</html>

test/functional/specs/routing.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
casper.test.begin('Routing', 10, function (test) {
2+
3+
casper
4+
.start('./fixtures/routing.html', function () {
5+
test.assertElementCount('div', 1)
6+
test.assertSelectorHasText('div', 'Hi!')
7+
})
8+
.thenClick('a', function () {
9+
test.assertElementCount('div', 1)
10+
test.assertSelectorHasText('div', 'Ho!')
11+
})
12+
.thenClick('a', function () {
13+
test.assertElementCount('div', 1)
14+
test.assertSelectorHasText('div', 'Ha!')
15+
})
16+
.thenClick('a', function () {
17+
test.assertElementCount('div', 1)
18+
test.assertSelectorHasText('div', 'Hi!')
19+
})
20+
.thenOpen('./fixtures/routing.html#ho', function () {
21+
test.assertElementCount('div', 1)
22+
test.assertSelectorHasText('div', 'Ho!')
23+
})
24+
.run(function () {
25+
test.done()
26+
})
27+
28+
})

0 commit comments

Comments
 (0)