diff --git a/.travis.yml b/.travis.yml index 77f171a..fe29457 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,37 +5,38 @@ jdk: dist: trusty env: global: - - TRAVIS_NODE_VERSION="8" - TRAVIS_SBT_VERSION="1.2.8" - secure: Px1jYCcHrx4Eufto0lOK8QOciiZ72baECbZWYEtz9CZfjpmuFIovfSShNrni2rYCTmxdZmpl2Royq+BhbO7IbVKXXGP3Spq0cxPfVa1VQ+s9GRjbxY7QyXUbXq2Xcs/2xiieBXLihrZwIeRKGW3SXmwiZvypYyPknugezPgx2I0ULIZOJGD3LC2WAKfdY/a5Ok6ErxQj35U01ONif6ey2B97+s3w8D/P1Qw1f2p5dpU5QCr4iXfKQgC4Cje1/A4s+Qk2BIiQbUEmBRLeTWLsAcx501BCmMoFc+t64behU6wDflvcHdDk9pWUfii0ub4PM3QNYPydTBzadlr29rkrZOL/JtXpemcRh6q0aJLcLofmJd4ess7NIzAu7/oPVWe9sv1H989GKtuqDWrZo1fTcGPYT5nmjvssrYCVPl5HCJG/jtyN4EHtNnzpl51OA4p6K3itTqdSm1JwoLdz6ReGsQi30hdloxHTyOmJDYY5AvTz8utIdAnKr8EjSM5xFbN7bApWISDAeRNrk63hCUhJvCrmBWI04PLZrT+lRylhXTieDit09jZOpfbFRHUZCw2eFp7ddhUNZArnOZOn7phphgxqIXnaRpWYDgGaCqJo4d79URJGowssRh5Vs+ozOkSvZfUlE/crQDLwaXnVt25V6EZWrOOMHUSW/kLiWCg8Vqc= - secure: a8GtpUc81dCfS2D/VKbNKxz3nztcnHyPatS8QHUr2nG2hTMZbL/7O4714EtI1QlBb7Ke64tAhAASaszJqDlWkI9xuMo6G+9U2Ui/FMG/XMe3CiBPoU56jx7bSOP7SG02wsE39hF/pqjuMDTNDSBz9+vSuyB1GnwLP15bej49ityWet/6yDAZac9atwNbLRfeuIfpQa8lfETi9vUw4o8f83gqqg4uG+k0QCTRzGMlMKMXTt9zmTQJQUVwyZrgnGweHCsO9WCpIkkSOwpzphd/6IBfob+RcCnqDPMwfAZEAWVNFs3OLznSUvQdBbyGHKlXktrK2o6johdhq6X+bmezMcxZo9di4PLYcGZiFzW0iMZKv04CVJv8Q5gUScRhH0m6IaqB93p9XPX+EV8WtXNNlSoRuAWlw6x+oyreQ7dYQY1/c5A/WXzxJFDjrITRV4y68zT8zqoTUNpDlpTtK76qXVZgWEb4ErAb0iCsVUegVgzZyodMDviNW4F7w8GvNXKUqbUV4swT0/DP2C0zJglh7U5Pxbnp8UHUNvnvf8HwrlHRUGkRfZRQ+oaFIS3XJk0kCwpETIOwnUeIKVfxVM9F3eZTzKCYCdinYKS0OsWTbtxs98kFl2gBw/Sm572bQEL3LaJTc0k/u7ZpB+bQEK7sEvk6vIr3+M/Yw2YkK/hlwtQ= - secure: X0pCqLOeXtdnwroruTgx+g89a6C1BvH6YVnlEyLVcPqSSo9pOo145CrwI1O5JX+Sej3t7J+psL6WEW0AmzRlk0MgxUIdhTkIpj7p2cRvyMVtSjI5qTDmnpCec48UbrwFSZ90BfvJddCVeZcB+aDWga7Fe1LzyN1eLc42hmFHq0p1WAfZUisHI0YKb3RzOiBKx+SzlLDN2BW3gl1OFRQl7ZFX6ORbgZhhcmOSEf74VHI3JiWLfDaPOI1KspeR+e1yQ7hSvA7V94rIz2xugv9xRgGyBLg1k9moMPR8VrBj717yn+tfXUxLOOIQUW1GLDhtlt5y/n3+yceQ6zzi9w9Keplx0wmQ29Soi5UfuYvRrSjifmzAkKl+RYZ6coJmvzcGKYatwID022dbDaPM28JQIBKmvT+Hy8j/3eyPaXHDHpThrneDawIXbdQbiT7uH62HM+wWJwb+tQrEdRMwJwlisxNBh1axefqFYV4cSsabtuT41F+oAfZKWObferSD9evlx8zABSKDCQsZfM3/+PUIo2w6WWxlviOOyzbrXIH6Ll65X3CHznh26HtdCwyTjYB3Llqez8qhV0zukIrKcNcAJVzeoiRZIjAS3KHjt8CokE2wetpvhTqbsym0zTI/zXaMZS58ioahrkR6pb+Fa7Pu9wjwhVU1+McZDcf/o9Gn7h0= before_install: -- nvm install 6 -- nvm use 6 -- node --version +- nvm install 12 && + nvm use 12 +- node --version && + npm --version - if [ $TRAVIS_PULL_REQUEST = 'false' ]; then openssl aes-256-cbc -K $encrypted_e5d9f4dea210_key -iv $encrypted_e5d9f4dea210_iv -in travis/secrets.tar.enc -out travis/secrets.tar -d; tar xv -C travis -f travis/secrets.tar; fi script: - sbt clean coverage test coverageReport && - sbt coverageAggregate -after_success: -- sbt coveralls -- if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" -o "$TRAVIS_BRANCH" == "$TRAVIS_TAG" ]; then + sbt coverageAggregate && + sbt coveralls && + if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" -o "$TRAVIS_BRANCH" == "$TRAVIS_TAG" ]; then if [ -z "$TRAVIS_TAG" ]; then echo "Publish a snapshot"; sbt clean publish; else echo "Publish a release version=$TRAVIS_TAG"; - version=$TRAVIS_TAG sbt clean publishSigned sonatypeRelease; + version=$TRAVIS_TAG sbt clean publishSigned sonatypeBundleRelease; fi else echo "This is not a master branch commit. Skipping the publish/release step"; fi cache: directories: + - ~/.npm + - ~/.nvm - "$HOME/.ivy2/cache" - "$HOME/.sbt" before_cache: diff --git a/README.md b/README.md index 8ee9cf3..123da78 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.com/scommons/scommons-react.svg?branch=master)](https://travis-ci.com/scommons/scommons-react) [![Coverage Status](https://coveralls.io/repos/github/scommons/scommons-react/badge.svg?branch=master)](https://coveralls.io/github/scommons/scommons-react?branch=master) [![scala-index](https://index.scala-lang.org/scommons/scommons-react/scommons-react-core/latest.svg)](https://index.scala-lang.org/scommons/scommons-react/scommons-react-core) -[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-0.6.17.svg)](https://www.scala-js.org) +[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-0.6.29.svg)](https://www.scala-js.org) ## Scala Commons React [Scala.js](https://www.scala-js.org) facades for common [React.js](https://reactjs.org) utilities and components. diff --git a/pgp.sbt b/pgp.sbt index b25983a..641294a 100644 --- a/pgp.sbt +++ b/pgp.sbt @@ -1,7 +1,6 @@ //see: https://www.scala-sbt.org/sbt-pgp/usage.html -useGpg := false pgpPublicRing := file("./travis/pubring.gpg") pgpSecretRing := file("./travis/secring.gpg") pgpPassphrase := sys.env.get("PGP_PASS").map(_.toArray) diff --git a/project/src/main/scala/common/Libs.scala b/project/src/main/scala/common/Libs.scala index 75e5fe9..6d5a27b 100644 --- a/project/src/main/scala/common/Libs.scala +++ b/project/src/main/scala/common/Libs.scala @@ -6,12 +6,12 @@ import scommons.sbtplugin.project.CommonLibs object Libs extends CommonLibs { - val scommonsNodejsVersion = "0.3.1" - private val sjsReactJsVer = "0.14.0" + val scommonsNodejsVersion = "1.0.0-SNAPSHOT" + private val sjsReactJsVer = "0.15.0" - lazy val sjsReactJs = Def.setting("io.github.shogowada" %%% "scalajs-reactjs" % sjsReactJsVer) - lazy val sjsReactJsRouterDom = Def.setting("io.github.shogowada" %%% "scalajs-reactjs-router-dom" % sjsReactJsVer) - lazy val sjsReactJsRouterRedux = Def.setting("io.github.shogowada" %%% "scalajs-reactjs-router-redux" % sjsReactJsVer) - lazy val sjsReactJsRedux = Def.setting("io.github.shogowada" %%% "scalajs-reactjs-redux" % sjsReactJsVer) - lazy val sjsReactJsReduxDevTools = Def.setting("io.github.shogowada" %%% "scalajs-reactjs-redux-devtools" % sjsReactJsVer) + lazy val sjsReactJs = Def.setting("org.scommons.shogowada" %%% "scalajs-reactjs" % sjsReactJsVer) + lazy val sjsReactJsRouterDom = Def.setting("org.scommons.shogowada" %%% "scalajs-reactjs-router-dom" % sjsReactJsVer) + lazy val sjsReactJsRouterRedux = Def.setting("org.scommons.shogowada" %%% "scalajs-reactjs-router-redux" % sjsReactJsVer) + lazy val sjsReactJsRedux = Def.setting("org.scommons.shogowada" %%% "scalajs-reactjs-redux" % sjsReactJsVer) + lazy val sjsReactJsReduxDevTools = Def.setting("org.scommons.shogowada" %%% "scalajs-reactjs-redux-devtools" % sjsReactJsVer) } diff --git a/project/src/main/scala/definitions/ReactModule.scala b/project/src/main/scala/definitions/ReactModule.scala index e1ebe1d..f7cf005 100644 --- a/project/src/main/scala/definitions/ReactModule.scala +++ b/project/src/main/scala/definitions/ReactModule.scala @@ -26,12 +26,7 @@ object ReactModule { sonatypeProfileName := "org.scommons", publishMavenStyle := true, publishArtifact in Test := false, - publishTo := { - if (isSnapshot.value) - Some("snapshots" at "https://oss.sonatype.org/content/repositories/snapshots") - else - Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2") - }, + publishTo := sonatypePublishToBundle.value, pomExtra := { https://github.com/scommons/scommons-react diff --git a/project/src/main/scala/definitions/ScalaJsModule.scala b/project/src/main/scala/definitions/ScalaJsModule.scala index b79044b..bc09d08 100644 --- a/project/src/main/scala/definitions/ScalaJsModule.scala +++ b/project/src/main/scala/definitions/ScalaJsModule.scala @@ -5,7 +5,6 @@ import sbt._ import scommons.sbtplugin.project.CommonClientModule import scalajsbundler.sbtplugin.ScalaJSBundlerPlugin -import scalajsbundler.sbtplugin.ScalaJSBundlerPlugin.autoImport._ trait ScalaJsModule extends ReactModule { @@ -13,8 +12,5 @@ trait ScalaJsModule extends ReactModule { super.definition .enablePlugins(ScalaJSPlugin, ScalaJSBundlerPlugin) .settings(CommonClientModule.settings: _*) - .settings( - requireJsDomEnv in Test := false - ) } } diff --git a/showcase/src/test/scala/scommons/react/showcase/ClassComponentDemoSpec.scala b/showcase/src/test/scala/scommons/react/showcase/ClassComponentDemoSpec.scala index ba50b6e..dc72f42 100644 --- a/showcase/src/test/scala/scommons/react/showcase/ClassComponentDemoSpec.scala +++ b/showcase/src/test/scala/scommons/react/showcase/ClassComponentDemoSpec.scala @@ -12,11 +12,11 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { it should "render component" in { //given - val componentDidMount = mock[(DemoProps, DemoState) => ClassComponentDemoState] - val shouldComponentUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Boolean] - val componentDidUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Unit] - val componentWillUnmount = mock[(DemoProps, DemoState) => Unit] - val rendered = mock[(ClassComponentDemoProps, ClassComponentDemoState) => Unit] + val componentDidMount = mockFunction[DemoProps, DemoState, ClassComponentDemoState] + val shouldComponentUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Boolean] + val componentDidUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Unit] + val componentWillUnmount = mockFunction[DemoProps, DemoState, Unit] + val rendered = mockFunction[ClassComponentDemoProps, ClassComponentDemoState, Unit] val props = ClassComponentDemoProps("test") val comp = new ClassComponentDemo( @@ -29,11 +29,11 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { val state = ClassComponentDemoState(s"initial: ${props.propValue}") inSequence { - (rendered.apply _).expects(props, state) - (componentDidMount.apply _).expects(props, state).returning(state) - (shouldComponentUpdate.apply _).expects(*, *, *, *).never() - (componentDidUpdate.apply _).expects(*, *, *, *).never() - (componentWillUnmount.apply _).expects(*, *).never() + rendered.expects(props, state) + componentDidMount.expects(props, state).returning(state) + shouldComponentUpdate.expects(*, *, *, *).never() + componentDidUpdate.expects(*, *, *, *).never() + componentWillUnmount.expects(*, *).never() } //when @@ -51,11 +51,11 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { it should "update component when props change" in { //given - val componentDidMount = mock[(DemoProps, DemoState) => ClassComponentDemoState] - val shouldComponentUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Boolean] - val componentDidUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Unit] - val componentWillUnmount = mock[(DemoProps, DemoState) => Unit] - val rendered = mock[(ClassComponentDemoProps, ClassComponentDemoState) => Unit] + val componentDidMount = mockFunction[DemoProps, DemoState, ClassComponentDemoState] + val shouldComponentUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Boolean] + val componentDidUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Unit] + val componentWillUnmount = mockFunction[DemoProps, DemoState, Unit] + val rendered = mockFunction[ClassComponentDemoProps, ClassComponentDemoState, Unit] val props = ClassComponentDemoProps("test") val comp = new ClassComponentDemo( @@ -70,12 +70,12 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { //then inSequence { - (rendered.apply _).expects(props, state) - (componentDidMount.apply _).expects(props, state).returning(state) - (shouldComponentUpdate.apply _).expects(props, state, newProps, state).returning(true) - (rendered.apply _).expects(newProps, state) - (componentDidUpdate.apply _).expects(newProps, state, props, state) - (componentWillUnmount.apply _).expects(newProps, state) + rendered.expects(props, state) + componentDidMount.expects(props, state).returning(state) + shouldComponentUpdate.expects(props, state, newProps, state).returning(true) + rendered.expects(newProps, state) + componentDidUpdate.expects(newProps, state, props, state) + componentWillUnmount.expects(newProps, state) } val renderer = createTestRenderer(<(comp())(^.wrapped := props)("some child")) @@ -87,11 +87,11 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { it should "update component when state change" in { //given - val componentDidMount = mock[(DemoProps, DemoState) => ClassComponentDemoState] - val shouldComponentUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Boolean] - val componentDidUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Unit] - val componentWillUnmount = mock[(DemoProps, DemoState) => Unit] - val rendered = mock[(ClassComponentDemoProps, ClassComponentDemoState) => Unit] + val componentDidMount = mockFunction[DemoProps, DemoState, ClassComponentDemoState] + val shouldComponentUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Boolean] + val componentDidUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Unit] + val componentWillUnmount = mockFunction[DemoProps, DemoState, Unit] + val rendered = mockFunction[ClassComponentDemoProps, ClassComponentDemoState, Unit] val props = ClassComponentDemoProps("test") val comp = new ClassComponentDemo( @@ -106,15 +106,15 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { //then inSequence { - (rendered.apply _).expects(props, state) - (componentDidMount.apply _).expects(props, state).returning(newState) - (shouldComponentUpdate.apply _).expects(props, state, props, newState).returning(true) - (rendered.apply _).expects(props, newState) - (componentDidUpdate.apply _).expects(props, newState, props, state) - (shouldComponentUpdate.apply _).expects(props, newState, props, newState).returning(true) - (rendered.apply _).expects(props, newState) - (componentDidUpdate.apply _).expects(props, newState, props, newState) - (componentWillUnmount.apply _).expects(props, newState) + rendered.expects(props, state) + componentDidMount.expects(props, state).returning(newState) + shouldComponentUpdate.expects(props, state, props, newState).returning(true) + rendered.expects(props, newState) + componentDidUpdate.expects(props, newState, props, state) + shouldComponentUpdate.expects(props, newState, props, newState).returning(true) + rendered.expects(props, newState) + componentDidUpdate.expects(props, newState, props, newState) + componentWillUnmount.expects(props, newState) } val renderer = createTestRenderer(<(comp())(^.wrapped := props)("some child")) @@ -126,11 +126,11 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { it should "update component when children change" in { //given - val componentDidMount = mock[(DemoProps, DemoState) => ClassComponentDemoState] - val shouldComponentUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Boolean] - val componentDidUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Unit] - val componentWillUnmount = mock[(DemoProps, DemoState) => Unit] - val rendered = mock[(ClassComponentDemoProps, ClassComponentDemoState) => Unit] + val componentDidMount = mockFunction[DemoProps, DemoState, ClassComponentDemoState] + val shouldComponentUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Boolean] + val componentDidUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Unit] + val componentWillUnmount = mockFunction[DemoProps, DemoState, Unit] + val rendered = mockFunction[ClassComponentDemoProps, ClassComponentDemoState, Unit] val props = ClassComponentDemoProps("test") val comp = new ClassComponentDemo( @@ -144,12 +144,12 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { //then inSequence { - (rendered.apply _).expects(props, state) - (componentDidMount.apply _).expects(props, state).returning(state) - (shouldComponentUpdate.apply _).expects(props, state, props, state).returning(true) - (rendered.apply _).expects(props, state) - (componentDidUpdate.apply _).expects(props, state, props, state) - (componentWillUnmount.apply _).expects(props, state) + rendered.expects(props, state) + componentDidMount.expects(props, state).returning(state) + shouldComponentUpdate.expects(props, state, props, state).returning(true) + rendered.expects(props, state) + componentDidUpdate.expects(props, state, props, state) + componentWillUnmount.expects(props, state) } val renderer = createTestRenderer(<(comp())(^.wrapped := props)("some child")) @@ -172,11 +172,11 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { it should "re-render component if props hasn't changed when shouldComponentUpdate => true" in { //given - val componentDidMount = mock[(DemoProps, DemoState) => ClassComponentDemoState] - val shouldComponentUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Boolean] - val componentDidUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Unit] - val componentWillUnmount = mock[(DemoProps, DemoState) => Unit] - val rendered = mock[(ClassComponentDemoProps, ClassComponentDemoState) => Unit] + val componentDidMount = mockFunction[DemoProps, DemoState, ClassComponentDemoState] + val shouldComponentUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Boolean] + val componentDidUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Unit] + val componentWillUnmount = mockFunction[DemoProps, DemoState, Unit] + val rendered = mockFunction[ClassComponentDemoProps, ClassComponentDemoState, Unit] val props = ClassComponentDemoProps("test") val comp = new ClassComponentDemo( @@ -191,12 +191,12 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { //then inSequence { - (rendered.apply _).expects(props, state) - (componentDidMount.apply _).expects(props, state).returning(state) - (shouldComponentUpdate.apply _).expects(props, state, props, state).returning(true) - (rendered.apply _).expects(props, state) - (componentDidUpdate.apply _).expects(props, state, props, state) - (componentWillUnmount.apply _).expects(sameProps, state) + rendered.expects(props, state) + componentDidMount.expects(props, state).returning(state) + shouldComponentUpdate.expects(props, state, props, state).returning(true) + rendered.expects(props, state) + componentDidUpdate.expects(props, state, props, state) + componentWillUnmount.expects(sameProps, state) } val renderer = createTestRenderer(<(comp())(^.wrapped := props)("some child")) @@ -208,11 +208,11 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { it should "re-render component if state hasn't changed when shouldComponentUpdate => true" in { //given - val componentDidMount = mock[(DemoProps, DemoState) => ClassComponentDemoState] - val shouldComponentUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Boolean] - val componentDidUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Unit] - val componentWillUnmount = mock[(DemoProps, DemoState) => Unit] - val rendered = mock[(ClassComponentDemoProps, ClassComponentDemoState) => Unit] + val componentDidMount = mockFunction[DemoProps, DemoState, ClassComponentDemoState] + val shouldComponentUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Boolean] + val componentDidUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Unit] + val componentWillUnmount = mockFunction[DemoProps, DemoState, Unit] + val rendered = mockFunction[ClassComponentDemoProps, ClassComponentDemoState, Unit] val props = ClassComponentDemoProps("test") val comp = new ClassComponentDemo( @@ -227,12 +227,12 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { //then inSequence { - (rendered.apply _).expects(props, state) - (componentDidMount.apply _).expects(props, state).returning(sameState) - (shouldComponentUpdate.apply _).expects(props, state, props, state).returning(true) - (rendered.apply _).expects(props, state) - (componentDidUpdate.apply _).expects(props, state, props, state) - (componentWillUnmount.apply _).expects(props, sameState) + rendered.expects(props, state) + componentDidMount.expects(props, state).returning(sameState) + shouldComponentUpdate.expects(props, state, props, state).returning(true) + rendered.expects(props, state) + componentDidUpdate.expects(props, state, props, state) + componentWillUnmount.expects(props, sameState) } val renderer = createTestRenderer(<(comp())(^.wrapped := props)("some child")) @@ -244,11 +244,11 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { it should "not re-render component if props hasn't changed when shouldComponentUpdate => false" in { //given - val componentDidMount = mock[(DemoProps, DemoState) => ClassComponentDemoState] - val shouldComponentUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Boolean] - val componentDidUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Unit] - val componentWillUnmount = mock[(DemoProps, DemoState) => Unit] - val rendered = mock[(ClassComponentDemoProps, ClassComponentDemoState) => Unit] + val componentDidMount = mockFunction[DemoProps, DemoState, ClassComponentDemoState] + val shouldComponentUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Boolean] + val componentDidUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Unit] + val componentWillUnmount = mockFunction[DemoProps, DemoState, Unit] + val rendered = mockFunction[ClassComponentDemoProps, ClassComponentDemoState, Unit] val props = ClassComponentDemoProps("test") val comp = new ClassComponentDemo( @@ -263,12 +263,12 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { //then inSequence { - (rendered.apply _).expects(props, state) - (componentDidMount.apply _).expects(props, state).returning(state) - (shouldComponentUpdate.apply _).expects(props, state, props, state).returning(false) - (rendered.apply _).expects(*, *).never() - (componentDidUpdate.apply _).expects(*, *, *, *).never() - (componentWillUnmount.apply _).expects(sameProps, state) + rendered.expects(props, state) + componentDidMount.expects(props, state).returning(state) + shouldComponentUpdate.expects(props, state, props, state).returning(false) + rendered.expects(*, *).never() + componentDidUpdate.expects(*, *, *, *).never() + componentWillUnmount.expects(sameProps, state) } val renderer = createTestRenderer(<(comp())(^.wrapped := props)("some child")) @@ -280,11 +280,11 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { it should "not re-render component if state hasn't changed when shouldComponentUpdate => false" in { //given - val componentDidMount = mock[(DemoProps, DemoState) => ClassComponentDemoState] - val shouldComponentUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Boolean] - val componentDidUpdate = mock[(DemoProps, DemoState, DemoProps, DemoState) => Unit] - val componentWillUnmount = mock[(DemoProps, DemoState) => Unit] - val rendered = mock[(ClassComponentDemoProps, ClassComponentDemoState) => Unit] + val componentDidMount = mockFunction[DemoProps, DemoState, ClassComponentDemoState] + val shouldComponentUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Boolean] + val componentDidUpdate = mockFunction[DemoProps, DemoState, DemoProps, DemoState, Unit] + val componentWillUnmount = mockFunction[DemoProps, DemoState, Unit] + val rendered = mockFunction[ClassComponentDemoProps, ClassComponentDemoState, Unit] val props = ClassComponentDemoProps("test") val comp = new ClassComponentDemo( @@ -299,12 +299,12 @@ class ClassComponentDemoSpec extends TestSpec with TestRendererUtils { //then inSequence { - (rendered.apply _).expects(props, state) - (componentDidMount.apply _).expects(props, state).returning(sameState) - (shouldComponentUpdate.apply _).expects(props, state, props, state).returning(false) - (rendered.apply _).expects(*, *).never() - (componentDidUpdate.apply _).expects(*, *, *, *).never() - (componentWillUnmount.apply _).expects(props, sameState) + rendered.expects(props, state) + componentDidMount.expects(props, state).returning(sameState) + shouldComponentUpdate.expects(props, state, props, state).returning(false) + rendered.expects(*, *).never() + componentDidUpdate.expects(*, *, *, *).never() + componentWillUnmount.expects(props, sameState) } val renderer = createTestRenderer(<(comp())(^.wrapped := props)("some child")) diff --git a/test-dom/src/main/scala/scommons/react/test/dom/AsyncTestSpec.scala b/test-dom/src/main/scala/scommons/react/test/dom/AsyncTestSpec.scala index d0b730a..057f4de 100644 --- a/test-dom/src/main/scala/scommons/react/test/dom/AsyncTestSpec.scala +++ b/test-dom/src/main/scala/scommons/react/test/dom/AsyncTestSpec.scala @@ -3,10 +3,11 @@ package scommons.react.test.dom import org.scalactic.source.Position import org.scalajs.dom import org.scalamock.scalatest.AsyncMockFactory +import org.scalatest.Assertion import org.scalatest.concurrent.PatienceConfiguration import org.scalatest.exceptions.{StackDepthException, TestFailedDueToTimeoutException} +import org.scalatest.flatspec.AsyncFlatSpec import org.scalatest.time.{Millis, Seconds, Span} -import org.scalatest.{Assertion, AsyncFlatSpec} import scommons.react.test.BaseTestSpec import scala.concurrent.{ExecutionContext, Future, Promise} diff --git a/test-dom/src/main/scala/scommons/react/test/dom/util/TestDOMUtils.scala b/test-dom/src/main/scala/scommons/react/test/dom/util/TestDOMUtils.scala index 0f47ab7..b7f3d83 100644 --- a/test-dom/src/main/scala/scommons/react/test/dom/util/TestDOMUtils.scala +++ b/test-dom/src/main/scala/scommons/react/test/dom/util/TestDOMUtils.scala @@ -5,7 +5,8 @@ import io.github.shogowada.scalajs.reactjs.elements.ReactElement import io.github.shogowada.statictags import org.scalajs.dom import org.scalajs.dom._ -import org.scalatest.{BeforeAndAfterEach, Matchers, Suite} +import org.scalatest.matchers.should.Matchers +import org.scalatest.{BeforeAndAfterEach, Suite} import scommons.react.test.dom.raw.{ReactTestUtils, Simulate} import scala.scalajs.js diff --git a/test/src/main/scala/scommons/react/test/BaseTestSpec.scala b/test/src/main/scala/scommons/react/test/BaseTestSpec.scala index e0d5d2f..64fab57 100644 --- a/test/src/main/scala/scommons/react/test/BaseTestSpec.scala +++ b/test/src/main/scala/scommons/react/test/BaseTestSpec.scala @@ -3,7 +3,8 @@ package scommons.react.test import io.github.shogowada.scalajs.reactjs.VirtualDOM import io.github.shogowada.scalajs.reactjs.elements.ReactElement import io.github.shogowada.statictags.Element -import org.scalatest.{Inside, Matchers} +import org.scalatest.Inside +import org.scalatest.matchers.should.Matchers import scala.language.implicitConversions diff --git a/test/src/main/scala/scommons/react/test/TestSpec.scala b/test/src/main/scala/scommons/react/test/TestSpec.scala index cdfd93a..2b382da 100644 --- a/test/src/main/scala/scommons/react/test/TestSpec.scala +++ b/test/src/main/scala/scommons/react/test/TestSpec.scala @@ -1,8 +1,8 @@ package scommons.react.test import org.scalamock.scalatest.MockFactory -import org.scalatest.FlatSpec +import org.scalatest.flatspec.AnyFlatSpec -trait TestSpec extends FlatSpec +trait TestSpec extends AnyFlatSpec with BaseTestSpec with MockFactory diff --git a/test/src/main/scala/scommons/react/test/util/RendererUtils.scala b/test/src/main/scala/scommons/react/test/util/RendererUtils.scala index 6009005..2381daf 100644 --- a/test/src/main/scala/scommons/react/test/util/RendererUtils.scala +++ b/test/src/main/scala/scommons/react/test/util/RendererUtils.scala @@ -2,7 +2,8 @@ package scommons.react.test.util import io.github.shogowada.scalajs.reactjs.elements.ReactElement import org.scalactic.source.Position -import org.scalatest.{Assertion, Matchers, Succeeded} +import org.scalatest.matchers.should.Matchers +import org.scalatest.{Assertion, Succeeded} import scommons.react.UiComponent import scommons.react.test.raw.RenderedInstance