Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
MINOR: Fix some tests that were failing with Karma on Windows. (#1985)
Browse files Browse the repository at this point in the history
* MINOR: Fix some tests that were failing with Karma on Windows.

* MINOR: Check with polar data sources test fails with timeout.
  • Loading branch information
atomicsulfate authored Nov 23, 2020
1 parent d77100d commit 5c22a7c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 28 deletions.
3 changes: 2 additions & 1 deletion @here/harp-mapview/test/PolarTileDataSourceTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ describe("PolarTileDataSource", function() {
assert.equal(tile2.objects.length, 0);
});

it.skip("Geometry should not exceed pole radius", function() {
it("Geometry should not exceed pole radius", function() {
this.timeout(5000);
const EPSILON = 1e-5;
const minLevel = 1; // at zoomLevel 0 there's no hole at the poles
const maxLevel = 8;
Expand Down
39 changes: 14 additions & 25 deletions @here/harp-mapview/test/WorkerLoaderTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import {
silenceLoggingAroundFunction,
stubGlobalConstructor
} from "@here/harp-test-utils";
import { assert } from "chai";
import * as chai from "chai";
import * as chaiAsPromised from "chai-as-promised";
chai.use(chaiAsPromised);
const { expect, assert } = chai;
import * as sinon from "sinon";

import { WorkerLoader } from "../lib/workers/WorkerLoader";
Expand Down Expand Up @@ -67,7 +70,6 @@ describeWithWorker("Web Worker API", function() {

describe("WorkerLoader", function() {
let sandbox: sinon.SinonSandbox;
let restoreMochaGlobalExceptionHandler: boolean = false;
beforeEach(function() {
sandbox = sinon.createSandbox();
if (typeof window === "undefined") {
Expand All @@ -81,9 +83,6 @@ describe("WorkerLoader", function() {
if (typeof window === "undefined") {
delete global.Worker;
}
if (restoreMochaGlobalExceptionHandler) {
(Mocha as any).process.addListener("uncaughtException");
}
WorkerLoader.directlyFallbackToBlobBasedLoading = false;
});

Expand Down Expand Up @@ -175,34 +174,24 @@ describe("WorkerLoader", function() {
);
});

it.skip("#startWorker catches error in worker global context", async function() {
it("#startWorker catches error in worker global context", function() {
const script = `
// We intentionally do not send anything, so waitForWorkerInitialized
// should raise timeout error.
null.foo = "aa";
`;
assert.isDefined(Blob);

// For some reason, both Chrome and Firefox call global exception handler
// for error in global worker context (probably to help lazy developers) even
// if we subscribe to `onerror`.
// It's reported on console and to mocha, so we
// 1) Show log message, so random developer is not worried about error in developer
// console
console.log(
"Next 'TypeError' about accessing null in some blob based worker is handled. " +
"Don't worry"
);

// 2) Temporarily disable global exception handler, so mocha doesn't report
// this as error
restoreMochaGlobalExceptionHandler = true;
(Mocha as any).process.removeListener("uncaughtException");
const blob = new Blob([script], { type: "application/javascript" });
await assertRejected(
WorkerLoader.startWorker(URL.createObjectURL(blob)),
/Error during worker initialization/i
);

const listener = () => {
(Mocha as any).process.removeListener("uncaughtException", listener);
};
(Mocha as any).process.on("uncaughtException", listener);

return expect(
WorkerLoader.startWorker(URL.createObjectURL(blob))
).to.be.rejectedWith(Error);
});
});

Expand Down
3 changes: 1 addition & 2 deletions @here/harp-test-utils/test/TestDataUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ describe("@here/harp-test-utils", function() {
"text"
);

assert(textFromFile);
assert.equal(textFromFile, "Test message\n");
assert.include(textFromFile, "Test message");
});
it(`loads static json file`, async function() {
const jsonFromFile = await loadTestResource(
Expand Down

0 comments on commit 5c22a7c

Please sign in to comment.