@seanox/aspect-js
Version:
full stack JavaScript framework for SPAs incl. reactivity rendering, mvc / mvvm, models, expression language, datasource, virtual paths, unit test and some more
81 lines (73 loc) • 3.14 kB
HTML
<html>
<head>
<meta charset="ISO-8859-1">
<title>Seanox aspect-js test environment</title>
<style>
body {
font-family: monospace;
}
body div {
margin: 1em;
}
body * {
display: block;
}
</style>
<script src="aspect-js.js"></script>
<script src="scripts/capture.js"></script>
<script type="text/javascript">
Test.activate();
const capture = new Capture();
Composite.listen(Composite.EVENT_RENDER_END, () => {
capture.snap();
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();
}});
// In markup, namespaces have a purely textual character and only the
// syntax is checked. Thus, resources from the module directory can also
// be used without namespaces on the object level.
Test.create({test() {
// Named access on the Window object
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#named-access-on-the-window-object
// No model has been implemented for ns3.
// But here "named access on the Window object" takes effect and the
// browser creates an object with the same name.
Assert.assertTrue(Namespace.exists("ns3"));
Assert.assertNotUndefined(Namespace.lookup("ns3"));
Assert.assertEquals("object", typeof ns3);
Assert.assertTrue(ns3 instanceof HTMLElement);
Assert.assertTrue(Namespace.lookup("ns3") instanceof HTMLElement);
Assert.assertEquals(Namespace.lookup("ns3"), ns3);
}});
Test.create({test() {
Assert.assertTrue(Namespace.exists("ns4"));
Assert.assertNotUndefined(Namespace.lookup("ns4"));
Assert.assertEquals("object", typeof Namespace.lookup("ns4"))
Assert.assertFalse(Namespace.lookup("ns4") instanceof Element);
Assert.assertTrue(Namespace.exists("ns4.a"));
Assert.assertNotUndefined(Namespace.lookup("ns4.a"));
Assert.assertEquals("object", typeof Namespace.lookup("ns4.a"))
Assert.assertFalse(Namespace.lookup("ns4.a") instanceof Element);
Assert.assertTrue(Namespace.exists("ns4.a.moduleA"));
Assert.assertNotUndefined(Namespace.lookup("ns4.a.moduleA"));
Assert.assertEquals("object", typeof Namespace.lookup("ns4.a.moduleA"));
Assert.assertFalse(Namespace.lookup("ns4.a.moduleA") instanceof Element);
}});
</script>
<script type="text/test">
content of moduleA (ns3.a)
content of moduleA (ns4.a)
</script>
</head>
<body>
<div id="ns3" composite namespace></div>
<div id="ns4" composite namespace></div>
</body>
</html>