Skip to content

Commit a941d51

Browse files
committed
kotest tests
1 parent 18af11d commit a941d51

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

src/test/kotlin/answers/FsmTestExample.kt

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,32 @@ import io.kotest.matchers.shouldBe
99
import io.kotest.matchers.shouldHave
1010

1111
class FsmTestExample : BehaviorSpec({
12-
given("a broomstick") {
13-
`when`("I sit on it") {
14-
val fsm = Fsm.create(initialState = "locked") {
15-
add { this on "coin" from "locked" into "unlocked" }
16-
add { this on "pass" from "unlocked" into "locked" }
17-
}
18-
then("I should be able to fly") {
19-
fsm.initial shouldBe State("locked")
20-
fsm.transitions shouldHave haveSize(2)
21-
}
12+
13+
given("fsm") {
14+
val fsm = Fsm.create(initialState = "locked") {
15+
add { this on "coin" from "locked" into "unlocked" }
16+
add { this on "pass" from "unlocked" into "locked" }
17+
}
18+
then("I could move from state to state") {
19+
fsm.initial shouldBe State("locked")
20+
fsm.transitions shouldHave haveSize(2)
21+
fsm["coin"] shouldBe State("unlocked")
22+
fsm["pass"] shouldBe State("locked")
2223
}
2324
}
2425

25-
given("2222") {
26-
`when`("I sit on it") {
27-
val fsmSpec = FsmSpec(initialState = "locked")
28-
val fsm = fsmSpec {
29-
add { this on "coin" from "locked" into "unlocked" }
30-
add { this on "pass" from "unlocked" into "locked" }
31-
}
26+
given("fsm from fsm spec") {
27+
val fsmSpec = FsmSpec(initialState = "locked")
28+
val fsm = fsmSpec {
29+
add { this on "coin" from "locked" into "unlocked" }
30+
add { this on "pass" from "unlocked" into "locked" }
31+
}
3232

33-
then("I should be able to fly") {
34-
fsm.initial shouldBe State("locked")
35-
fsm.transitions shouldHave haveSize(2)
36-
}
33+
then("I could move from state to state") {
34+
fsm.initial shouldBe State("locked")
35+
fsm.transitions shouldHave haveSize(2)
36+
fsm["coin"] shouldBe State("unlocked")
37+
fsm["pass"] shouldBe State("locked")
3738
}
3839
}
3940
})

0 commit comments

Comments
 (0)