state test working, added random experimental html

This commit is contained in:
metacryst
2025-12-26 01:36:04 -06:00
parent b08e2767f6
commit c4560aba37
5 changed files with 302 additions and 21 deletions

71
Test/state/state.test.js Normal file
View File

@@ -0,0 +1,71 @@
window.testSuites.push( class testState {
SimpleState() {
class Home extends Shadow {
state = {
pathname: "/"
}
render() {
VStack(() => {
p("hi")
.top(() => {return (this.state.pathname === "/" ? [11, vw] : [7, vw])})
})
.onAppear(() => {
this.state.pathname = "/asd"
})
}
}
register(Home, randomName("home"))
window.Home()
if(!($("p").style.top === "7vw")) return "state was not respeccted"
}
StateArrayPush() {
class Home extends Shadow {
state = {
logs: []
}
render() {
VStack(() => {
p("hi")
.fontSize(() => {return this.state.logs.length > 0 ? [2, em] : [1, em]})
})
.onAppear(() => {
this.state.logs = ["one", "two"]
})
}
}
register(Home, randomName("home"))
window.Home()
if(!($("p").style.fontSize === "2em")) return "state did not update!"
}
SimpleStack() {
class Home extends Shadow {
state = {
logs: []
}
render() {
VStack(() => {
let asd = this.state.logs.length * 2
p("hi")
.fontSize(asd, vw)
})
.onAppear(() => {
this.state.logs = ["one", "two"]
})
}
}
register(Home, randomName("home"))
window.Home()
if(!($("p").style.fontSize === "4vw")) return "state did not update!"
}
})