Skip to content

Commit 7c221b0

Browse files
committed
Add a variant of the custom test that does not use TestKit.
1 parent 9463ff2 commit 7c221b0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

jsdom-nodejs-env/src/test/scala/org/scalajs/jsenv/jsdomnodejs/JSDOMNodeJSEnvTest.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ import org.scalajs.jsenv.test._
1212

1313
class JSDOMNodeJSEnvTest {
1414

15+
private val TestRunConfig = {
16+
RunConfig()
17+
.withInheritOut(false)
18+
.withOnOutputStream((_, _) => ()) // ignore stdout
19+
}
20+
1521
private val config = JSDOMNodeJSSuite.Config
1622
private val kit = new TestKit(config, withCom = true)
1723
import kit._
@@ -27,4 +33,25 @@ class JSDOMNodeJSEnvTest {
2733
|""".stripMargin
2834
}
2935

36+
@Test
37+
def historyAPIWithoutTestKit: Unit = {
38+
assertRunSucceeds(
39+
"""
40+
|console.log(window.location.href);
41+
|window.history.pushState({}, "", "/foo");
42+
|console.log(window.location.href);
43+
""".stripMargin)
44+
}
45+
46+
private def assertRunSucceeds(inputStr: String): Unit = {
47+
val inputFile = MemVirtualBinaryFile.fromStringUTF8("test.js", inputStr)
48+
val input = Input.ScriptsToLoad(List(inputFile))
49+
val run = config.jsEnv.start(input, TestRunConfig)
50+
try {
51+
Await.result(run.future, config.awaitTimeout)
52+
} finally {
53+
run.close()
54+
}
55+
}
56+
3057
}

0 commit comments

Comments
 (0)