-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added assertWrapped prop test helper, fixed #7
- Loading branch information
1 parent
5c1a9af
commit a497b57
Showing
4 changed files
with
89 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
test/src/test/scala/scommons/react/test/TestAttributesSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package scommons.react.test | ||
|
||
import scommons.react._ | ||
import scommons.react.test.TestAttributesSpec._ | ||
|
||
class TestAttributesSpec extends TestSpec with TestRendererUtils { | ||
|
||
TestAttributesSpec.someChildComp = mockUiComponent("TestChild") | ||
|
||
it should "render and assertWrapped" in { | ||
//when | ||
val result = testRender(<(TestComponent())()()) | ||
|
||
//then | ||
assertNativeComponent(result, | ||
<.div()( | ||
<(someChildComp())(^.assertWrapped(inside(_) { | ||
case TestComponentProps("test name", age) => | ||
age shouldBe 123 | ||
}))() | ||
) | ||
) | ||
} | ||
} | ||
|
||
object TestAttributesSpec { | ||
|
||
case class TestComponentProps(name: String, age: Int) | ||
|
||
private var someChildComp: UiComponent[TestComponentProps] = TestComponent | ||
|
||
object TestComponent extends FunctionComponent[TestComponentProps] { | ||
|
||
protected def render(props: Props): ReactElement = { | ||
<.div()( | ||
<(someChildComp())(^.wrapped := TestComponentProps("test name", 123))() | ||
) | ||
} | ||
} | ||
} |