@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
78 lines (73 loc) • 2.43 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 src="scripts/capture.js"></script>
<script type="text/javascript">
Test.activate();
const capture = new Capture();
const values = [];
Composite.listen(Composite.EVENT_RENDER_END, () => {
capture.snap();
values.push(document.querySelector("#valueA").value);
const count = capture.patterns().length;
if (capture.size() === count)
Test.start();
if (capture.size() >= count)
Assert.assertEquals("expected {1} steps but was {2}", count, capture.size());
});
Test.create({test() {
capture.validate();
}});
Test.create({test() {
Assert.assertEquals("hallo", values[0]);
Assert.assertEquals("hallo", values[1]);
Assert.assertNotEquals("hallo", values[2]);
Assert.assertNotEquals("hallo", values[3]);
Assert.assertNotEquals("hallo", values[4]);
Assert.assertEquals(values[2], values[3]);
Assert.assertEquals(values[2], values[4]);
}});
const modelA = {
valueA: "hallo"
}.reactive();
window.setTimeout(() => {modelA.valueA = "a2b4c6d8e0";}, 1000)
</script>
<script type="text/test">
_A_hallo_
Value of variable modelA.valueA: hallo
</script>
<script type="text/test">
_A_a2b4c6d8e0_
Value of variable modelA.valueA: hallo
</script>
<script type="text/test">
_A_a2b4c6d8e0_
Value of variable modelA.valueA: hallo
</script>
<script type="text/test">
_A_a2b4c6d8e0_
Value of variable modelA.valueA: a2b4c6d8e0
</script>
<script type="text/test">
_A_a2b4c6d8e0_
Value of variable modelA.valueA: a2b4c6d8e0
</script>
</head>
<body>
_A_{{modelA.valueA}}_
<p id="modelA" composite>
<input type="text" id="valueA" value="{{Date.now()}}"
events="input" foo="{{modelA.valueA}}"/>
Value of variable modelA.valueA: {{modelA.valueA}}
</p>
</body>
</html>