@seanox/aspect-js
Version:
full stack JavaScript framework for SPAs incl. reactivity rendering, mvc / mvvm, models, expression language, datasource, routing, paths, unit test and some more
74 lines (70 loc) • 2.65 kB
HTML
<html>
<head>
<meta charset="ISO-8859-1">
<title>Seanox aspect-js test environment</title>
<style>
body {
font-family: monospace;
white-space: pre;
}
</style>
<script src="aspect-js.js"></script>
<script type="text/javascript">
Test.activate();
Test.create({test() {
Assert.assertEquals("a1:0 a2:1 a3:2 b1:3 b2:4 b3:6", snapshots.shift());
}});
Test.create({test() {
Assert.assertEquals("a1:7 a2:8 a3:9 b1:3 b2:4 b3:6", snapshots.shift());
}});
Test.create({test() {
Assert.assertEquals("a1:7 a2:8 a3:9 b1:7 b2:8 b3:6", snapshots.shift());
}});
Test.create({test() {
Assert.assertEquals("a1:7 a2:8 a3:9 b1:7 b2:7 b3:9", snapshots.shift());
}});
Test.create({test() {
Assert.assertEquals("a1:7 a2:8 a3:9 b1:10 b2:7 b3:7", snapshots.shift());
}});
const snapshots = [];
let timeout = null;
Composite.listen(Composite.EVENT_RENDER_END, () => {
if (timeout)
window.clearInterval(timeout);
timeout = window.setTimeout(() => {
Test.start();
}, 250);
const snapshot = "a1:" + a1.value
+ " a2:" + a2.value
+ " a3:" + a3.value
+ " b1:" + b1.value
+ " b2:" + b2.value
+ " b3:" + b3.value;
snapshots.push(snapshot);
switch (snapshots.length) {
case 1:
a1.typeValue("7");
return;
case 2:
b1.typeValue("7");
return;
case 3:
b2.typeValue("7");
return;
case 4:
b3.typeValue("7");
return;
}
});
</script>
</head>
<body>
<input type="text" id="a1" events="input" render="#a2, #a3" value="0">
<input type="text" id="a2" value="{{(parseInt(a1.value) or 0) +1}}">
<input type="text" id="a3" value="{{(parseInt(a1.value) or 0) +2}}">
<input type="text" id="b1" events="input" render="#b2" value="{{(parseInt(b3.value) or 0) +3}}">
<input type="text" id="b2" events="input" render="#b3" value="{{(parseInt(b1.value) or 0) +1}}">
<input type="text" id="b3" events="input" render="#b1" value="{{(parseInt(b2.value) or 0) +2}}">
</body>
</html>