five-bells-visualization
Version:
Tool to visualize Five Bells payments
89 lines (71 loc) • 3.14 kB
HTML
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="utf-8">
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../../web-component-tester/browser.js"></script>
<link rel="import" href="../../polymer.html">
<link rel="import" href="configure-elements.html">
</head>
<body>
<x-configure-value></x-configure-value>
<x-configure-value content="attr" object='{"foo": "obj-attr"}'></x-configure-value>
<x-configure-host></x-configure-host>
<x-configure-host content="attr"></x-configure-host>
<script>
function testValueAndChangeHandler(e, value) {
assert.equal(e.content, value, 'Property does not equal configured value');
assert.equal(e.changeHandlerCount, 1, 'property `change` Change handler not run when default value set');
assert.equal(e.objectChangeHandlerCount, 1, 'property `object` Change handler not run when default value set');
}
function testConfigure(e, value, objectValue) {
testValueAndChangeHandler(e, value);
assert.equal(e.object.foo, objectValue);
assert.equal(e.$.content.textContent, value, 'Bound value not propagated to dom');
}
function testConfigureHost(e, value) {
testValueAndChangeHandler(e, value);
e = e.$.child;
testValueAndChangeHandler(e, value);
e = e.$.gchild;
testValueAndChangeHandler(e, value);
assert.equal(e.$.content.textContent, value, 'Bound value not propagated to dom');
}
suite('configure', function() {
test('value set in properties initializes correctly', function() {
var e = document.querySelector('x-configure-value');
testConfigure(e, 'default', 'obj-default');
});
test('attribute overrides value set in properties', function() {
var e = document.querySelector('x-configure-value[content]');
testConfigure(e, 'attr', 'obj-attr');
});
test('configured values initialize and propagates', function() {
var e = document.querySelector('x-configure-host');
testConfigureHost(e, 'host');
});
test('attribute overrides configured values and propagates', function() {
var e = document.querySelector('x-configure-host[content]');
testConfigureHost(e, 'attr');
});
test('property changed in change handler of another not stomped by default', function() {
var e = document.querySelector('x-configure-value');
assert.equal(e.stomp, 10);
});
test('read-only property initialized to default value', function() {
var e = document.querySelector('x-configure-value');
assert.equal(e.readOnly, 'default');
});
});
</script>
</body>
</html>