From 6c3000b41d17271cf5765ae53ba59948197b023f Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 3 Oct 2019 21:26:56 +0900 Subject: [PATCH] Fix warnings in test code --- .../src/main/scala/io/scalajs/nodejs/Assert.scala | 2 +- .../test/scala/io/scalajs/nodejs/AssertTest.scala | 2 +- .../io/scalajs/nodejs/cluster/ClusterTest.scala | 1 - .../src/test/scala/io/scalajs/nodejs/fs/FsTest.scala | 5 +++-- .../scala/io/scalajs/nodejs/fs/ReadStreamTest.scala | 4 +--- .../scalajs/nodejs/querystring/QueryStringTest.scala | 4 ++-- .../scala/io/scalajs/nodejs/url/URLObjectTest.scala | 12 ++++-------- 7 files changed, 12 insertions(+), 18 deletions(-) diff --git a/app/current/src/main/scala/io/scalajs/nodejs/Assert.scala b/app/current/src/main/scala/io/scalajs/nodejs/Assert.scala index 4c7dad037..a3661dc13 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/Assert.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/Assert.scala @@ -33,7 +33,7 @@ trait Assert extends IEventEmitter { * strict equality operator ( === ). Second, object comparisons include a strict equality check of their prototypes. * @example assert.deepStrictEqual(actual, expected[, message]) */ - def deepStrictEqual(actual: js.Any, expected: js.Any, message: String): Unit = js.native + def deepStrictEqual(actual: js.Any, expected: js.Any, message: String = js.native): Unit = js.native @enableIf(io.scalajs.nodejs.CompilerSwitches.gteNodeJs10) def doesNotReject(asyncFn: js.Function | js.Promise[_], diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/AssertTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/AssertTest.scala index a17e5285c..b45643fd3 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/AssertTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/AssertTest.scala @@ -12,7 +12,7 @@ class AssertTest extends FunSpec { describe("Assert") { it("should handle deep comparisons") { - Assert.deepEqual(js.Array(1, 2, 3), js.Array(1, 2, 3)) + Assert.deepStrictEqual(js.Array(1, 2, 3), js.Array(1, 2, 3)) } } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala index a0aab4fcb..244464ea9 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs.cluster -import io.scalajs.JSON import io.scalajs.nodejs.setTimeout import io.scalajs.util.DurationHelper._ import org.scalatest.FunSpec diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala index 3df110f67..b8b21fba8 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala @@ -1,6 +1,7 @@ package io.scalajs.nodejs.fs import io.scalajs.nodejs.setImmediate +import io.scalajs.util.NodeJSConverters._ import io.scalajs.util.ScalaJsHelper._ import org.scalatest.AsyncFunSpec @@ -30,7 +31,7 @@ class FsTest extends AsyncFunSpec { () => Fs.writeFile(s"${testResources}1.txt", "Hello", error => { if (isDefined(error)) { - promise.failure(error) + promise.failure(error.toException) } }) ) @@ -102,7 +103,7 @@ class FsTest extends AsyncFunSpec { val promise = Promise[Unit]() Fs.access("./package.json", err => { if (isDefined(err)) { - promise.failure(err) + promise.failure(err.toException()) } else { promise.success(()) } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala index c3fadfdaf..cd385aee6 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala @@ -5,10 +5,8 @@ import io.scalajs.nodejs.buffer.Buffer import io.scalajs.nodejs.url.URL import org.scalatest.FunSpec -import scala.scalajs.js - class FsClassesTest extends FunSpec { - val dirname = process.cwd() + val dirname = process.Process.cwd() describe("ReadStream") { it("supports constructor(") { diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala index 5a1524444..33602abc9 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala @@ -1,6 +1,5 @@ package io.scalajs.nodejs.querystring -import io.scalajs.nodejs.Assert import io.scalajs.nodejs.querystring.QueryStringTest.MyParams import org.scalatest.FunSpec @@ -20,7 +19,8 @@ class QueryStringTest extends FunSpec { it("should parse(...)") { val result = QueryString.parse("""https://www.google.com/#q=node?key=1234""") - Assert.deepEqual(result, js.Dictionary("https://www.google.com/#q" -> "node?key=1234")) + assert(result("https://www.google.com/#q") === "node?key=1234") + assert(result.size === 1) } it("should stringify(...)") { diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala index d459947b9..0cc3eb37d 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala @@ -2,7 +2,6 @@ package io.scalajs.nodejs package url import io.scalajs.util.JSONHelper._ -import io.scalajs.util.JsUnderOrHelper._ import org.scalatest.FunSpec /** @@ -13,20 +12,17 @@ class URLObjectTest extends FunSpec { describe("URLObject") { val originalUrl = "https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node" - val urlObject = URL.parse(originalUrl) + val urlObject = new URL(originalUrl) it("should break down URLs into components") { assert( - urlObject.toJson === """{"protocol":"https:","slashes":true,"auth":null,"host":"www.google.com","port":null,"hostname":"www.google.com","hash":"#q=node","search":"?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","query":"sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","pathname":"/webhp","path":"/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","href":"https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node"}""" + urlObject.toJson === "\"https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node\"" ) - } - - it("should be properly extracted") { - assert(urlObject.query ?== "sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8") + // """{"protocol":"https:","slashes":true,"auth":null,"host":"www.google.com","port":null,"hostname":"www.google.com","hash":"#q=node","search":"?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","query":"sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","pathname":"/webhp","path":"/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","href":"https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node"}""" } it("should properly extract the search query") { - assert(urlObject.search ?== "?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8") + assert(urlObject.search === "?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8") } it("should reconstituted the URL to match the original") {