File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed
main/scala/japgolly/scalajs/react/test
test/scala/japgolly/scalajs/react/test Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 33* ` ComponentOrNode ` moved to test module. Renamed to ` ReactOrDomNode ` .
44* Changed overloaded ` classSet ` methods into ` classSet{,1}{,M} ` .
55* Added ` simulateKeyDownUp ` and ` simulateKeyDownPressUp ` to ` KeyboardEventData ` in the test module.
6+ * In rare circumstances, ` Simulation.run ` targets can go out of date. Targets are now stored by-name.
67
78# 0.6.0 ([ commit log] ( https://github.com/japgolly/scalajs-react/compare/v0.5.4...v0.6.0 ) )
89
Original file line number Diff line number Diff line change @@ -6,20 +6,26 @@ import ReactTestUtils.Simulate
66/**
77 * Allows composition and abstraction of `ReactTestUtils.Simulate` procedures.
88 */
9- case class Simulation (run : ReactOrDomNode => Unit ) {
9+ class Simulation (_run : (() => ReactOrDomNode ) => Unit ) {
10+
11+ def run (n : => ReactOrDomNode ): Unit =
12+ _run(() => n)
1013
1114 def andThen (f : Simulation ) =
12- Simulation (n => { run (n); f.run(n) })
15+ new Simulation (n => { _run (n); f.run(n() ) })
1316
1417 @ inline final def >> (f : Simulation ) = this andThen f
1518 @ inline final def compose (f : Simulation ) = f andThen this
1619
1720 final def runN (cs : ReactOrDomNode * ): Unit =
18- cs foreach run
21+ cs foreach ( run(_))
1922}
2023
2124object Simulation {
2225
26+ def apply (run : (=> ReactOrDomNode ) => Unit ): Simulation =
27+ new Simulation (n => run(n()))
28+
2329 // Don't use default arguments - they force parentheses on to caller.
2430 // Eg. Simulation.blur >> Simulation.focus becomes Simulation.blur() >> Simulation.focus(). Yuk.
2531
Original file line number Diff line number Diff line change @@ -75,6 +75,16 @@ object TestTest extends TestSuite {
7575 events mustEqual Vector (" focus" , " change" , " blur" )
7676 i.getDOMNode().value mustEqual " good"
7777 }
78+ ' targetByName {
79+ val c = ReactTestUtils .renderIntoDocument(IC ())
80+ var count = 0
81+ def tgt = {
82+ count += 1
83+ Sel (" input" ).findIn(c)
84+ }
85+ Simulation .focusChangeBlur(" -" ) run tgt
86+ assert(count == 3 )
87+ }
7888 }
7989 }
8090}
You can’t perform that action at this time.
0 commit comments