added unit tests, parsing class fields

This commit is contained in:
metacryst
2024-03-13 16:07:26 -05:00
parent dbf4d7cb19
commit fc4434b5de
4 changed files with 260 additions and 89 deletions

61
Test/parse.test.js Normal file
View File

@@ -0,0 +1,61 @@
window.testSuites.push( class testParse {
testParseClassFieldsWithEqualityCheck() {
class Space extends HTMLElement {
form = Forms.observe(window.location.pathname, this)
contents = [
...this.form.children.map(form => {
switch(form.type) {
case "file" === "file":
return File(form)
case "space":
return ChildSpace(form)
case "link":
return Link()
}
})
]
constructor() {
super()
}
}
const fields = window.Registry.parseClassFields(Space.toString());
if(!(JSON.stringify(fields) === JSON.stringify(["form", "contents"]))) {
return `Fields don't match`
}
}
testParseClassFieldsWithInnerFunctionVariable() {
class Space extends HTMLElement {
form = Forms.observe(window.location.pathname, this)
contents = [
...this.form.children.map(form => {
let file;
file = "hey"
switch(form.type) {
case "file" === "file":
return File(form)
case "space":
return ChildSpace(form)
case "link":
return Link()
}
})
]
constructor() {
super()
}
}
const fields = window.Registry.parseClassFields(Space.toString());
if(!(JSON.stringify(fields) === JSON.stringify(["form", "contents"]))) {
return `Fields don't match`
}
}
})