Skip to content

Commit 82be1de

Browse files
Use TestRenderer instead of ShallowRenderer
1 parent dbe666b commit 82be1de

56 files changed

Lines changed: 547 additions & 523 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

showcase/src/main/scala/showcase/app/ShowcaseRoot.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ object ShowcaseRoot extends FunctionComponent[ShowcaseRootProps] {
4242
else DefaultTheme
4343
})(
4444
<(AppStack.Navigator)(
45-
^.screenOptions := { navProps =>
45+
^.screenOptions := { navProps: NavigationProps =>
4646
val screenTitle = getScreenTitle(navProps)
4747
val options = new StackScreenOptions {
4848
val headerBackTitleVisible = false

showcase/src/main/scala/showcase/app/community/SvgDemo.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ import scala.scalajs.js
1010
*/
1111
object SvgDemo extends FunctionComponent[Unit] {
1212

13+
private[community] var svgXmlDemoComp: UiComponent[Unit] = SvgXmlDemo
14+
private[community] var svgCssDemoComp: UiComponent[Unit] = SvgCssDemo
15+
1316
protected def render(props: Props): ReactElement = {
1417
implicit val theme: Theme = useTheme()
1518

1619
<.View(^.rnStyle := styles.container)(
1720
<.Text(themeStyle(styles.title, themeTextStyle))("SvgXml:"),
18-
<(SvgXmlDemo())()(),
21+
<(svgXmlDemoComp())()(),
1922

2023
<.Text(themeStyle(styles.title, themeTextStyle))("SvgCss:"),
21-
<(SvgCssDemo())()()
24+
<(svgCssDemoComp())()()
2225
)
2326
}
2427

showcase/src/main/scala/showcase/app/style/BorderRadiusDemo.scala

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,8 @@ import scala.scalajs.js
77

88
object BorderRadiusDemo extends FunctionComponent[Unit] {
99

10-
protected def render(props: Props): ReactElement = {
11-
<.View(^.rnStyle := styles.container)(
12-
<(Example())(^.rnStyle := new Style {
13-
override val borderRadius = 20
14-
})(
15-
<(CenteredText())()("Example 1:\n4 Rounded Corners")
16-
),
17-
<(Example())(^.rnStyle := new Style {
18-
override val borderTopRightRadius = 60
19-
override val borderBottomRightRadius = 60
20-
})(
21-
<(CenteredText())()("Example 2:\nD Shape")
22-
),
23-
<(Example())(^.rnStyle := new Style {
24-
override val borderTopLeftRadius = 30
25-
override val borderBottomRightRadius = 30
26-
})(
27-
<(CenteredText())()("Example 3:\nLeaf Shape")
28-
),
29-
<(Example())(^.rnStyle := new Style {
30-
override val borderRadius = 60
31-
})(
32-
<(CenteredText())()("Example 4:\nCircle")
33-
)
34-
)
35-
}
36-
3710
private[style] val Example = new FunctionComponent[Unit] {
38-
11+
3912
protected def render(props: Props): ReactElement = {
4013
<.View(^.rnStyle := js.Array(
4114
styles.example,
@@ -58,6 +31,36 @@ object BorderRadiusDemo extends FunctionComponent[Unit] {
5831
}
5932
}
6033

34+
private[style] var exampleComp: UiComponent[Unit] = Example
35+
private[style] var centeredTextComp: UiComponent[Unit] = CenteredText
36+
37+
protected def render(props: Props): ReactElement = {
38+
<.View(^.rnStyle := styles.container)(
39+
<(exampleComp())(^.rnStyle := new Style {
40+
override val borderRadius = 20
41+
})(
42+
<(centeredTextComp())()("Example 1:\n4 Rounded Corners")
43+
),
44+
<(exampleComp())(^.rnStyle := new Style {
45+
override val borderTopRightRadius = 60
46+
override val borderBottomRightRadius = 60
47+
})(
48+
<(centeredTextComp())()("Example 2:\nD Shape")
49+
),
50+
<(exampleComp())(^.rnStyle := new Style {
51+
override val borderTopLeftRadius = 30
52+
override val borderBottomRightRadius = 30
53+
})(
54+
<(centeredTextComp())()("Example 3:\nLeaf Shape")
55+
),
56+
<(exampleComp())(^.rnStyle := new Style {
57+
override val borderRadius = 60
58+
})(
59+
<(centeredTextComp())()("Example 4:\nCircle")
60+
)
61+
)
62+
}
63+
6164
private[style] lazy val styles = StyleSheet.create(new Styles)
6265
private[style] class Styles extends js.Object {
6366
import Style._

showcase/src/main/scala/showcase/app/style/BorderStyleDemo.scala

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,47 @@ import scala.scalajs.js
77

88
object BorderStyleDemo extends FunctionComponent[Unit] {
99

10+
private[style] val Example = new FunctionComponent[Unit] {
11+
12+
protected def render(props: Props): ReactElement = {
13+
<.View(^.rnStyle := js.Array(
14+
styles.example,
15+
props.native.style.asInstanceOf[Style]
16+
))(
17+
props.children
18+
)
19+
}
20+
}
21+
22+
private[style] var exampleComp: UiComponent[Unit] = Example
23+
1024
protected def render(props: Props): ReactElement = {
1125
import Style._
1226

1327
<.View(^.rnStyle := styles.container)(
14-
<(Example())(^.rnStyle := new Style {
28+
<(exampleComp())(^.rnStyle := new Style {
1529
override val borderWidth = 1
1630
})(
1731
<.Text()("borderWidth: 1")
1832
),
19-
<(Example())(^.rnStyle := new Style {
33+
<(exampleComp())(^.rnStyle := new Style {
2034
override val borderWidth = 3
2135
override val borderLeftWidth = 0
2236
})(
2337
<.Text()("borderWidth: 3, borderLeftWidth: 0")
2438
),
25-
<(Example())(^.rnStyle := new Style {
39+
<(exampleComp())(^.rnStyle := new Style {
2640
override val borderWidth = 3
2741
override val borderLeftColor = Color.red
2842
})(
2943
<.Text()("borderWidth: 3, borderLeftColor: 'red'")
3044
),
31-
<(Example())(^.rnStyle := new Style {
45+
<(exampleComp())(^.rnStyle := new Style {
3246
override val borderLeftWidth = 3
3347
})(
3448
<.Text()("borderLeftWidth: 3")
3549
),
36-
<(Example())(^.rnStyle := new Style {
50+
<(exampleComp())(^.rnStyle := new Style {
3751
override val borderWidth = 1
3852
override val borderStyle = BorderStyle.dashed
3953
})(
@@ -42,18 +56,6 @@ object BorderStyleDemo extends FunctionComponent[Unit] {
4256
)
4357
}
4458

45-
private[style] val Example = new FunctionComponent[Unit] {
46-
47-
protected def render(props: Props): ReactElement = {
48-
<.View(^.rnStyle := js.Array(
49-
styles.example,
50-
props.native.style.asInstanceOf[Style]
51-
))(
52-
props.children
53-
)
54-
}
55-
}
56-
5759
private[style] lazy val styles = StyleSheet.create(new Styles)
5860
private[style] class Styles extends js.Object {
5961
import ViewStyle._

showcase/src/main/scala/showcase/app/style/MarginStyleDemo.scala

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,66 @@ import scala.scalajs.js
77

88
object MarginStyleDemo extends FunctionComponent[Unit] {
99

10+
private[style] val Example = new FunctionComponent[Unit] {
11+
12+
protected def render(props: Props): ReactElement = {
13+
<.View(^.rnStyle := js.Array(
14+
styles.example,
15+
props.native.style.asInstanceOf[Style]
16+
))(
17+
props.children
18+
)
19+
}
20+
}
21+
22+
private[style] val CenteredText = new FunctionComponent[Unit] {
23+
24+
protected def render(props: Props): ReactElement = {
25+
<.Text(^.rnStyle := js.Array(
26+
styles.centeredText,
27+
props.native.style.asInstanceOf[Style]
28+
))(
29+
props.children
30+
)
31+
}
32+
}
33+
34+
private[style] var exampleComp: UiComponent[Unit] = Example
35+
private[style] var centeredTextComp: UiComponent[Unit] = CenteredText
36+
1037
protected def render(props: Props): ReactElement = {
1138
<.View(^.rnStyle := styles.container)(
1239
<.View(^.rnStyle := styles.exampleContainer)(
13-
<(Example())()(
14-
<(CenteredText())()("A")
40+
<(exampleComp())()(
41+
<(centeredTextComp())()("A")
1542
)
1643
),
1744
<.View(^.rnStyle := styles.exampleContainer)(
18-
<(Example())(^.rnStyle := new Style {
45+
<(exampleComp())(^.rnStyle := new Style {
1946
override val marginTop = 50
2047
})(
21-
<(CenteredText())()("B")
48+
<(centeredTextComp())()("B")
2249
)
2350
),
2451
<.View(^.rnStyle := styles.exampleContainer)(
25-
<(Example())(^.rnStyle := new Style {
52+
<(exampleComp())(^.rnStyle := new Style {
2653
override val marginTop = 50
2754
override val marginLeft = 10
2855
})(
29-
<(CenteredText())()("C")
56+
<(centeredTextComp())()("C")
3057
)
3158
),
3259
<.View(^.rnStyle := styles.exampleContainer)(
33-
<(Example())(^.rnStyle := new Style {
60+
<(exampleComp())(^.rnStyle := new Style {
3461
override val marginLeft = -10
3562
override val marginTop = -10
3663
})(
37-
<(CenteredText())()("D")
64+
<(centeredTextComp())()("D")
3865
)
3966
)
4067
)
4168
}
4269

43-
private[style] val Example = new FunctionComponent[Unit] {
44-
45-
protected def render(props: Props): ReactElement = {
46-
<.View(^.rnStyle := js.Array(
47-
styles.example,
48-
props.native.style.asInstanceOf[Style]
49-
))(
50-
props.children
51-
)
52-
}
53-
}
54-
55-
private[style] val CenteredText = new FunctionComponent[Unit] {
56-
57-
protected def render(props: Props): ReactElement = {
58-
<.Text(^.rnStyle := js.Array(
59-
styles.centeredText,
60-
props.native.style.asInstanceOf[Style]
61-
))(
62-
props.children
63-
)
64-
}
65-
}
66-
6770
private[style] lazy val styles = StyleSheet.create(new Styles)
6871
private[style] class Styles extends js.Object {
6972
import Style._

showcase/src/main/scala/showcase/app/style/PaddingStyleDemo.scala

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,66 @@ import scala.scalajs.js
77

88
object PaddingStyleDemo extends FunctionComponent[Unit] {
99

10+
private[style] val Example = new FunctionComponent[Unit] {
11+
12+
protected def render(props: Props): ReactElement = {
13+
<.View(^.rnStyle := js.Array(
14+
styles.example,
15+
props.native.style.asInstanceOf[Style]
16+
))(
17+
props.children
18+
)
19+
}
20+
}
21+
22+
private[style] val CenteredText = new FunctionComponent[Unit] {
23+
24+
protected def render(props: Props): ReactElement = {
25+
<.Text(^.rnStyle := js.Array(
26+
styles.centeredText,
27+
props.native.style.asInstanceOf[Style]
28+
))(
29+
props.children
30+
)
31+
}
32+
}
33+
34+
private[style] var exampleComp: UiComponent[Unit] = Example
35+
private[style] var centeredTextComp: UiComponent[Unit] = CenteredText
36+
1037
protected def render(props: Props): ReactElement = {
1138
<.View(^.rnStyle := styles.container)(
1239
<.View(^.rnStyle := styles.exampleContainer)(
13-
<(Example())()(
14-
<(CenteredText())()("A")
40+
<(exampleComp())()(
41+
<(centeredTextComp())()("A")
1542
)
1643
),
1744
<.View(^.rnStyle := styles.exampleContainer)(
18-
<(Example())(^.rnStyle := new Style {
45+
<(exampleComp())(^.rnStyle := new Style {
1946
override val paddingTop = 50
2047
})(
21-
<(CenteredText())()("B")
48+
<(centeredTextComp())()("B")
2249
)
2350
),
2451
<.View(^.rnStyle := styles.exampleContainer)(
25-
<(Example())(^.rnStyle := new Style {
52+
<(exampleComp())(^.rnStyle := new Style {
2653
override val paddingTop = 50
2754
override val paddingLeft = 10
2855
})(
29-
<(CenteredText())()("C")
56+
<(centeredTextComp())()("C")
3057
)
3158
),
3259
<.View(^.rnStyle := styles.exampleContainer)(
33-
<(Example())(^.rnStyle := new Style {
60+
<(exampleComp())(^.rnStyle := new Style {
3461
override val paddingLeft = -10
3562
override val paddingTop = -10
3663
})(
37-
<(CenteredText())()("D")
64+
<(centeredTextComp())()("D")
3865
)
3966
)
4067
)
4168
}
4269

43-
private[style] val Example = new FunctionComponent[Unit] {
44-
45-
protected def render(props: Props): ReactElement = {
46-
<.View(^.rnStyle := js.Array(
47-
styles.example,
48-
props.native.style.asInstanceOf[Style]
49-
))(
50-
props.children
51-
)
52-
}
53-
}
54-
55-
private[style] val CenteredText = new FunctionComponent[Unit] {
56-
57-
protected def render(props: Props): ReactElement = {
58-
<.Text(^.rnStyle := js.Array(
59-
styles.centeredText,
60-
props.native.style.asInstanceOf[Style]
61-
))(
62-
props.children
63-
)
64-
}
65-
}
66-
6770
private[style] lazy val styles = StyleSheet.create(new Styles)
6871
private[style] class Styles extends js.Object {
6972
import Style._

0 commit comments

Comments
 (0)