Skip to content

Commit

Permalink
Upgraded Scala.js to v1.5.1 (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-podzigun authored Jul 16, 2022
1 parent 3a92a8e commit edab00b
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 55 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![CI](https://github.com/scommons/scommons-react-native/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/scommons/scommons-react-native/actions/workflows/ci.yml?query=workflow%3Aci+branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/github/scommons/scommons-react-native/badge.svg?branch=master)](https://coveralls.io/github/scommons/scommons-react-native?branch=master)
[![scala-index](https://index.scala-lang.org/scommons/scommons-react-native/scommons-react-native-core/latest.svg)](https://index.scala-lang.org/scommons/scommons-react-native/scommons-react-native-core)
[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-1.1.0.svg)](https://www.scala-js.org)
[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-1.5.0.svg)](https://www.scala-js.org)

## Scala Commons React Native
Scala.js facades for core [react-native](https://facebook.github.io/react-native/docs/getting-started) utilities and components.
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ lazy val `scommons-react-native` = (project in file("."))
.settings(CommonModule.settings: _*)
.settings(ReactNativeModule.settings: _*)
.settings(
skip in publish := true,
publish / skip := true,
publish := ((): Unit),
publishLocal := ((): Unit),
publishM2 := ((): Unit)
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.2.8
sbt.version = 1.5.2
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"

//addSbtPlugin(("org.scommons.sbt" % "sbt-scommons-plugin" % "0.8.0-SNAPSHOT").changing())
addSbtPlugin("org.scommons.sbt" % "sbt-scommons-plugin" % "0.8.0")
addSbtPlugin(("org.scommons.sbt" % "sbt-scommons-plugin" % "0.9.0-SNAPSHOT").changing())
//addSbtPlugin("org.scommons.sbt" % "sbt-scommons-plugin" % "0.8.0")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.7.3")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
8 changes: 4 additions & 4 deletions project/src/main/scala/common/Libs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import scommons.sbtplugin.project.CommonLibs

object Libs extends CommonLibs {

val scommonsApiVersion = "0.8.0"
val scommonsReactVersion = "0.8.0"
val scommonsNodejsVersion = "0.8.0"
val scommonsWebSqlVersion = "0.8.0"
val scommonsApiVersion = "1.0.0-SNAPSHOT"
val scommonsReactVersion = "1.0.0-SNAPSHOT"
val scommonsNodejsVersion = "1.0.0-SNAPSHOT"
val scommonsWebSqlVersion = "1.0.0-SNAPSHOT"

lazy val scommonsApiXhr = Def.setting("org.scommons.api" %%% "scommons-api-xhr" % scommonsApiVersion)
lazy val scommonsReactCore = Def.setting("org.scommons.react" %%% "scommons-react-core" % scommonsReactVersion)
Expand Down
2 changes: 1 addition & 1 deletion project/src/main/scala/definitions/ReactNativeModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object ReactNativeModule {
//
sonatypeProfileName := "org.scommons",
publishMavenStyle := true,
publishArtifact in Test := false,
Test / publishArtifact := false,
publishTo := sonatypePublishToBundle.value,
pomExtra := {
<url>https://github.com/scommons/scommons-react-native</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object ReactNativeShowcase extends ScalaJsModule {

override def definition: Project = super.definition
.settings(
skip in publish := true,
publish / skip := true,
publish := ((): Unit),
publishLocal := ((): Unit),
publishM2 := ((): Unit),
Expand Down
25 changes: 0 additions & 25 deletions project/src/main/scala/definitions/ScalaJsModule.scala
Original file line number Diff line number Diff line change
@@ -1,40 +1,15 @@
package definitions

import org.scalajs.sbtplugin.ScalaJSPlugin
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
import sbt.Keys._
import sbt._
import scalajsbundler.sbtplugin.ScalaJSBundlerPlugin
import scommons.sbtplugin.project.CommonMobileModule
import scoverage.ScoverageKeys.{coverageEnabled, coverageScalacPluginVersion}

trait ScalaJsModule extends ReactNativeModule {

override def definition: Project = {
super.definition
.enablePlugins(ScalaJSPlugin, ScalaJSBundlerPlugin)
.settings(CommonMobileModule.settings: _*)
.settings(
//TODO: remove these temporal fixes for Scala.js 1.1+ and scoverage
coverageScalacPluginVersion := {
val current = coverageScalacPluginVersion.value
if (scalaJSVersion.startsWith("0.6")) current
else "1.4.2" //the only version that supports Scala.js 1.1+
},
libraryDependencies ~= { modules =>
if (scalaJSVersion.startsWith("0.6")) modules
else modules.filter(_.organization != "org.scoverage")
},
libraryDependencies ++= {
if (coverageEnabled.value) {
if (scalaJSVersion.startsWith("0.6")) Nil
else Seq(
"org.scoverage" %% "scalac-scoverage-runtime_sjs1" % coverageScalacPluginVersion.value,
"org.scoverage" %% "scalac-scoverage-plugin" % coverageScalacPluginVersion.value % "scoveragePlugin"
)
}
else Nil
}
)
}
}
4 changes: 3 additions & 1 deletion showcase/src/test/scala/showcase/AlertDemoSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class AlertDemoSpec extends TestSpec with TestRendererUtils {
val okHandler = mockFunction[Unit]
AlertDemo.okHandler = okHandler
val comp = testRender(<(AlertDemo())()())
val List(showAlert, _) = findComponents(comp, raw.Button)
val showAlert = inside(findComponents(comp, raw.Button)) {
case List(showAlert, _) => showAlert
}

//then
okHandler.expects()
Expand Down
20 changes: 15 additions & 5 deletions showcase/src/test/scala/showcase/FlatListDemoSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class FlatListDemoSpec extends AsyncTestSpec
it should "set refreshing when onRefresh" in {
//given
val renderer = createTestRenderer(<(FlatListDemo())()())
val List(flatList) = findComponents(renderer.root, <.FlatList.reactClass)
val flatList = inside(findComponents(renderer.root, <.FlatList.reactClass)) {
case List(flatList) => flatList
}
flatList.props.refreshing shouldBe false

//when
Expand Down Expand Up @@ -53,7 +55,9 @@ class FlatListDemoSpec extends AsyncTestSpec
}

//when & then
val List(flatList) = findComponents(renderer.root, <.FlatList.reactClass)
val flatList = inside(findComponents(renderer.root, <.FlatList.reactClass)) {
case List(flatList) => flatList
}
assertTestComponent(renderItem(flatList), Item) {
case ItemProps(title, selected, onPress) =>
title shouldBe "First Item"
Expand All @@ -65,7 +69,9 @@ class FlatListDemoSpec extends AsyncTestSpec
}

//then
val List(selectedList) = findComponents(renderer.root, <.FlatList.reactClass)
val selectedList = inside(findComponents(renderer.root, <.FlatList.reactClass)) {
case List(selectedList) => selectedList
}
assertTestComponent(renderItem(selectedList), Item) {
case ItemProps(title, selected, onPress) =>
title shouldBe "First Item"
Expand All @@ -77,7 +83,9 @@ class FlatListDemoSpec extends AsyncTestSpec
}

//then
val List(unselectedList) = findComponents(renderer.root, <.FlatList.reactClass)
val unselectedList = inside(findComponents(renderer.root, <.FlatList.reactClass)) {
case List(unselectedList) => unselectedList
}
assertTestComponent(renderItem(unselectedList), Item) {
case ItemProps(title, selected, _) =>
title shouldBe "First Item"
Expand All @@ -88,7 +96,9 @@ class FlatListDemoSpec extends AsyncTestSpec
it should "return data.id from keyExtractor" in {
//given
val comp = testRender(<(FlatListDemo())()())
val List(flatList) = findComponents(comp, <.FlatList.reactClass)
val flatList = inside(findComponents(comp, <.FlatList.reactClass)) {
case List(flatList) => flatList
}
val data = dataList.head

//when
Expand Down
24 changes: 18 additions & 6 deletions showcase/src/test/scala/showcase/ModalDemoSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,34 @@ class ModalDemoSpec extends TestSpec with TestRendererUtils {
//given
val renderer = createTestRenderer(<(ModalDemo())()())
findComponents(renderer.root, raw.Modal) shouldBe Nil
val List(showModal) = findComponents(renderer.root, raw.Button)
val showModal = inside(findComponents(renderer.root, raw.Button)) {
case List(showModal) => showModal
}

//when
showModal.props.onPress()

//then
val List(modal) = findComponents(renderer.root, raw.Modal)
val modal = inside(findComponents(renderer.root, raw.Modal)) {
case List(modal) => modal
}
modal.props.visible shouldBe true
}

it should "set visible to false when press Hide Modal" in {
//given
val renderer = createTestRenderer(<(ModalDemo())()())
val List(showModal) = findComponents(renderer.root, raw.Button)
val showModal = inside(findComponents(renderer.root, raw.Button)) {
case List(showModal) => showModal
}
showModal.props.onPress()
val List(modal) = findComponents(renderer.root, raw.Modal)
val modal = inside(findComponents(renderer.root, raw.Modal)) {
case List(modal) => modal
}
modal.props.visible shouldBe true
val List(hideModal, _) = findComponents(renderer.root, raw.Button)
val hideModal = inside(findComponents(renderer.root, raw.Button)) {
case List(hideModal, _) => hideModal
}

//when
hideModal.props.onPress()
Expand All @@ -56,7 +66,9 @@ class ModalDemoSpec extends TestSpec with TestRendererUtils {
it should "render component with modal" in {
//given
val renderer = createTestRenderer(<(ModalDemo())()())
val List(showModal) = findComponents(renderer.root, raw.Button)
val showModal = inside(findComponents(renderer.root, raw.Button)) {
case List(showModal) => showModal
}

//when
showModal.props.onPress()
Expand Down
4 changes: 2 additions & 2 deletions showcase/src/test/scala/showcase/PickerDemoSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class PickerDemoSpec extends TestSpec with TestRendererUtils {
it should "set selectedValue when onValueChange" in {
//given
val renderer = createTestRenderer(<(PickerDemo())()())
val List(picker) = findComponents(renderer.root, <.Picker.reactClass)
val picker = findComponents(renderer.root, <.Picker.reactClass).head
picker.props.selectedValue shouldBe "1"

//when
picker.props.onValueChange("2", 1)

//then
val List(updated) = findComponents(renderer.root, <.Picker.reactClass)
val updated = findComponents(renderer.root, <.Picker.reactClass).head
updated.props.selectedValue shouldBe "2"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ShowcaseRootSpec extends TestSpec with TestRendererUtils {
override val `lazy` = false
override val tabBarLabelPosition = LabelPosition.`below-icon`
}
)(), { case List(tab1, tab2, tab3, tab4) =>
)(), inside(_) { case List(tab1, tab2, tab3, tab4) =>
assertNativeComponent(tab1,
<(HomeTab.Screen)(^.name := "Home", ^.component := ShowcaseController())()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ChoiceGroupDemoSpec extends TestSpec with TestRendererUtils {
private def assertChoiceGroup(result: TestInstance): Unit = {
implicit val theme: Theme = DefaultTheme

assertNativeComponent(result, <.View(^.rnStyle := styles.container)(), { case List(t1, c1, t2, c2) =>
assertNativeComponent(result, <.View(^.rnStyle := styles.container)(), inside(_) { case List(t1, c1, t2, c2) =>
assertNativeComponent(t1, <.Text(themeStyle(styles.title, themeTextStyle))(
"Single-select (simple):"
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ class ChoiceGroupSpec extends TestSpec with TestRendererUtils {
)
}

val List(item1, item2, item3) = items
val (item1, item2, item3) = inside(items) {
case List(item1, item2, item3) => (item1, item2, item3)
}

assertNativeComponent(result,
<.View(props.style.map(^.rnStyle := _))(
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := sys.env.getOrElse("version", default = "1.0.0-SNAPSHOT").stripPrefix("v")
ThisBuild / version := sys.env.getOrElse("version", default = "1.0.0-SNAPSHOT").stripPrefix("v")

0 comments on commit edab00b

Please sign in to comment.