Skip to content

Commit 33fb50f

Browse files
author
Evan You
committed
functional test for custom elements
1 parent 3f60051 commit 33fb50f

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Custom Elements</title>
5+
<meta charset="utf-8">
6+
<script src="../../../dist/seed.js"></script>
7+
</head>
8+
<body>
9+
<my-element>afsefsefse</my-element>
10+
<cool>hmm</cool>
11+
<wow></wow>
12+
<script>
13+
// global custom element with option object + replace
14+
Seed.element('my-element', {
15+
replace: true,
16+
className: 'test',
17+
template: '<div>{{msg}}</div>'
18+
})
19+
new Seed({
20+
el:'body',
21+
scope: {
22+
msg: 'hihi',
23+
},
24+
elements: {
25+
// private custom element with simple function
26+
cool: function (el) {
27+
el.className = 'cool'
28+
el.innerHTML = 'This is cool'
29+
},
30+
// private custom element with constructor
31+
wow: Seed.extend({
32+
init: function () {
33+
this.$el.textContent = 'this is wow'
34+
}
35+
})
36+
}
37+
})
38+
</script>
39+
</body>
40+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
casper.test.begin('Custom Elements', 3, function (test) {
2+
3+
casper
4+
.start('./fixtures/custom-element.html', function () {
5+
test.assertSelectorHasText('div.test', 'hihi')
6+
test.assertSelectorHasText('cool.cool', 'This is cool')
7+
test.assertSelectorHasText('wow', 'this is wow')
8+
})
9+
.run(function () {
10+
test.done()
11+
})
12+
13+
})

0 commit comments

Comments
 (0)