File tree 3 files changed +11
-36
lines changed
jsdom-nodejs-env/src/test/scala/org/scalajs/jsenv/jsdomnodejs
3 files changed +11
-36
lines changed Original file line number Diff line number Diff line change 1
1
package org .scalajs .jsenv .jsdomnodejs
2
2
3
- import scala .concurrent .Await
3
+ import scala .concurrent .duration . _
4
4
5
5
import org .junit .Test
6
6
7
- import org .scalajs .io ._
8
-
9
- import org .scalajs .jsenv ._
7
+ import org .scalajs .jsenv .test .kit .TestKit
10
8
11
9
class JSDOMNodeJSEnvTest {
12
-
13
- private val TestRunConfig = {
14
- RunConfig ()
15
- .withInheritOut(false )
16
- .withOnOutputStream((_, _) => ()) // ignore stdout
17
- }
18
-
19
- private val config = JSDOMNodeJSSuite .Config
10
+ private val kit = new TestKit (new JSDOMNodeJSEnv , 1 .minute)
20
11
21
12
@ Test
22
- def historyAPIWithoutTestKit : Unit = {
23
- assertRunSucceeds (
13
+ def historyAPI : Unit = {
14
+ kit.withRun (
24
15
"""
25
16
|console.log(window.location.href);
26
17
|window.history.pushState({}, "", "/foo");
27
18
|console.log(window.location.href);
28
- """ .stripMargin)
29
- }
30
-
31
- private def assertRunSucceeds (inputStr : String ): Unit = {
32
- val inputFile = MemVirtualBinaryFile .fromStringUTF8(" test.js" , inputStr)
33
- val input = Input .ScriptsToLoad (List (inputFile))
34
- val run = config.jsEnv.start(input, TestRunConfig )
35
- try {
36
- Await .result(run.future, config.awaitTimeout)
37
- } finally {
38
- run.close()
19
+ """ .stripMargin) {
20
+ _.expectOut(" http://localhost/\n " )
21
+ .expectOut(" http://localhost/foo\n " )
39
22
}
40
23
}
41
-
42
24
}
Original file line number Diff line number Diff line change @@ -5,11 +5,4 @@ import org.scalajs.jsenv.test._
5
5
import org .junit .runner .RunWith
6
6
7
7
@ RunWith (classOf [JSEnvSuiteRunner ])
8
- class JSDOMNodeJSSuite extends JSEnvSuite (JSDOMNodeJSSuite .Config )
9
-
10
- object JSDOMNodeJSSuite {
11
- val Config = {
12
- JSEnvSuiteConfig (new JSDOMNodeJSEnv )
13
- .withTerminateVMJSCode(" __ScalaJSEnv.exitFunction(0)" )
14
- }
15
- }
8
+ class JSDOMNodeJSSuite extends JSEnvSuite (JSEnvSuiteConfig (new JSDOMNodeJSEnv ))
Original file line number Diff line number Diff line change 1
- addSbtPlugin(" org.scala-js" % " sbt-scalajs" % " 1.0.0-M5 " )
1
+ addSbtPlugin(" org.scala-js" % " sbt-scalajs" % " 1.0.0-M6 " )
2
2
3
- libraryDependencies += " org.scala-js" %% " scalajs-env-nodejs" % " 1.0.0-M5 "
3
+ libraryDependencies += " org.scala-js" %% " scalajs-env-nodejs" % " 1.0.0-M6 "
4
4
5
5
unmanagedSourceDirectories in Compile +=
6
6
baseDirectory.value.getParentFile / " jsdom-nodejs-env/src/main/scala"
You can’t perform that action at this time.
0 commit comments