From f9bea4d143344f3525b243f7bb72930a8f2cf0d1 Mon Sep 17 00:00:00 2001 From: Lawrence Daniels Date: Wed, 19 Apr 2017 09:58:19 -0700 Subject: [PATCH] Test fixes --- src/test/scala/io/scalajs/nodejs/fs/FsTest.scala | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala b/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala index c016c2542..9b7b96f0a 100644 --- a/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala +++ b/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala @@ -1,7 +1,9 @@ package io.scalajs.nodejs.fs +import io.scalajs.JSON import io.scalajs.nodejs.setImmediate import io.scalajs.nodejs.util.Util +import io.scalajs.util.ScalaJsHelper._ import org.scalatest.FunSpec import scala.scalajs.js @@ -15,12 +17,16 @@ class FsTest extends FunSpec { describe("Fs") { it("supports watching files") { - val watcher = Fs.watch("./src/test/resources/", (value: js.Any) => { - info(s"watcher value: ${Util.inspect(value)}") + val watcher = Fs.watch("./src/test/resources/", (eventType, file) => { + info(s"watcher: eventType = '$eventType' file = '$file'") }) info(s"watcher: ${Util.inspect(watcher)}") - setImmediate(() => Fs.writeFile("./src/test/resources/1.txt", "Hello", () => {})) + setImmediate(() => Fs.writeFile("./src/test/resources/1.txt", "Hello", error => { + if (isDefined(error)) { + alert(s"error: ${JSON.stringify(error)}") + } + })) } it("should stream data") { @@ -31,7 +37,7 @@ class FsTest extends FunSpec { val readable = Fs.createReadStream(file1) val writable = Fs.createWriteStream(file2) readable.setEncoding("utf8") - readable.onData(chunk => writable.write(chunk)) + readable.onData[String](chunk => writable.write(chunk)) writable.onFinish { () => info("Comparing file sizes:") info(s"$file1 is ${Fs.statSync(file1).size} bytes")