UNPKG

@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

162 lines (156 loc) 3.55 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(); SiteMap.customize({ "#": ["home", "projects", "about", "contact..."], "#project": ["..."], "#project#a": ["..."], "#team": ["...", "a", "b", "c"], "#team#a": ["..."], "#team#x": ["..."] }); const tests = [ "#", "#a", "#a#b", "#home", "#home#a", "#home#a#b", "#contact", "#contact#a", "#contact#a#b", "#project", "#project#a", "#project#a#b", "#team", "#team#a", "#team#a#b", "#team#x", "#team#x#a", "#team#x#a#b", "#" ]; Test.create({test() { document.location.href = "#"; document.body.innerHTML = ""; tests.forEach((test) => { document.body.innerHTML = document.body.innerHTML.trim(); if (document.body.innerHTML) document.body.innerHTML += "\r\n"; document.body.innerHTML += "I: " + test + "\r\nO: " + SiteMap.locate(test); }); Assert.assertSameTo("script[type='text/test1']", document.body.textContent); }}); Test.create({test() { SiteMap.forward("#project"); document.body.innerHTML = ""; const filter = /^#project#/; tests.forEach((test) => { document.body.innerHTML = document.body.innerHTML.trim(); if (document.body.innerHTML) document.body.innerHTML += "\r\n"; if (test.match(filter)) test = test.replace(filter, ""); document.body.innerHTML += "I: " + test + "\r\nO: " + SiteMap.locate(test); }); Assert.assertSameTo("script[type='text/test2']", document.body.textContent); }}); Test.start({auto:true}); </script> <script type="text/test1"> I: # O: # I: #a O: # I: #a#b O: # I: #home O: #home I: #home#a O: #home I: #home#a#b O: #home I: #contact O: #contact I: #contact#a O: #contact#a I: #contact#a#b O: #contact#a#b I: #project O: #project I: #project#a O: #project#a I: #project#a#b O: #project#a#b I: #team O: #team I: #team#a O: #team#a I: #team#a#b O: #team#a#b I: #team#x O: #team#x I: #team#x#a O: #team#x#a I: #team#x#a#b O: #team#x#a#b I: # O: # </script> <script type="text/test2"> I: # O: # I: #a O: # I: #a#b O: # I: #home O: #home I: #home#a O: #home I: #home#a#b O: #home I: #contact O: #contact I: #contact#a O: #contact#a I: #contact#a#b O: #contact#a#b I: #project O: #project I: a O: #project#a I: a#b O: #project#a#b I: #team O: #team I: #team#a O: #team#a I: #team#a#b O: #team#a#b I: #team#x O: #team#x I: #team#x#a O: #team#x#a I: #team#x#a#b O: #team#x#a#b I: # O: # </script> </head> <body> </body> </html>