Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ node_modules

lib/

# Build artifacts
tsconfig.tsbuildinfo

# Local toy file
kernel.json

Expand Down
2 changes: 1 addition & 1 deletion __mocks__/jmp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EventEmitter } from "events";
import * as jmp from "jmp";
import * as jmp from "@runtimed/jmp";

class Socket extends EventEmitter {
throttle = false;
Expand Down
32 changes: 15 additions & 17 deletions __tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from "../src";

import { EventEmitter } from "events";
import { Socket as _Socket } from "jmp";
import { Socket as _Socket } from "@runtimed/jmp";
import * as zmq from "zeromq";

type Socket = typeof _Socket &
Expand All @@ -36,7 +36,7 @@ class HokeySocket extends _Socket {
}

describe("createSocket", () => {
test("creates a JMP socket on the channel with identity", async done => {
test("creates a JMP socket on the channel with identity", async () => {
const config = {
signature_scheme: "hmac-sha256",
key: "5ca1ab1e-c0da-aced-cafe-c0ffeefacade",
Expand All @@ -47,17 +47,21 @@ describe("createSocket", () => {
const identity = uuid();

const socket = await createSocket("iopub", identity, config);
expect(socket).not.toBeNull();
expect(socket.identity).toBe(identity);
expect(socket.type).toBe(ZMQType.frontend.iopub);
socket.close();

done();
try {
expect(socket).not.toBeNull();
expect(socket.identity).toBe(identity);
expect(socket.type).toBe(ZMQType.frontend.iopub);
} finally {
socket.close();
await new Promise(resolve => {
socket.on('close', resolve);
})
}
});
});

describe("verifiedConnect", () => {
test("verifiedConnect monitors the socket", async done => {
test("verifiedConnect monitors the socket", async () => {
const emitter = new EventEmitter();

const socket = {
Expand All @@ -84,11 +88,9 @@ describe("verifiedConnect", () => {

await p;
expect(socket.unmonitor).toHaveBeenCalledTimes(1);

done();
});

test("verifiedConnect monitors the socket properly even on fast connect", async done => {
test("verifiedConnect monitors the socket properly even on fast connect", () => {
const emitter = new EventEmitter();

const socket = {
Expand All @@ -108,7 +110,6 @@ describe("verifiedConnect", () => {
expect(socket.connect).toHaveBeenCalledTimes(1);
expect(socket.unmonitor).toHaveBeenCalledTimes(1);
expect(socket.connect).toHaveBeenCalledWith("tcp://127.0.0.1:8945");
done();
});
});

Expand Down Expand Up @@ -208,7 +209,7 @@ describe("createMainChannelFromSockets", () => {
});
});

test("propagates header information through", async done => {
test("propagates header information through", async () => {
const shellSocket = new HokeySocket();
const iopubSocket = new HokeySocket();
const sockets = {
Expand Down Expand Up @@ -249,7 +250,6 @@ describe("createMainChannelFromSockets", () => {
msg_type: "random" as MessageType,
date: new Date().toISOString(),
msg_id: "XYZ",

// NOTE: we'll be checking that we use the set username for the
// channels, no overrides
username: "kitty"
Expand Down Expand Up @@ -285,7 +285,5 @@ describe("createMainChannelFromSockets", () => {
{ channel: "shell", yolo: false },
{ channel: "iopub", yolo: true }
]);

done();
});
});
Loading