From 9600e71006bbdb335af49c8b8c7e5a63f52ddf9d Mon Sep 17 00:00:00 2001 From: Tatsuyuki Ishi Date: Sun, 14 Jan 2018 10:44:46 +0900 Subject: [PATCH] Replace strict undefined asserts to falsy asserts --- test/ts/src/grpc.spec.ts | 53 +++++++++++++++------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/test/ts/src/grpc.spec.ts b/test/ts/src/grpc.spec.ts index 58f5a9b6..092a800b 100644 --- a/test/ts/src/grpc.spec.ts +++ b/test/ts/src/grpc.spec.ts @@ -1,5 +1,18 @@ // Polyfills import {debug} from "../../../ts/src/debug"; +// Test Config +import {assert} from "chai"; +import {corsHost, testHost} from "../../hosts-config"; +// gRPC-Web library +import {BrowserHeaders, Code, grpc, Request,} from "../../../ts/src/index"; +// Generated Test Classes +import {Empty,} from "google-protobuf/google/protobuf/empty_pb"; +import { + CheckStreamClosedRequest, CheckStreamClosedResponse, ContinueStreamRequest, PingRequest, + PingResponse, +} from "../_proto/improbable/grpcweb/test/test_pb"; +import {FailService, TestService, TestUtilService} from "../_proto/improbable/grpcweb/test/test_pb_service"; +import {UncaughtExceptionListener} from "./util"; const global = Function('return this')(); @@ -13,12 +26,6 @@ if (typeof DataView === "undefined") { (global as any).DataView = require("typedarray").DataView; } -// Test Config -import {assert} from "chai"; -import { - testHost, - corsHost -} from "../../hosts-config"; type TestConfig = { testHostUrl: string, corsHostUrl: string, @@ -39,28 +46,8 @@ const http2Config: TestConfig = { }; const DEBUG: boolean = (global as any).DEBUG; -// gRPC-Web library -import { - grpc, - Code, - Request, - BrowserHeaders, -} from "../../../ts/src/index"; import UnaryMethodDefinition = grpc.UnaryMethodDefinition; -// Generated Test Classes -import { - Empty, -} from "google-protobuf/google/protobuf/empty_pb"; -import { - CheckStreamClosedRequest, CheckStreamClosedResponse, - ContinueStreamRequest, - PingRequest, - PingResponse, -} from "../_proto/improbable/grpcweb/test/test_pb"; -import {FailService, TestService, TestUtilService} from "../_proto/improbable/grpcweb/test/test_pb_service"; -import {UncaughtExceptionListener} from "./util"; - function headerTrailerCombos(cb: (withHeaders: boolean, withTrailers: boolean, name: string) => void) { cb(false, false, " - no headers - no trailers"); cb(true, false, " - with headers - no trailers"); @@ -115,7 +102,7 @@ function runTests({testHostUrl, corsHostUrl, unavailableHost, emptyHost}: TestCo onEnd: (status: Code, statusMessage: string, trailers: BrowserHeaders) => { DEBUG && debug("status", status, "statusMessage", statusMessage); assert.strictEqual(status, Code.OK, "expected OK (0)"); - assert.strictEqual(statusMessage, undefined, "expected no message"); + assert.isNotOk(statusMessage, "expected no message"); if (withTrailers) { assert.deepEqual(trailers.get("TrailerTestKey1"), ["ServerValue1"]); assert.deepEqual(trailers.get("TrailerTestKey2"), ["ServerValue2"]); @@ -161,7 +148,7 @@ function runTests({testHostUrl, corsHostUrl, unavailableHost, emptyHost}: TestCo onEnd: (status: Code, statusMessage: string, trailers: BrowserHeaders) => { DEBUG && debug("status", status, "statusMessage", statusMessage, "trailers", trailers); assert.strictEqual(status, Code.OK, "expected OK (0)"); - assert.strictEqual(statusMessage, undefined, "expected no message"); + assert.isNotOk(statusMessage, "expected no message"); if (withTrailers) { assert.deepEqual(trailers.get("TrailerTestKey1"), ["ServerValue1"]); assert.deepEqual(trailers.get("TrailerTestKey2"), ["ServerValue2"]); @@ -204,7 +191,7 @@ function runTests({testHostUrl, corsHostUrl, unavailableHost, emptyHost}: TestCo onEnd: (status: Code, statusMessage: string, trailers: BrowserHeaders) => { DEBUG && debug("status", status, "statusMessage", statusMessage, "trailers", trailers); assert.strictEqual(status, Code.OK, "expected OK (0)"); - assert.strictEqual(statusMessage, undefined, "expected no message"); + assert.isNotOk(statusMessage, "expected no message"); if (withTrailers) { assert.deepEqual(trailers.get("TrailerTestKey1"), ["ServerValue1"]); assert.deepEqual(trailers.get("TrailerTestKey2"), ["ServerValue2"]); @@ -253,7 +240,7 @@ function runTests({testHostUrl, corsHostUrl, unavailableHost, emptyHost}: TestCo onEnd: (status: Code, statusMessage: string, trailers: BrowserHeaders) => { DEBUG && debug("status", status, "statusMessage", statusMessage, "trailers", trailers); assert.strictEqual(status, Code.OK, "expected OK (0)"); - assert.strictEqual(statusMessage, undefined, "expected no message"); + assert.isNotOk(statusMessage, "expected no message"); if (withTrailers) { assert.deepEqual(trailers.get("TrailerTestKey1"), ["ServerValue1"]); assert.deepEqual(trailers.get("TrailerTestKey2"), ["ServerValue2"]); @@ -296,7 +283,7 @@ function runTests({testHostUrl, corsHostUrl, unavailableHost, emptyHost}: TestCo onEnd: (status: Code, statusMessage: string, trailers: BrowserHeaders) => { DEBUG && debug("status", status, "statusMessage", statusMessage, "trailers", trailers); assert.strictEqual(status, Code.OK, "expected OK (0)"); - assert.strictEqual(statusMessage, undefined, "expected no message"); + assert.isNotOk(statusMessage, "expected no message"); if (withTrailers) { assert.deepEqual(trailers.get("TrailerTestKey1"), ["ServerValue1"]); assert.deepEqual(trailers.get("TrailerTestKey2"), ["ServerValue2"]); @@ -542,7 +529,7 @@ function runTests({testHostUrl, corsHostUrl, unavailableHost, emptyHost}: TestCo onEnd: ({status, statusMessage, headers, message, trailers}) => { DEBUG && debug("status", status, "statusMessage", statusMessage, "headers", headers, "res", message, "trailers", trailers); assert.strictEqual(status, Code.OK, "expected OK (0)"); - assert.strictEqual(statusMessage, undefined, "expected no message"); + assert.isNotOk(statusMessage, "expected no message"); if (withHeaders) { assert.deepEqual(headers.get("HeaderTestKey1"), ["ServerValue1"]); assert.deepEqual(headers.get("HeaderTestKey2"), ["ServerValue2"]); @@ -577,7 +564,7 @@ function runTests({testHostUrl, corsHostUrl, unavailableHost, emptyHost}: TestCo onEnd: ({status, statusMessage, headers, message, trailers}) => { DEBUG && debug("status", status, "statusMessage", statusMessage, "headers", headers, "res", message, "trailers", trailers); assert.strictEqual(status, Code.OK, "expected OK (0)"); - assert.strictEqual(statusMessage, undefined, "expected no message"); + assert.isNotOk(statusMessage, "expected no message"); if (withHeaders) { assert.deepEqual(headers.get("HeaderTestKey1"), ["ServerValue1"]); assert.deepEqual(headers.get("HeaderTestKey2"), ["ServerValue2"]);