state test working, added random experimental html
This commit is contained in:
71
Test/state/state.test.js
Normal file
71
Test/state/state.test.js
Normal 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!"
|
||||
}
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user