Skip to content

Commit 141778f

Browse files
committed
test: convert socket event/messages to TypeScript
1 parent 117fcee commit 141778f

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

test/unit/compat/socket-events-test.js renamed to test/unit/compat/socket-events-test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
if (process.env.INCLUDE_COMPAT_TESTS) {
2-
const zmq = require("./load")
3-
const {assert} = require("chai")
4-
const {testProtos, uniqAddress} = require("../helpers")
1+
import * as zmq from "../../../v5-compat"
2+
import {assert} from "chai"
3+
import {testProtos, uniqAddress} from "../helpers"
54

5+
if (process.env.INCLUDE_COMPAT_TESTS) {
66
for (const proto of testProtos("tcp", "inproc")) {
77
describe(`compat socket with ${proto} events`, function () {
8-
it("should support events", function (done) {
8+
it("should support events", async function (done) {
99
const rep = zmq.socket("rep")
1010
const req = zmq.socket("req")
1111

12-
const address = uniqAddress(proto)
12+
const address = await uniqAddress(proto)
1313

1414
rep.on("message", function (msg) {
1515
assert.instanceOf(msg, Buffer)

test/unit/compat/socket-messages-test.js renamed to test/unit/compat/socket-messages-test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
if (process.env.INCLUDE_COMPAT_TESTS) {
2-
const zmq = require("./load")
3-
const {assert} = require("chai")
4-
const {testProtos, uniqAddress} = require("../helpers")
1+
import * as zmq from "../../../v5-compat"
2+
import {assert} from "chai"
3+
import {testProtos, uniqAddress} from "../helpers"
54

5+
if (process.env.INCLUDE_COMPAT_TESTS) {
66
for (const proto of testProtos("tcp", "inproc")) {
77
describe(`compat socket with ${proto} messages`, function () {
8-
let push
9-
let pull
8+
let push: zmq.Socket
9+
let pull: zmq.Socket
1010

1111
beforeEach(function () {
1212
push = zmq.socket("push")
1313
pull = zmq.socket("pull")
1414
})
1515

16-
it("should support messages", function (done) {
17-
const address = uniqAddress(proto)
16+
it("should support messages", async function (done) {
17+
const address = await uniqAddress(proto)
1818

1919
let n = 0
2020

@@ -43,8 +43,8 @@ if (process.env.INCLUDE_COMPAT_TESTS) {
4343
push.send(Buffer.from("buffer"))
4444
})
4545

46-
it("should support multipart messages", function (done) {
47-
const address = uniqAddress(proto)
46+
it("should support multipart messages", async function (done) {
47+
const address = await uniqAddress(proto)
4848

4949
pull.on("message", function (msg1, msg2, msg3) {
5050
assert.equal(msg1.toString(), "string")
@@ -60,8 +60,8 @@ if (process.env.INCLUDE_COMPAT_TESTS) {
6060
push.send(["string", 15.99, Buffer.from("buffer")])
6161
})
6262

63-
it("should support sndmore", function (done) {
64-
const address = uniqAddress(proto)
63+
it("should support sndmore", async function (done) {
64+
const address = await uniqAddress(proto)
6565

6666
pull.on("message", function (a, b, c, d, e) {
6767
assert.equal(a.toString(), "tobi")
@@ -82,8 +82,8 @@ if (process.env.INCLUDE_COMPAT_TESTS) {
8282
})
8383

8484
if (proto != "inproc") {
85-
it("should handle late connect", function (done) {
86-
const address = uniqAddress(proto)
85+
it("should handle late connect", async function (done) {
86+
const address = await uniqAddress(proto)
8787
let n = 0
8888

8989
pull.on("message", function (msg) {
@@ -115,8 +115,8 @@ if (process.env.INCLUDE_COMPAT_TESTS) {
115115
})
116116
}
117117

118-
it("should call send callbacks", function (done) {
119-
const address = uniqAddress(proto)
118+
it("should call send callbacks", async function (done) {
119+
const address = await uniqAddress(proto)
120120
let received = 0
121121
let callbacks = 0
122122

0 commit comments

Comments
 (0)