Skip to content

Commit

Permalink
add tests for MDV syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Jun 10, 2013
1 parent 5eaf4b8 commit 09bd6cf
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions test/html/mdv-syntax.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>mdv syntax</title>
<script src="../../polymer.js"></script>
<script src="../../tools/test/htmltest.js"></script>
<script src="../../node_modules/chai/chai.js"></script>
</head>
<body>
<!-- bind -->
<element name="mdv-bind" attributes="test">
<template>
<template bind="{{test.value as v}}">
<span id="output">{{v}}</span>
</template>
</template>
<script>
Polymer.register(this, {
testbind: function() {
var o = this.webkitShadowRoot.querySelector('#output');
chai.assert.equal(o.textContent, this.test.value);
}
});
</script>
</element>

<!-- repeat -->
<element name="mdv-repeat" attributes="test">
<template>
<template repeat="{{item in test}}">
<div>{{item.value}}</div>
</template>
</template>
<script>
Polymer.register(this, {
testrepeat: function() {
var d = this.webkitShadowRoot.querySelectorAll('div');
for (var i = 0; i < d.length; i++) {
chai.assert.equal(d[i].textContent, this.test[i].value);
}
}
});
</script>
</element>

<!-- all -->
<element name="mdv-holder" attributes="testmodel">
<template>
<mdv-bind id="bind" test="{{testmodel.bindAs}}"></mdv-bind>
<mdv-repeat id="repeat" test="{{testmodel.repeatIn}}"></mdv-repeat>
</template>
<script>
Polymer.register(this, {
insertedCallback: function() {
this.asyncMethod('runTests');
},
runTests: function() {
this.$.bind.testbind();
this.$.repeat.testrepeat();
done();
}
});
</script>
</element>

<!-- boot -->
<script>
var e = document.createElement('mdv-holder');
e.testmodel = {
bindAs: {value: 42},
repeatIn: [{value: 1}, {value: 2}]
};
document.body.appendChild(e);
</script>

</body>
</html>

0 comments on commit 09bd6cf

Please sign in to comment.