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

74 lines (68 loc) 3.7 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() { DataSource.collect(); }}); Test.create({expected:/\bInvalid collection/i, test() { DataSource.collect(null); }}); Test.create({expected:/\bInvalid collection/i, test() { DataSource.collect({}); }}); Test.create({test() { const collection = DataSource.collect("xml://datasource_collect_a"); Assert.assertEquals(1, collection.querySelectorAll("collection > test").length); Assert.assertEquals(1, collection.querySelectorAll("collection > test[id='collect_a']").length); }}); Test.create({test() { const collection = DataSource.collect("xml://datasource_collect_a", "xml://datasource_collect_a"); Assert.assertEquals(2, collection.querySelectorAll("collection > test").length); Assert.assertEquals(2, collection.querySelectorAll("collection > test[id='collect_a']").length); }}); Test.create({test() { const collection = DataSource.collect("xml://datasource_collect_a", "xml://datasource_collect_a", "xml://datasource_collect_b"); Assert.assertEquals(3, collection.querySelectorAll("collection > test").length); Assert.assertEquals(2, collection.querySelectorAll("collection > test[id='collect_a']").length); Assert.assertEquals(1, collection.querySelectorAll("collection > test[id='collect_b']").length); }}); Test.create({test() { const collection = DataSource.collect("xml://datasource_collect_a", "xml://datasource_collect_b", "xml://datasource_collect_c"); Assert.assertEquals(3, collection.querySelectorAll("collection > test").length); Assert.assertEquals(1, collection.querySelectorAll("collection > test[id='collect_a']").length); Assert.assertEquals(1, collection.querySelectorAll("collection > test[id='collect_b']").length); Assert.assertEquals(1, collection.querySelectorAll("collection > test[id='collect_c']").length); }}); Test.create({test() { const collection = DataSource.collect("xxx", ["xml://datasource_collect_a", "xml://datasource_collect_b", "xml://datasource_collect_c"]); Assert.assertEquals(3, collection.querySelectorAll("xxx > test").length); Assert.assertEquals(1, collection.querySelectorAll("xxx > test[id='collect_a']").length); Assert.assertEquals(1, collection.querySelectorAll("xxx > test[id='collect_b']").length); Assert.assertEquals(1, collection.querySelectorAll("xxx > test[id='collect_c']").length); }}); Test.create({expected:/\b404/i, test() { DataSource.collect("xml://datasource_collect_a", "xml://datasource_collect_b", "xml://datasource_collect_d"); }}); Test.create({expected:/\bInvalid collection/i, test() { DataSource.collect("xml://datasource_collect_a", "xml://datasource_collect_b", null); }}); Test.create({expected:/\bInvalid collection/i, test() { DataSource.collect("xml://datasource_collect_a", "xml://datasource_collect_b", {}); }}); Test.start({auto:true}); </script> </head> <body> </body> </html>