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

92 lines (83 loc) 3.5 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 type="text/javascript"> Test.activate(); Test.create({test() { let result = document.body.innerHTML.replace(/[\r\n]+/g," ").trim(); result = result.replace(/(onReceive ){2,}/g, "onReceive "); const pattern1 = "Test in progress..." + " onReceive onStart onReceive onError onEnd" + " ---" + " onReceive onStart onReceive onProgress onReceive onSuccess onEnd"; const pattern2 = "Test in progress..." + " onReceive onStart onReceive onProgress onError onEnd" + " ---" + " onReceive onStart onReceive onProgress onReceive onSuccess onEnd"; try {Assert.assertEquals(pattern1, result); } catch (exception) { try {Assert.assertEquals(pattern2, result); } catch (exception) { throw exception; } } }}); window.addEventListener("load", () => { document.body.innerHTML = "Test in progress...\r\n\r\n"; const onStart = () => { document.body.innerHTML += "onStart\r\n"; }; const onProgress = () => { document.body.innerHTML += "onProgress\r\n"; }; const onReceive = () => { document.body.innerHTML += "onReceive\r\n"; }; const onSuccess = () => { document.body.innerHTML += "onSuccess\r\n"; }; const onAbort = () => { document.body.innerHTML += "onAbort\r\n"; }; const onTimeout = () => { document.body.innerHTML += "onTimeout\r\n"; }; const onError = () => { document.body.innerHTML += "onError\r\n"; }; const onEnd = () => { document.body.innerHTML += "onEnd\r\n"; }; Composite.listen(Composite.EVENT_HTTP_START, onStart); Composite.listen(Composite.EVENT_HTTP_PROGRESS, onProgress); Composite.listen(Composite.EVENT_HTTP_RECEIVE, onReceive); Composite.listen(Composite.EVENT_HTTP_LOAD, onSuccess); Composite.listen(Composite.EVENT_HTTP_ABORT, onAbort); Composite.listen(Composite.EVENT_HTTP_TIMEOUT, onTimeout); Composite.listen(Composite.EVENT_HTTP_ERROR, onError); Composite.listen(Composite.EVENT_HTTP_END, onEnd); const request = new XMLHttpRequest(); request.open("GET", "https://github.com/seanox"); request.send(); window.setTimeout(() => { document.body.innerHTML += "---\r\n"; const request = new XMLHttpRequest(); request.open("GET", document.location.href); request.send(); window.setTimeout(Test.start, 2500); }, 2500); }); </script> </head> <body> </body> </html>