Skip to content

Commit 4ede05b

Browse files
committed
Renamed Sel.find* to findIn
1 parent dda74a1 commit 4ede05b

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ DOM lookup is much easier than using `ReactTestUtils` directly by instead using
145145
`Sel` allows you to use a jQuery/CSS-like selector to lookup a DOM element or subset.
146146
Full examples can be [seen here](https://github.com/japgolly/scalajs-react/blob/master/test/src/test/scala/japgolly/scalajs/react/test/SelTest.scala); this is a sample:
147147
```scala
148-
val dom = Sel(".inner a.active.new") find myComponent
148+
val dom = Sel(".inner a.active.new") findIn myComponent
149149
```
150150

151151

test/src/main/scala/japgolly/scalajs/react/test/Sel.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ReactTestUtils._
77
* Path to a subset of DOM.
88
* Much easier and more powerful than what you find in ReactTestUtils.
99
*
10-
* Example: Sel("div.inner a.active.blue span") find c
10+
* Example: Sel("div.inner a.active.blue span") findIn c
1111
*/
1212
sealed abstract class Sel {
1313
import Sel._
@@ -23,29 +23,29 @@ sealed abstract class Sel {
2323

2424
final def >>(s: Sel): Sel = Descent(this, s)
2525

26-
final def findAll(i: ComponentM): Array[ComponentM] = this match {
26+
final def findAllIn(i: ComponentM): Array[ComponentM] = this match {
2727
case Tag(n) => scryRenderedDOMComponentsWithTag(i, n)
2828
case Cls(n) => scryRenderedDOMComponentsWithClass(i, n)
29-
case And(h, t) => (h.findAll(i) /: t)((q, s) => q intersect s.findAll(i))
30-
case Descent(p, c) => val r = p findAll i; r flatMap c.findAll filterNot (r contains _)
29+
case And(h, t) => (h.findAllIn(i) /: t)((q, s) => q intersect s.findAllIn(i))
30+
case Descent(p, c) => val r = p findAllIn i; r flatMap c.findAllIn filterNot (r contains _)
3131
case E => Array(i)
3232
case => Array()
3333
}
3434

35-
final def findE(i: ComponentM): Either[String, ComponentM] = {
36-
val a = findAll(i)
35+
final def findInE(i: ComponentM): Either[String, ComponentM] = {
36+
val a = findAllIn(i)
3737
a.length match {
3838
case 1 => Right(a(0))
3939
case 0 => Left(s"DOM not found for [$this]")
4040
case n => Left(s"Too many DOM elements ($n) found for [$this]")
4141
}
4242
}
4343

44-
final def findO(i: ComponentM): Option[ComponentM] =
45-
findE(i).right.toOption
44+
final def findInO(i: ComponentM): Option[ComponentM] =
45+
findInE(i).right.toOption
4646

47-
final def find(i: ComponentM): ComponentM =
48-
findE(i).fold(sys.error, identity)
47+
final def findIn(i: ComponentM): ComponentM =
48+
findInE(i).fold(sys.error, identity)
4949
}
5050

5151
object Sel {

test/src/test/scala/japgolly/scalajs/react/test/SelTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ object SelTest extends TestSuite {
2020
val c = ReactTestUtils renderIntoDocument C()
2121

2222
def test1(s: String, e: String) = {
23-
val a = Sel(s).find(c).getDOMNode().innerHTML
23+
val a = Sel(s).findIn(c).getDOMNode().innerHTML
2424
assert(a == e)
2525
}
2626

2727
def testF(errFrag: String) = (s: String) => {
28-
val a: Either[String, String] = Sel(s).findE(c).right.map(_.getDOMNode().innerHTML)
28+
val a: Either[String, String] = Sel(s).findInE(c).right.map(_.getDOMNode().innerHTML)
2929
if (a.isRight) println(Sel(s))
3030
assert(a.isLeft, a.toString contains errFrag)
3131
}

0 commit comments

Comments
 (0)