Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Fix warnings in test code #95

Merged
merged 1 commit into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/current/src/main/scala/io/scalajs/nodejs/Assert.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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[_],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
}
})
)
Expand Down Expand Up @@ -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(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(") {
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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(...)") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.scalajs.nodejs
package url

import io.scalajs.util.JSONHelper._
import io.scalajs.util.JsUnderOrHelper._
import org.scalatest.FunSpec

/**
Expand All @@ -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") {
Expand Down