File tree Expand file tree Collapse file tree 5 files changed +45
-3
lines changed
main/scala/tutorial/webapp
test/scala/tutorial/webapp Expand file tree Collapse file tree 5 files changed +45
-3
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,13 @@ scalaVersion := "2.11.2"
6
6
7
7
libraryDependencies += " org.scala-lang.modules.scalajs" %%% " scalajs-jquery" % " 0.6"
8
8
9
+ ScalaJSKeys .jsDependencies += scala.scalajs.sbtplugin.RuntimeDOM
10
+
9
11
skip in ScalaJSKeys .packageJSDependencies := false
12
+
13
+ // uTest settings
14
+ utest.jsrunner.Plugin .utestJsSettings
15
+
16
+ ScalaJSKeys .persistLauncher in Compile := true
17
+
18
+ ScalaJSKeys .persistLauncher in Test := false
Original file line number Diff line number Diff line change 1
1
addSbtPlugin(" org.scala-lang.modules.scalajs" % " scalajs-sbt-plugin" % " 0.5.6" )
2
+
3
+ addSbtPlugin(" com.lihaoyi" % " utest-js-plugin" % " 0.2.3" )
Original file line number Diff line number Diff line change 5
5
< title > The Scala.js Tutorial</ title >
6
6
</ head >
7
7
< body >
8
- < button id ="click-me-button " type ="button "> Click me!</ button >
9
-
10
8
<!-- Include JavaScript dependencies -->
11
9
< script type ="text/javascript " src ="./target/scala-2.11/scala-js-tutorial-jsdeps.js "> </ script >
12
10
<!-- Include Scala.js compiled code -->
Original file line number Diff line number Diff line change @@ -10,8 +10,10 @@ object TutorialApp extends JSApp {
10
10
}
11
11
12
12
def setupUI (): Unit = {
13
+ jQuery(""" <button type="button">Click me!</button>""" )
14
+ .click(addClickedMessage _)
15
+ .appendTo(jQuery(" body" ))
13
16
jQuery(" body" ).append(" <p>Hello World</p>" )
14
- jQuery(" #click-me-button" ).click(addClickedMessage _)
15
17
}
16
18
17
19
def addClickedMessage (): Unit = {
Original file line number Diff line number Diff line change
1
+ package tutorial .webapp
2
+
3
+ import utest ._
4
+
5
+ import org .scalajs .jquery .jQuery
6
+
7
+ object TutorialTest extends TestSuite {
8
+
9
+ // Initialize App
10
+ TutorialApp .setupUI()
11
+
12
+ def tests = TestSuite {
13
+ ' HelloWorld {
14
+ assert(jQuery(" p:contains('Hello World')" ).length == 1 )
15
+ }
16
+
17
+ ' ButtonClick {
18
+ def messageCount =
19
+ jQuery(" p:contains('You clicked the button!')" ).length
20
+
21
+ val button = jQuery(" button:contains('Click me!')" )
22
+ assert(button.length == 1 )
23
+ assert(messageCount == 0 )
24
+
25
+ for (c <- 1 to 5 ) {
26
+ button.click()
27
+ assert(messageCount == c)
28
+ }
29
+ }
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments