diff --git a/build.sbt b/build.sbt new file mode 100644 index 0000000..f6d614c --- /dev/null +++ b/build.sbt @@ -0,0 +1,18 @@ +scalaJSSettings + +name := "Scala.js Tutorial" + +scalaVersion := "2.11.2" + +libraryDependencies += "org.scala-lang.modules.scalajs" %%% "scalajs-jquery" % "0.6" + +ScalaJSKeys.jsDependencies += scala.scalajs.sbtplugin.RuntimeDOM + +skip in ScalaJSKeys.packageJSDependencies := false + +// uTest settings +utest.jsrunner.Plugin.utestJsSettings + +ScalaJSKeys.persistLauncher in Compile := true + +ScalaJSKeys.persistLauncher in Test := false diff --git a/project/build.properties b/project/build.properties new file mode 100644 index 0000000..64abd37 --- /dev/null +++ b/project/build.properties @@ -0,0 +1 @@ +sbt.version=0.13.6 diff --git a/project/plugins.sbt b/project/plugins.sbt new file mode 100644 index 0000000..0e893f0 --- /dev/null +++ b/project/plugins.sbt @@ -0,0 +1,3 @@ +addSbtPlugin("org.scala-lang.modules.scalajs" % "scalajs-sbt-plugin" % "0.5.6") + +addSbtPlugin("com.lihaoyi" % "utest-js-plugin" % "0.2.3") diff --git a/scalajs-tutorial-fastopt.html b/scalajs-tutorial-fastopt.html new file mode 100644 index 0000000..0cef602 --- /dev/null +++ b/scalajs-tutorial-fastopt.html @@ -0,0 +1,15 @@ + + +
+ +Hello World
") + } + + def addClickedMessage(): Unit = { + jQuery("body").append("You clicked the button!
") + } +} diff --git a/src/test/scala/tutorial/webapp/TutorialTest.scala b/src/test/scala/tutorial/webapp/TutorialTest.scala new file mode 100644 index 0000000..475b0f1 --- /dev/null +++ b/src/test/scala/tutorial/webapp/TutorialTest.scala @@ -0,0 +1,31 @@ +package tutorial.webapp + +import utest._ + +import org.scalajs.jquery.jQuery + +object TutorialTest extends TestSuite { + + // Initialize App + TutorialApp.setupUI() + + def tests = TestSuite { + 'HelloWorld { + assert(jQuery("p:contains('Hello World')").length == 1) + } + + 'ButtonClick { + def messageCount = + jQuery("p:contains('You clicked the button!')").length + + val button = jQuery("button:contains('Click me!')") + assert(button.length == 1) + assert(messageCount == 0) + + for (c <- 1 to 5) { + button.click() + assert(messageCount == c) + } + } + } +}