@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
87 lines (83 loc) • 2.45 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();
let _actors = "!";
const modelX = {
get actors() {
return _actors;
}
}
Routing.customize(/\bc\b/, () => {
_actors += "1";
return false;
});
Routing.customize("#a", () => {
_actors += "2";
});
Routing.customize("#b", () => {
_actors += "3";
});
Routing.customize(/\bc\b/, () => {
_actors += "4";
Routing.route("#x");
return false;
});
const _snapshots = [];
const toggle = () => {
window.setTimeout(() => {
let snapshot = Routing.location;
_snapshots.push(document.body.innerText.replace(/\s+/g, ""));
if (_snapshots.length === 0)
Routing.route("#");
else if (_snapshots.length % 5 === 0)
Routing.route("#b#x");
else if (_snapshots.length % 4 === 0)
Routing.route("#c#d");
else if (_snapshots.length % 3 === 0)
Routing.route("#a#b#c");
else if (_snapshots.length % 2 !== 0)
Routing.route("#a");
else if (_snapshots.length % 2 === 0)
Routing.route("#b#c");
if (_snapshots.length > 10) {
document.body.innerText = _snapshots.join("\r\n");
Test.start();
} else toggle();
}, 250);
};
toggle();
Test.create({test() {
const content = _snapshots.join("\r\n");
Assert.assertSameTo("script[type='text/test']", content);
}});
</script>
<script type="text/test">
0!
1!2
1!2
1!2
1!2
5!21113
5!21113
7!2111312
7!2111312
7!2111312
10!2111312113
</script>
</head>
<body route>
{{_snapshots.length}}
{{modelX.actors}}
</body>
</html>