All unit tests passing, all 3 methods of initializing working
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
class Home extends Page {
|
||||
results = window.test
|
||||
|
||||
render = () => {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,31 @@
|
||||
window.testSuites.push( class testParse {
|
||||
|
||||
testParseConstructor() {
|
||||
class Space extends Shadow {
|
||||
form
|
||||
contents = []
|
||||
|
||||
constructor(...params) {
|
||||
super(...params)
|
||||
}
|
||||
}
|
||||
|
||||
let newClass = window.Registry.parseConstructor(Space)
|
||||
if(!newClass.prototype.constructor.toString().includes("window.Registry.construct(")) {
|
||||
return "'window.Registry.construct(' not detected!"
|
||||
}
|
||||
}
|
||||
|
||||
testParseConstructorIfNoneProvided() {
|
||||
class Space extends Shadow {
|
||||
$form
|
||||
}
|
||||
|
||||
let newClass = window.Registry.parseConstructor(Space)
|
||||
if(!newClass.prototype.constructor.toString().includes("window.Registry.construct(")) {
|
||||
return "'window.Registry.construct(' not detected!"
|
||||
}
|
||||
}
|
||||
|
||||
testParseClassFieldsWithNoDefault() {
|
||||
class Space extends Shadow {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
window.testSuites.push( class testShadow {
|
||||
|
||||
testObjectAsStateField() {
|
||||
ObjectAsStateField() {
|
||||
class File extends Shadow {
|
||||
$form
|
||||
|
||||
@@ -17,7 +17,7 @@ window.testSuites.push( class testShadow {
|
||||
}
|
||||
}
|
||||
|
||||
testMultiParams() {
|
||||
MultiParams() {
|
||||
class File2 extends Shadow {
|
||||
$form
|
||||
$tag
|
||||
@@ -56,7 +56,7 @@ window.testSuites.push( class testShadow {
|
||||
}
|
||||
}
|
||||
|
||||
testChangeAttrChangesField() {
|
||||
ChangeAttrChangesField() {
|
||||
class File3 extends Shadow {
|
||||
$form
|
||||
$tag
|
||||
@@ -75,7 +75,7 @@ window.testSuites.push( class testShadow {
|
||||
}
|
||||
}
|
||||
|
||||
testChangeFieldChangesAttr() {
|
||||
ChangeFieldChangesAttr() {
|
||||
class File4 extends Shadow {
|
||||
$form
|
||||
$tag
|
||||
@@ -94,25 +94,37 @@ window.testSuites.push( class testShadow {
|
||||
}
|
||||
}
|
||||
|
||||
testDefaultStateFieldWorks() {
|
||||
ConstructorCanUseState() {
|
||||
class File7 extends Shadow {
|
||||
$form = {data: "asdf"}
|
||||
extra
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
this.extra = this.form
|
||||
}
|
||||
}
|
||||
|
||||
window.register(File7, "file7-el")
|
||||
const el = window.File7()
|
||||
if(el.extra === undefined) {
|
||||
return `Constructor could not access state`
|
||||
}
|
||||
}
|
||||
|
||||
DefaultStateFieldWorks() {
|
||||
class File6 extends Shadow {
|
||||
$form = {data: "asdf"}
|
||||
|
||||
constructor(...params) {
|
||||
super(...params)
|
||||
console.log(this.form)
|
||||
}
|
||||
}
|
||||
|
||||
window.register(File6, "file6-el")
|
||||
const el = window.File6()
|
||||
console.log(el, el.$form, el._form)
|
||||
if(el.form === undefined) {
|
||||
return `Default value did not work`
|
||||
}
|
||||
}
|
||||
|
||||
testRegisterThrowsIfNoConstructorParams() {
|
||||
RegisterThrowsIfNoConstructorParams() {
|
||||
class File3 extends Shadow {
|
||||
$form
|
||||
|
||||
@@ -123,7 +135,9 @@ window.testSuites.push( class testShadow {
|
||||
|
||||
try {
|
||||
window.register(File3, "file3-el")
|
||||
} catch(e) {}
|
||||
} catch(e) {
|
||||
return
|
||||
}
|
||||
|
||||
return "Error not thrown!"
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<link rel="icon" href="">
|
||||
<link rel="stylesheet" href="">
|
||||
<script src="../index.js"></script>
|
||||
<script src="test.js"></script>
|
||||
<script src="test.js" type="module"></script>
|
||||
<script type="module">
|
||||
import Home from "./Pages/home.js";
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
console.log("Tests initializing.")
|
||||
window.testSuites = [];
|
||||
|
||||
import ("./parse.test.js")
|
||||
import ("./shadow.test.js")
|
||||
await import ("./parse.test.js")
|
||||
await import ("./shadow.test.js")
|
||||
|
||||
window.test = async function() {
|
||||
// window.testSuites.sort();
|
||||
@@ -62,4 +62,6 @@ window.test = async function() {
|
||||
|
||||
window.wait = ms => new Promise(res => setTimeout(res, ms));
|
||||
|
||||
window.__defineGetter__("test", test);
|
||||
window.__defineGetter__("test", test);
|
||||
|
||||
window.test
|
||||
Reference in New Issue
Block a user