UNPKG

@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

125 lines (119 loc) 2.76 kB
<!DOCTYPE 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(); Composite.listen(Composite.EVENT_RENDER_END, () => { capture.snap(); const count = capture.patterns().length; if (capture.size() === 1) window.setTimeout(() => { model.list[1].text = "D"; }, 500); if (capture.size() === count) Test.start(); }); Test.create({test() { capture.validate(); }}); Test.create({test() { Assert.assertEquals(capture.size(), capture.snapshots().length); }}); const model = ({ list: [ {text: "A"}, {text: "B"}, {text: "C"}, ], get recursionA() { return this.ordinal(); }, propA: {v:"A"}, propB: {v:"B"}, propC: {v:"C"}, propX: {v:"X"}, inner: { get text() { return model.list[1].text; } } }).reactive(); window.setTimeout(() => { model.propX = model.propC = model.propB = model.propA; }, 1000); window.setTimeout(() => { model.propX = model.propC = model.propB = model.propA = model.propX; }, 2000); </script> <script type="text/test"> A: _7_ B: _B_ C: _B_ D: A B C X: _X_ </script> <script type="text/test"> A: _7_ B: _D_ C: _B_ D: A B C X: _X_ </script> <script type="text/test"> A: _7_ B: _D_ C: _D_ D: A B C X: _X_ </script> <script type="text/test"> A: _7_ B: _D_ C: _D_ D: A D C X: _X_ </script> <script type="text/test"> A: _7_ B: _D_ C: _D_ D: A D C X: _A_ </script> </head> <body> A: _{{model.recursionA}}_ B: _{{model.list[1].text}}_ C: _{{model.inner.text}}_ D: <div iterate="{{list:model.list}}"> {{list.item.text}} </div> X: _{{model.propX.v}}_ </body> </html>