Skip to content

Commit

Permalink
update all packages
Browse files Browse the repository at this point in the history
  • Loading branch information
dcharbonnier committed Nov 13, 2019
1 parent c4de43e commit abe54aa
Show file tree
Hide file tree
Showing 3 changed files with 1,727 additions and 1,817 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"toc": "markdown-toc README.md -i --maxdepth 3",
"build": "tsc -p ./tsconfig.json --outDir dist/",
"test": "yarn test-node && yarn test-karma && yarn build && yarn test-typescript-compatibility",
"test-typescript-compatibility": "for version in 2.7 2.8 2.9 3.0 3.1 3.2.4 3.3; do ./test-typescript-compatibility.sh $version || exit 1;done;",
"test-typescript-compatibility": "for version in 2.7 2.8 2.9 3.0 3.1 3.2.4 3.3 3.4.5 3.5.1 3.6.4 3.7.2; do ./test-typescript-compatibility.sh $version || exit 1;done;",
"test-server": "node --experimental-modules mock.mjs >/dev/null 2>&1 &",
"test-karma": "yarn test-server && karma start --single-run",
"test-phantom": "yarn test-server && karma start --single-run --browsers PhantomJS",
Expand Down
19 changes: 14 additions & 5 deletions src/waterfall/Waterfall.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Waterfall } from "./Waterfall";

describe("Waterfall", () => {
let ws: Waterfall;
let wsList: Waterfall[] = [];
before(async () => {
await expectEventually(() => supervisor.ws.readyState === WebSocket.OPEN,
"The supervisor failed to connect");
Expand All @@ -13,26 +14,33 @@ describe("Waterfall", () => {
if (ws) {
ws.close();
}
while (wsList.length) {
try {
wsList.pop().close();
} catch(e) {
// ignore
}
}
});
describe("constructor", () => {
it("should throw an error when not using the new operator", () => {
expect(() => (Waterfall as any)("")).to.throw(TypeError,
expect(() => ws = (Waterfall as any)("")).to.throw(TypeError,
"Failed to construct. Please use the 'new' operator");
});

it("should throw an error when using a bad url", () => {
INVALID_URLS.forEach((url) => {
expect(() => new Waterfall(url)).to.throw("Invalid url");
expect(() => wsList.push(new Waterfall(url))).to.throw("Invalid url");
});
});

it("should throw an error when using an undefined url", () => {
expect(() => new Waterfall(undefined)).to.throw("Invalid url");
expect(() => ws = new Waterfall(undefined)).to.throw("Invalid url");
});

it("should not throw when using a correct url", () => {
VALID_URLS.forEach((url) => {
expect(() => new Waterfall(url)).to.not.throw();
expect(() => wsList.push(new Waterfall(url))).to.not.throw();
});
});
it("should immediately connect to the server", async () => {
Expand Down Expand Up @@ -160,7 +168,6 @@ describe("Waterfall", () => {

it("should call the url generator when reconnecting", (done) => {
const firstTest = testCase;
ws.send("disconnect");
ws.addEventListener("connecting", async () => {
await sleep(100);
const secondTest = testCase;
Expand All @@ -172,6 +179,8 @@ describe("Waterfall", () => {
.to.deep.equal(["connect"]);
done();
});
ws.send("disconnect");

});
it("should avoid unnecessary close/open cycles", (done) => {
urlGeneratorCall = 0;
Expand Down
Loading

0 comments on commit abe54aa

Please sign in to comment.