From 4d7b4388124713ef7c6e0ae6fd548b7eeacff1e8 Mon Sep 17 00:00:00 2001 From: Gnought <1684105+gnought@users.noreply.github.com> Date: Tue, 6 Apr 2021 22:42:18 +0800 Subject: [PATCH] chore: upgrade tap (#611) * Verify object type by t.type * Upgrade tap * replace deprecated tap functions * replace deprecated tap functions * disable check-coverage warning as an error * Add .taprc * Update package.json --- .taprc | 5 + package.json | 8 +- test/auth.js | 158 ++++++++++++++-------------- test/basic.js | 82 +++++++-------- test/client-pub-sub.js | 82 +++++++-------- test/close_socket_by_other_party.js | 6 +- test/connect.js | 46 ++++---- test/events.js | 12 +-- test/helper.js | 4 +- test/keep-alive.js | 8 +- test/meta.js | 38 +++---- test/not-blocking.js | 6 +- test/qos1.js | 98 ++++++++--------- test/qos2.js | 62 +++++------ test/regr-21.js | 2 +- test/retain.js | 74 ++++++------- test/topics.js | 30 +++--- test/will.js | 46 ++++---- 18 files changed, 386 insertions(+), 381 deletions(-) create mode 100644 .taprc diff --git a/.taprc b/.taprc new file mode 100644 index 00000000..6fe29f63 --- /dev/null +++ b/.taprc @@ -0,0 +1,5 @@ +ts: false +jsx: false +flow: false +coverage: true +strict: true \ No newline at end of file diff --git a/package.json b/package.json index 9d0ba384..a59b2daa 100644 --- a/package.json +++ b/package.json @@ -11,11 +11,11 @@ "lint:typescript": "eslint -c types/.eslintrc.json aedes.d.ts types/**/*.ts test/types/**/*.test-d.ts", "lint:markdown": "markdownlint docs/*.md README.md", "test": "npm run lint && npm run unit && npm run test:typescript", - "test:ci": "npm run lint && npm run unit -- --cov --coverage-report=lcovonly && npm run test:typescript", + "test:ci": "npm run lint && npm run unit -- --cov --no-check-coverage --coverage-report=lcovonly && npm run test:typescript", "test:report": "npm run lint && npm run unit:report && npm run test:typescript", "test:typescript": "tsd", - "unit": "tap --no-esm -J test/*.js", - "unit:report": "tap --no-esm -J test/*.js --cov --coverage-report=html --coverage-report=cobertura | tee out.tap", + "unit": "tap -J test/*.js", + "unit:report": "tap -J test/*.js --cov --coverage-report=html --coverage-report=cobertura | tee out.tap", "license-checker": "license-checker --production --onlyAllow=\"MIT;ISC;BSD-3-Clause;BSD-2-Clause\"", "release": "read -p 'GITHUB_TOKEN: ' GITHUB_TOKEN && export GITHUB_TOKEN=$GITHUB_TOKEN && release-it --disable-metrics" }, @@ -111,7 +111,7 @@ "release-it": "^14.4.1", "snazzy": "^9.0.0", "standard": "^16.0.3", - "tap": "^14.11.0", + "tap": "^15.0.2", "tsd": "^0.14.0", "typescript": "^4.2.3", "websocket-stream": "^5.5.2" diff --git a/test/auth.js b/test/auth.js index f5b0c4d8..999c07fb 100644 --- a/test/auth.js +++ b/test/auth.js @@ -11,12 +11,12 @@ test('authenticate successfully a client with username and password', function ( t.plan(4) const s = noError(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authenticate = function (client, username, password, cb) { - t.ok(client instanceof Client, 'client is there') + t.type(client, Client, 'client is there') t.equal(username, 'my username', 'username is there') - t.deepEqual(password, Buffer.from('my pass'), 'password is there') + t.same(password, Buffer.from('my pass'), 'password is there') cb(null, true) } @@ -32,7 +32,7 @@ test('authenticate successfully a client with username and password', function ( }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 0, length: 2, @@ -50,12 +50,12 @@ test('authenticate unsuccessfully a client with username and password', function t.plan(6) const s = setup() - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authenticate = function (client, username, password, cb) { - t.ok(client instanceof Client, 'client is there') + t.type(client, Client, 'client is there') t.equal(username, 'my username', 'username is there') - t.deepEqual(password, Buffer.from('my pass'), 'password is there') + t.same(password, Buffer.from('my pass'), 'password is there') cb(null, false) } @@ -68,7 +68,7 @@ test('authenticate unsuccessfully a client with username and password', function }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 5, length: 2, @@ -101,12 +101,12 @@ test('authenticate errors', function (t) { t.plan(7) const s = setup() - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authenticate = function (client, username, password, cb) { - t.ok(client instanceof Client, 'client is there') + t.type(client, Client, 'client is there') t.equal(username, 'my username', 'username is there') - t.deepEqual(password, Buffer.from('my pass'), 'password is there') + t.same(password, Buffer.from('my pass'), 'password is there') cb(new Error('this should happen!')) } @@ -120,7 +120,7 @@ test('authenticate errors', function (t) { }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 5, length: 2, @@ -153,12 +153,12 @@ test('authentication error when return code 1 (unacceptable protocol version) is t.plan(7) const s = setup() - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authenticate = function (client, username, password, cb) { - t.ok(client instanceof Client, 'client is there') + t.type(client, Client, 'client is there') t.equal(username, 'my username', 'username is there') - t.deepEqual(password, Buffer.from('my pass'), 'password is there') + t.same(password, Buffer.from('my pass'), 'password is there') const error = new Error('Auth error') error.returnCode = 1 cb(error, null) @@ -174,7 +174,7 @@ test('authentication error when return code 1 (unacceptable protocol version) is }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 5, length: 2, @@ -207,12 +207,12 @@ test('authentication error when return code 2 (identifier rejected) is passed', t.plan(7) const s = setup() - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authenticate = function (client, username, password, cb) { - t.ok(client instanceof Client, 'client is there') + t.type(client, Client, 'client is there') t.equal(username, 'my username', 'username is there') - t.deepEqual(password, Buffer.from('my pass'), 'password is there') + t.same(password, Buffer.from('my pass'), 'password is there') const error = new Error('Auth error') error.returnCode = 2 cb(error, null) @@ -228,7 +228,7 @@ test('authentication error when return code 2 (identifier rejected) is passed', }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 2, length: 2, @@ -261,12 +261,12 @@ test('authentication error when return code 3 (Server unavailable) is passed', f t.plan(7) const s = setup() - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authenticate = function (client, username, password, cb) { - t.ok(client instanceof Client, 'client is there') + t.type(client, Client, 'client is there') t.equal(username, 'my username', 'username is there') - t.deepEqual(password, Buffer.from('my pass'), 'password is there') + t.same(password, Buffer.from('my pass'), 'password is there') const error = new Error('Auth error') error.returnCode = 3 cb(error, null) @@ -282,7 +282,7 @@ test('authentication error when return code 3 (Server unavailable) is passed', f }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 3, length: 2, @@ -315,12 +315,12 @@ test('authentication error when return code 4 (bad user or password) is passed', t.plan(7) const s = setup() - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authenticate = function (client, username, password, cb) { - t.ok(client instanceof Client, 'client is there') + t.type(client, Client, 'client is there') t.equal(username, 'my username', 'username is there') - t.deepEqual(password, Buffer.from('my pass'), 'password is there') + t.same(password, Buffer.from('my pass'), 'password is there') const error = new Error('Auth error') error.returnCode = 4 cb(error, null) @@ -336,7 +336,7 @@ test('authentication error when return code 4 (bad user or password) is passed', }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 4, length: 2, @@ -369,12 +369,12 @@ test('authentication error when non numeric return code is passed', function (t) t.plan(7) const s = setup() - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authenticate = function (client, username, password, cb) { - t.ok(client instanceof Client, 'client is there') + t.type(client, Client, 'client is there') t.equal(username, 'my username', 'username is there') - t.deepEqual(password, Buffer.from('my pass'), 'password is there') + t.same(password, Buffer.from('my pass'), 'password is there') const error = new Error('Non numeric error codes') error.returnCode = 'return Code' cb(error, null) @@ -390,7 +390,7 @@ test('authentication error when non numeric return code is passed', function (t) }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 5, length: 2, @@ -423,7 +423,7 @@ test('authorize publish', function (t) { t.plan(4) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const expected = { cmd: 'publish', @@ -437,7 +437,7 @@ test('authorize publish', function (t) { s.broker.authorizePublish = function (client, packet, cb) { t.ok(client, 'client exists') - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') cb() } @@ -446,7 +446,7 @@ test('authorize publish', function (t) { expected.brokerId = s.broker.id expected.brokerCounter = s.broker.counter delete expected.length - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') cb() }) @@ -461,13 +461,13 @@ test('authorize waits for authenticate', function (t) { t.plan(6) const s = setup() - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authenticate = function (client, username, password, cb) { - t.ok(client instanceof Client, 'client is there') + t.type(client, Client, 'client is there') process.nextTick(function () { t.equal(username, 'my username', 'username is there') - t.deepEqual(password, Buffer.from('my pass'), 'password is there') + t.same(password, Buffer.from('my pass'), 'password is there') client.authenticated = true cb(null, true) }) @@ -493,7 +493,7 @@ test('authorize waits for authenticate', function (t) { expected.brokerId = s.broker.id expected.brokerCounter = s.broker.counter delete expected.length - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') cb() }) @@ -521,11 +521,11 @@ test('authorize publish from configOptions', function (t) { const s = connect(setup(aedes({ authorizePublish: function (client, packet, cb) { t.ok(client, 'client exists') - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') cb() } }))) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const expected = { cmd: 'publish', @@ -542,7 +542,7 @@ test('authorize publish from configOptions', function (t) { expected.brokerId = s.broker.id expected.brokerCounter = s.broker.counter delete expected.length - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') cb() }) @@ -557,7 +557,7 @@ test('do not authorize publish', function (t) { t.plan(3) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const expected = { cmd: 'publish', @@ -571,7 +571,7 @@ test('do not authorize publish', function (t) { s.broker.authorizePublish = function (client, packet, cb) { t.ok(client, 'client exists') - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') cb(new Error('auth negated')) } @@ -590,7 +590,7 @@ test('modify qos out of range in authorize publish ', function (t) { t.plan(2) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const expected = { cmd: 'publish', @@ -618,7 +618,7 @@ test('modify qos out of range in authorize publish ', function (t) { expected.brokerId = s.broker.id expected.brokerCounter = s.broker.counter delete expected.length - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') cb() }) @@ -638,11 +638,11 @@ test('authorize subscribe', function (t) { t.plan(5) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authorizeSubscribe = function (client, sub, cb) { t.ok(client, 'client exists') - t.deepEqual(sub, { + t.same(sub, { topic: 'hello', qos: 0 }, 'topic matches') @@ -656,10 +656,10 @@ test('authorize subscribe multiple same topics with same qos', function (t) { t.plan(4) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authorizeSubscribe = function (client, sub, cb) { - t.deepEqual(sub, { + t.same(sub, { topic: 'hello', qos: 0 }, 'topic matches') @@ -673,10 +673,10 @@ test('authorize subscribe multiple same topics with different qos', function (t) t.plan(4) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authorizeSubscribe = function (client, sub, cb) { - t.deepEqual(sub, { + t.same(sub, { topic: 'hello', qos: 1 }, 'topic matches') @@ -690,17 +690,17 @@ test('authorize subscribe multiple different topics', function (t) { t.plan(7) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authorizeSubscribe = function (client, sub, cb) { t.ok(client, 'client exists') if (sub.topic === 'hello') { - t.deepEqual(sub, { + t.same(sub, { topic: 'hello', qos: 0 }, 'topic matches') } else if (sub.topic === 'foo') { - t.deepEqual(sub, { + t.same(sub, { topic: 'foo', qos: 0 }, 'topic matches') @@ -717,14 +717,14 @@ test('authorize subscribe from config options', function (t) { const s = connect(setup(aedes({ authorizeSubscribe: function (client, sub, cb) { t.ok(client, 'client exists') - t.deepEqual(sub, { + t.same(sub, { topic: 'hello', qos: 0 }, 'topic matches') cb(null, sub) } }))) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) subscribe(t, s, 'hello', 0) }) @@ -733,11 +733,11 @@ test('negate subscription', function (t) { t.plan(5) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authorizeSubscribe = function (client, sub, cb) { t.ok(client, 'client exists') - t.deepEqual(sub, { + t.same(sub, { topic: 'hello', qos: 0 }, 'topic matches') @@ -755,7 +755,7 @@ test('negate subscription', function (t) { s.outStream.once('data', function (packet) { t.equal(packet.cmd, 'suback') - t.deepEqual(packet.granted, [128]) + t.same(packet.granted, [128]) t.equal(packet.messageId, 24) }) }) @@ -764,7 +764,7 @@ test('negate multiple subscriptions', function (t) { t.plan(5) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.authorizeSubscribe = function (client, sub, cb) { t.ok(client, 'client exists') @@ -785,7 +785,7 @@ test('negate multiple subscriptions', function (t) { s.outStream.once('data', function (packet) { t.equal(packet.cmd, 'suback') - t.deepEqual(packet.granted, [128, 128]) + t.same(packet.granted, [128, 128]) t.equal(packet.messageId, 24) }) }) @@ -802,7 +802,7 @@ test('negate subscription with correct persistence', function (t) { }] const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.authorizeSubscribe = function (client, sub, cb) { t.ok(client, 'client exists') @@ -815,9 +815,9 @@ test('negate subscription with correct persistence', function (t) { const s = connect(setup(broker), { clean: false, clientId: 'abcde' }) s.outStream.once('data', function (packet) { t.equal(packet.cmd, 'suback') - t.deepEqual(packet.granted, [128, 0]) + t.same(packet.granted, [128, 0]) broker.persistence.subscriptionsByClient(broker.clients.abcde, function (_, subs, client) { - t.deepEqual(subs, expected) + t.same(subs, expected) }) t.equal(packet.messageId, 24) }) @@ -840,7 +840,7 @@ test('negate multiple subscriptions random times', function (t) { const clock = Faketimers.createClock() const s = connect(setup()) - t.tearDown(function () { + t.teardown(function () { clock.reset() s.broker.close() }) @@ -871,7 +871,7 @@ test('negate multiple subscriptions random times', function (t) { s.outStream.once('data', function (packet) { t.equal(packet.cmd, 'suback') - t.deepEqual(packet.granted, [0, 128]) + t.same(packet.granted, [0, 128]) t.equal(packet.messageId, 24) }) }) @@ -880,7 +880,7 @@ test('failed authentication does not disconnect other client with same clientId' t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) const s0 = setup(broker) @@ -901,7 +901,7 @@ test('failed authentication does not disconnect other client with same clientId' }) s0.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 0, length: 2, @@ -930,7 +930,7 @@ test('failed authentication does not disconnect other client with same clientId' }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 5, length: 2, @@ -963,7 +963,7 @@ test('unauthorized connection should not unregister the correct one with same cl } } }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('clientError', function (client, err) { t.equal(err.message, 'bad user name or password') @@ -991,16 +991,16 @@ test('set authentication method in config options', function (t) { const s = setup(aedes({ authenticate: function (client, username, password, cb) { - t.ok(client instanceof Client, 'client is there') + t.type(client, Client, 'client is there') t.equal(username, 'my username', 'username is there') - t.deepEqual(password, Buffer.from('my pass'), 'password is there') + t.same(password, Buffer.from('my pass'), 'password is there') cb(null, false) } })) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 5, length: 2, @@ -1039,7 +1039,7 @@ test('change a topic name inside authorizeForward method in QoS 1 mode', functio return packet } }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const expected = { cmd: 'publish', @@ -1072,7 +1072,7 @@ test('change a topic name inside authorizeForward method in QoS 1 mode', functio const s = connect(setup(broker)) s.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') }) }) @@ -1085,7 +1085,7 @@ test('change a topic name inside authorizeForward method in QoS 1 mode', functio return null } }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('client', function (client) { client.subscribe({ @@ -1120,7 +1120,7 @@ test('prevent publish in QoS 0 mode', function (t) { return null } }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('client', function (client) { client.subscribe({ diff --git a/test/basic.js b/test/basic.js index 39f57358..0807c483 100644 --- a/test/basic.js +++ b/test/basic.js @@ -10,7 +10,7 @@ test('test aedes.Server', function (t) { t.plan(1) const broker = new aedes.Server() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) connect(setup(broker), {}, function () { t.pass('connected') @@ -21,7 +21,7 @@ test('publish QoS 0', function (t) { t.plan(2) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const expected = { cmd: 'publish', @@ -36,7 +36,7 @@ test('publish QoS 0', function (t) { expected.brokerId = s.broker.id expected.brokerCounter = s.broker.counter t.equal(packet.messageId, undefined, 'MUST not contain a packet identifier in QoS 0') - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') cb() }) @@ -51,7 +51,7 @@ test('messageId shoud reset to 1 if it reached 65535', function (t) { t.plan(7) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const publishPacket = { cmd: 'publish', @@ -82,7 +82,7 @@ test('publish empty topic throws error', function (t) { t.plan(1) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.inStream.write({ cmd: 'publish', @@ -100,7 +100,7 @@ test('publish empty topic throws error', function (t) { t.plan(5) const s = connect(setup(), { clean: ele.clean }) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const expected = { cmd: 'publish', @@ -115,11 +115,11 @@ test('publish empty topic throws error', function (t) { subscribe(t, s, 'hello', ele.qos, function () { s.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') }) s.broker.persistence.subscriptionsByClient(s.client, function (_, subs) { - t.deepEqual(subs, expectedSubs) + t.same(subs, expectedSubs) }) s.broker.publish({ @@ -160,7 +160,7 @@ test('return write errors to callback', function (t) { t.plan(5) const s = connect(setup(), { clean: ele.clean }) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const expected = { cmd: 'publish', @@ -176,11 +176,11 @@ test('return write errors to callback', function (t) { subscribeMultiple(t, s, subs, [ele.qos, ele.qos], function () { s.outStream.on('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') }) s.broker.persistence.subscriptionsByClient(s.client, function (_, saveSubs) { - t.deepEqual(saveSubs, expectedSubs) + t.same(saveSubs, expectedSubs) }) s.broker.publish({ @@ -196,7 +196,7 @@ test('does not die badly on connection error', function (t) { t.plan(3) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.inStream.write({ cmd: 'subscribe', @@ -229,7 +229,7 @@ test('subscribe should have messageId', function (t) { t.plan(1) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.inStream.write({ cmd: 'subscribe', @@ -247,7 +247,7 @@ test('unsubscribe', function (t) { t.plan(5) const s = noError(connect(setup()), t) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) subscribe(t, s, 'hello', 0, function () { s.inStream.write({ @@ -257,7 +257,7 @@ test('unsubscribe', function (t) { }) s.outStream.once('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'unsuback', messageId: 43, dup: false, @@ -285,7 +285,7 @@ test('unsubscribe without subscribe', function (t) { t.plan(1) const s = noError(connect(setup()), t) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.inStream.write({ cmd: 'unsubscribe', @@ -294,7 +294,7 @@ test('unsubscribe without subscribe', function (t) { }) s.outStream.once('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'unsuback', messageId: 43, dup: false, @@ -310,7 +310,7 @@ test('unsubscribe on disconnect for a clean=true client', function (t) { const opts = { clean: true } const s = connect(setup(), opts) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) subscribe(t, s, 'hello', 0, function () { s.conn.destroy(null, function () { @@ -337,7 +337,7 @@ test('unsubscribe on disconnect for a clean=false client', function (t) { const opts = { clean: false } const s = connect(setup(), opts) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) subscribe(t, s, 'hello', 0, function () { s.conn.destroy(null, function () { @@ -363,7 +363,7 @@ test('disconnect', function (t) { t.plan(1) const s = noError(connect(setup()), t) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.on('clientDisconnect', function () { t.pass('closed stream') @@ -378,7 +378,7 @@ test('disconnect client on wrong cmd', function (t) { t.plan(1) const s = noError(connect(setup()), t) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.on('clientDisconnect', function () { t.pass('closed stream') @@ -452,7 +452,7 @@ test('testing other event', function (t) { t.plan(1) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const client = setup(broker) @@ -466,7 +466,7 @@ test('connect without a clientId for MQTT 3.1.1', function (t) { t.plan(1) const s = setup() - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.inStream.write({ cmd: 'connect', @@ -477,7 +477,7 @@ test('connect without a clientId for MQTT 3.1.1', function (t) { }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 0, length: 2, @@ -495,7 +495,7 @@ test('disconnect existing client with the same clientId', function (t) { t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const c1 = connect(setup(broker), { clientId: 'abcde' @@ -516,7 +516,7 @@ test('disconnect if another broker connects the same clientId', function (t) { t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const c1 = connect(setup(broker), { clientId: 'abcde' @@ -538,7 +538,7 @@ test('publish to $SYS/broker/new/clients', function (t) { t.plan(1) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.mq.on('$SYS/' + broker.id + '/new/clients', function (packet, done) { t.equal(packet.payload.toString(), 'abcde', 'clientId matches') @@ -553,7 +553,7 @@ test('publish to $SYS/broker/new/clients', function (t) { test('publish to $SYS/broker/new/subsribers and $SYS/broker/new/unsubsribers', function (t) { t.plan(7) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const sub = { topic: 'hello', @@ -563,14 +563,14 @@ test('publish to $SYS/broker/new/subsribers and $SYS/broker/new/unsubsribers', f broker.mq.on('$SYS/' + broker.id + '/new/subscribes', function (packet, done) { const payload = JSON.parse(packet.payload.toString()) t.equal(payload.clientId, 'abcde', 'clientId matches') - t.deepEqual(payload.subs, [sub], 'subscriptions matches') + t.same(payload.subs, [sub], 'subscriptions matches') done() }) broker.mq.on('$SYS/' + broker.id + '/new/unsubscribes', function (packet, done) { const payload = JSON.parse(packet.payload.toString()) t.equal(payload.clientId, 'abcde', 'clientId matches') - t.deepEqual(payload.subs, [sub.topic], 'unsubscriptions matches') + t.same(payload.subs, [sub.topic], 'unsubscriptions matches') done() }) @@ -591,7 +591,7 @@ test('restore QoS 0 subscriptions not clean', function (t) { t.plan(5) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const expected = { cmd: 'publish', @@ -621,7 +621,7 @@ test('restore QoS 0 subscriptions not clean', function (t) { }) }) subscriber.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) @@ -632,7 +632,7 @@ test('do not restore QoS 0 subscriptions when clean', function (t) { t.plan(5) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) let subscriber = connect(setup(broker), { clean: true, clientId: 'abcde' @@ -680,7 +680,7 @@ test('double sub does not double deliver', function (t) { subscribe(t, s, 'hello', 0, function () { subscribe(t, s, 'hello', 0, function () { s.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') s.outStream.on('data', function () { t.fail('double deliver') }) @@ -694,7 +694,7 @@ test('double sub does not double deliver', function (t) { }) }) }) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) }) test('overlapping sub does not double deliver', function (t) { @@ -714,7 +714,7 @@ test('overlapping sub does not double deliver', function (t) { subscribe(t, s, 'hello', 0, function () { subscribe(t, s, 'hello/#', 0, function () { s.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') s.outStream.on('data', function () { t.fail('double deliver') }) @@ -728,7 +728,7 @@ test('overlapping sub does not double deliver', function (t) { }) }) }) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) }) test('clear drain', function (t) { @@ -754,7 +754,7 @@ test('clear drain', function (t) { }) }) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) }) test('id option', function (t) { @@ -769,7 +769,7 @@ test('id option', function (t) { setup(broker2).conn.destroy() t.equal(broker2.id, 'abc', 'broker id equals id option when set') - t.tearDown(() => { + t.teardown(() => { broker1.close() broker2.close() }) @@ -779,7 +779,7 @@ test('not duplicate client close when client error occurs', function (t) { t.plan(1) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) connect(setup(broker)) broker.on('client', function (client) { @@ -798,7 +798,7 @@ test('not duplicate client close when double close() called', function (t) { t.plan(1) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) connect(setup(broker)) broker.on('clientReady', function (client) { diff --git a/test/client-pub-sub.js b/test/client-pub-sub.js index 50517c0c..127ccd2b 100644 --- a/test/client-pub-sub.js +++ b/test/client-pub-sub.js @@ -8,7 +8,7 @@ test('publish direct to a single client QoS 0', function (t) { t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const expected = { cmd: 'publish', @@ -33,7 +33,7 @@ test('publish direct to a single client QoS 0', function (t) { const s = connect(setup(broker)) s.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') }) }) @@ -41,7 +41,7 @@ test('publish direct to a single client throws error', function (t) { t.plan(1) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.persistence.outgoingEnqueue = function (sub, packet, done) { done(new Error('Throws error')) @@ -65,7 +65,7 @@ test('publish direct to a single client throws error 2', function (t) { t.plan(1) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.persistence.outgoingUpdate = function (client, packet, done) { done(new Error('Throws error'), client, packet) @@ -91,7 +91,7 @@ test('publish direct to a single client QoS 1', function (t) { t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const expected = { cmd: 'publish', @@ -117,7 +117,7 @@ test('publish direct to a single client QoS 1', function (t) { s.outStream.once('data', function (packet) { expected.messageId = packet.messageId - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') s.inStream.write({ cmd: 'puback', messageId: packet.messageId @@ -129,7 +129,7 @@ test('publish QoS 2 throws error in pubrel', function (t) { t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = connect(setup(broker)) @@ -164,7 +164,7 @@ test('publish direct to a single client QoS 2', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) let publishCount = 0 let nonPublishCount = 0 @@ -211,7 +211,7 @@ test('emit a `ack` event on PUBACK for QoS 1 [clean=false]', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const expected = { cmd: 'publish', @@ -236,7 +236,7 @@ test('emit a `ack` event on PUBACK for QoS 1 [clean=false]', function (t) { expected.brokerId = packet.brokerId expected.brokerCounter = packet.brokerCounter expected.messageId = packet.messageId - t.deepEqual(packet, expected, 'ack packet is origianl packet') + t.same(packet, expected, 'ack packet is origianl packet') t.pass('got the ack event') }) @@ -254,7 +254,7 @@ test('emit a `ack` event on PUBACK for QoS 1 [clean=true]', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('clientReady', function (client) { client.publish({ @@ -285,7 +285,7 @@ test('emit a `ack` event on PUBCOMP for QoS 2 [clean=false]', function (t) { t.plan(5) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) let messageId let clientId @@ -330,7 +330,7 @@ test('emit a `ack` event on PUBCOMP for QoS 2 [clean=true]', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('clientReady', function (client) { client.publish({ @@ -368,7 +368,7 @@ test('offline message support for direct publish', function (t) { t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const expected = { cmd: 'publish', @@ -406,7 +406,7 @@ test('offline message support for direct publish', function (t) { messageId: packet.messageId }) delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) @@ -415,7 +415,7 @@ test('subscribe a client programmatically', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const expected = { cmd: 'publish', @@ -447,7 +447,7 @@ test('subscribe a client programmatically', function (t) { const s = connect(setup(broker)) s.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') }) }) @@ -455,7 +455,7 @@ test('subscribe a client programmatically clears retain', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const expected = { cmd: 'publish', @@ -488,7 +488,7 @@ test('subscribe a client programmatically clears retain', function (t) { const s = connect(setup(broker)) s.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') }) }) @@ -496,7 +496,7 @@ test('subscribe a bridge programmatically keeps retain', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const expected = { cmd: 'publish', @@ -530,7 +530,7 @@ test('subscribe a bridge programmatically keeps retain', function (t) { const s = connect(setup(broker)) s.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') }) }) @@ -538,7 +538,7 @@ test('subscribe throws error when QoS > 0', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('clientReady', function (client) { client.subscribe({ @@ -572,7 +572,7 @@ test('subscribe a client programmatically - wildcard', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const expected = { cmd: 'publish', @@ -604,7 +604,7 @@ test('subscribe a client programmatically - wildcard', function (t) { const s = connect(setup(broker)) s.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') }) }) @@ -612,7 +612,7 @@ test('unsubscribe a client', function (t) { t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('client', function (client) { client.subscribe({ @@ -635,7 +635,7 @@ test('unsubscribe should not call removeSubscriptions when [clean=true]', functi t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.persistence.removeSubscriptions = function (client, subs, cb) { cb(Error('remove subscription is called')) @@ -665,7 +665,7 @@ test('unsubscribe throws error', function (t) { t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('client', function (client) { client.subscribe({ @@ -691,7 +691,7 @@ test('unsubscribe throws error 2', function (t) { t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('client', function (client) { client.subscribe({ @@ -720,7 +720,7 @@ test('subscribe a client programmatically multiple topics', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const expected = { cmd: 'publish', @@ -755,7 +755,7 @@ test('subscribe a client programmatically multiple topics', function (t) { const s = connect(setup(broker)) s.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') }) }) @@ -763,7 +763,7 @@ test('subscribe a client programmatically with full packet', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const expected = { cmd: 'publish', @@ -800,7 +800,7 @@ test('subscribe a client programmatically with full packet', function (t) { const s = connect(setup(broker)) s.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') }) }) @@ -809,7 +809,7 @@ test('get message when client connects', function (t) { const client1 = 'gav' const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('client', function (client) { client.subscribe({ @@ -835,7 +835,7 @@ test('get message when client disconnects', function (t) { const client1 = 'gav' const client2 = 'friend' const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('client', function (client) { if (client.id === client1) { @@ -864,7 +864,7 @@ test('should not receive a message on negated subscription', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.authorizeSubscribe = function (client, sub, callback) { callback(null, null) @@ -906,7 +906,7 @@ test('programmatically add custom subscribe', function (t) { t.plan(6) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = connect(setup(broker)) const expected = { @@ -931,7 +931,7 @@ test('programmatically add custom subscribe', function (t) { t.pass('subscribed') }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') }) s.inStream.write({ cmd: 'publish', @@ -944,7 +944,7 @@ test('programmatically add custom subscribe', function (t) { function deliver (packet, cb) { deliverP.brokerId = s.broker.id deliverP.brokerCounter = s.broker.counter - t.deepEqual(packet, deliverP, 'packet matches') + t.same(packet, deliverP, 'packet matches') cb() } }) @@ -953,7 +953,7 @@ test('custom function in broker.subscribe', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) const expected = { @@ -986,7 +986,7 @@ test('custom function in broker.subscribe', function (t) { function deliver (packet, cb) { expected.brokerId = s.broker.id expected.brokerCounter = s.broker.counter - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') cb() } }) @@ -995,7 +995,7 @@ test('custom function in broker.unsubscribe', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = noError(setup(broker)) connect(s, {}, function () { diff --git a/test/close_socket_by_other_party.js b/test/close_socket_by_other_party.js index c73ade95..18aa18c1 100644 --- a/test/close_socket_by_other_party.js +++ b/test/close_socket_by_other_party.js @@ -48,7 +48,7 @@ test('client is closed before authenticate returns', function (t) { }, 2000) } }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('client', function (client) { t.fail('should no client registration') @@ -111,7 +111,7 @@ test('close client when its socket is closed', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const subscriber = connect(setup(broker)) @@ -131,7 +131,7 @@ test('multiple clients subscribe same topic, and all clients still receive messa let client2 - t.tearDown(() => { + t.teardown(() => { client2.end() broker.close() server.close() diff --git a/test/connect.js b/test/connect.js index d4bc5e0d..24c48a7a 100644 --- a/test/connect.js +++ b/test/connect.js @@ -12,7 +12,7 @@ const aedes = require('../') t.plan(2) const s = setup() - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.inStream.write({ cmd: 'connect', @@ -24,7 +24,7 @@ const aedes = require('../') }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 0, length: 2, @@ -45,7 +45,7 @@ test('reject client requested for unacceptable protocol version', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -75,7 +75,7 @@ test('reject client requested for unsupported protocol version', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -102,7 +102,7 @@ test('reject clients with no clientId running on MQTT 3.1.0', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -128,7 +128,7 @@ test('reject clients without clientid and clean=false on MQTT 3.1.1', function ( t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -153,7 +153,7 @@ test('clients without clientid and clean=true on MQTT 3.1.1 will get a generated t.plan(5) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -182,7 +182,7 @@ test('client connect error while fetching subscriptions', function (t) { t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -212,7 +212,7 @@ test('client connect clear outgoing', function (t) { const brokerId = 'pippo' const broker = aedes({ id: brokerId }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const subs = [{ clientId: clientId }] const packet = { @@ -251,7 +251,7 @@ test('clients with zero-byte clientid and clean=true on MQTT 3.1.1 will get a ge t.plan(5) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -282,7 +282,7 @@ test('reject clients with > 23 clientId length in MQTT 3.1.0', function (t) { t.plan(7) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -323,7 +323,7 @@ test('connect clients with > 23 clientId length using aedes maxClientsIdLength o t.plan(4) const broker = aedes({ maxClientsIdLength: 26 }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -350,7 +350,7 @@ test('connect with > 23 clientId length in MQTT 3.1.1', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -378,7 +378,7 @@ test('the first Packet MUST be a CONNECT Packet', function (t) { t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const packet = { cmd: 'publish', @@ -404,7 +404,7 @@ test('second CONNECT Packet sent from a Client as a protocol violation and disco t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const packet = { cmd: 'connect', @@ -438,7 +438,7 @@ test('connect handler calls done when preConnect throws error', function (t) { } }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -454,7 +454,7 @@ test('handler calls done when disconnect or unknown packet cmd is received', fun const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -498,7 +498,7 @@ test('reject second CONNECT Packet sent while first CONNECT still in preConnect }, ms) } }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -526,7 +526,7 @@ test('reject clients with wrong protocol name', function (t) { t.plan(2) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -552,7 +552,7 @@ test('After first CONNECT Packet, others are queued until \'connect\' event', fu const queueLimit = 50 const broker = aedes({ queueLimit }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publishP = { cmd: 'publish', @@ -595,7 +595,7 @@ test('Test queue limit', function (t) { const queueLimit = 50 const broker = aedes({ queueLimit }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publishP = { cmd: 'publish', @@ -645,7 +645,7 @@ test('Test queue limit', function (t) { return done(err, ok) } }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = setup(broker) @@ -720,7 +720,7 @@ test('websocket clients have access to the request object', function (t) { } }) - t.tearDown(() => { + t.teardown(() => { client.end(true) broker.close() server.close() diff --git a/test/events.js b/test/events.js index ef4b923f..bd8c3e26 100644 --- a/test/events.js +++ b/test/events.js @@ -10,12 +10,12 @@ test('publishes an hearbeat', function (t) { const broker = aedes({ heartbeatInterval: 10 // ms }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.subscribe('$SYS/+/heartbeat', function (message, cb) { const id = message.topic.match(/\$SYS\/([^/]+)\/heartbeat/)[1] t.equal(id, broker.id, 'broker id matches') - t.deepEqual(message.payload.toString(), id, 'message has id as the payload') + t.same(message.payload.toString(), id, 'message has id as the payload') }) }) @@ -24,7 +24,7 @@ test('publishes an hearbeat', function (t) { t.plan(4) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) subscribe(t, s, '#', 0, function () { s.outStream.once('data', function (packet) { @@ -45,7 +45,7 @@ test('publishes an hearbeat', function (t) { t.plan(4) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) subscribe(t, s, '+/#', 0, function () { s.outStream.once('data', function (packet) { @@ -67,7 +67,7 @@ test('does not store $SYS topics to QoS 1 # subscription', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const opts = { clean: false, clientId: 'abcde' } let s = connect(setup(broker), opts) @@ -94,7 +94,7 @@ test('Emit event when receives a ping', { timeout: 2000 }, function (t) { t.plan(5) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('ping', function (packet, client) { if (client && client) { diff --git a/test/helper.js b/test/helper.js index 5928ee63..eca73738 100644 --- a/test/helper.js +++ b/test/helper.js @@ -81,7 +81,7 @@ function subscribe (t, subscriber, topic, qos, done) { subscriber.outStream.once('data', function (packet) { t.equal(packet.cmd, 'suback') - t.deepEqual(packet.granted, [qos]) + t.same(packet.granted, [qos]) t.equal(packet.messageId, 24) if (done) { @@ -100,7 +100,7 @@ function subscribeMultiple (t, subscriber, subs, expectedGranted, done) { subscriber.outStream.once('data', function (packet) { t.equal(packet.cmd, 'suback') - t.deepEqual(packet.granted, expectedGranted) + t.same(packet.granted, expectedGranted) t.equal(packet.messageId, 24) if (done) { diff --git a/test/keep-alive.js b/test/keep-alive.js index 3fed3677..ac641905 100644 --- a/test/keep-alive.js +++ b/test/keep-alive.js @@ -10,7 +10,7 @@ test('supports pingreq/pingresp', function (t) { t.plan(1) const s = noError(connect(setup())) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.on('keepaliveTimeout', function (client) { t.fail('keep alive should not timeout') @@ -30,7 +30,7 @@ test('supports keep alive disconnections', function (t) { const clock = Faketimers.install() const s = connect(setup(), { keepalive: 1 }) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.on('keepaliveTimeout', function (client) { t.pass('keep alive timeout') @@ -50,7 +50,7 @@ test('supports keep alive disconnections after a pingreq', function (t) { const clock = Faketimers.install() const s = connect(setup(), { keepalive: 1 }) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) eos(s.conn, function () { t.pass('waits 1 and a half the keepalive timeout') @@ -77,7 +77,7 @@ test('disconnect if a connect does not arrive in time', function (t) { const s = setup(aedes({ connectTimeout: 500 })) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.client.on('error', function (err) { t.equal(err.message, 'connect did not arrive in time') diff --git a/test/meta.js b/test/meta.js index b822ed45..5035128a 100644 --- a/test/meta.js +++ b/test/meta.js @@ -8,7 +8,7 @@ test('count connected clients', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) t.equal(broker.connectedClients, 0, 'no connected clients') @@ -35,7 +35,7 @@ test('call published method', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.published = function (packet, client, done) { t.equal(packet.topic, 'hello', 'topic matches') @@ -56,7 +56,7 @@ test('call published method with client', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.published = function (packet, client, done) { // for internal messages, client will be null @@ -84,7 +84,7 @@ test('emit publish event with client - QoS 0', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('publish', function (packet, client) { // for internal messages, client will be null @@ -109,7 +109,7 @@ test('emit publish event with client - QoS 1', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('publish', function (packet, client) { // for internal messages, client will be null @@ -136,12 +136,12 @@ test('emit subscribe event', function (t) { t.plan(6) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = connect(setup(broker), { clientId: 'abcde' }) broker.on('subscribe', function (subscriptions, client) { - t.deepEqual(subscriptions, [{ + t.same(subscriptions, [{ topic: 'hello', qos: 0 }], 'topic matches') @@ -157,14 +157,14 @@ test('emit subscribe event if unrecognized params in subscribe packet structure' t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = noError(connect(setup(broker))) const subs = [{ topic: 'hello', qos: 0 }] broker.on('subscribe', function (subscriptions, client) { t.equal(subscriptions, subs) - t.deepEqual(client, s.client) + t.same(client, s.client) }) s.client.subscribe({ @@ -179,12 +179,12 @@ test('emit unsubscribe event', function (t) { t.plan(6) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = connect(setup(broker), { clean: true, clientId: 'abcde' }) broker.on('unsubscribe', function (unsubscriptions, client) { - t.deepEqual(unsubscriptions, [ + t.same(unsubscriptions, [ 'hello' ], 'unsubscription matches') t.equal(client.id, 'abcde', 'client matches') @@ -207,14 +207,14 @@ test('emit unsubscribe event if unrecognized params in unsubscribe packet struct t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = noError(connect(setup(broker))) const unsubs = [{ topic: 'hello', qos: 0 }] broker.on('unsubscribe', function (unsubscriptions, client) { t.equal(unsubscriptions, unsubs) - t.deepEqual(client, s.client) + t.same(client, s.client) }) s.client.unsubscribe({ @@ -229,7 +229,7 @@ test('dont emit unsubscribe event on client close', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = noError(connect(setup(broker), { clientId: 'abcde' }), t) @@ -251,7 +251,7 @@ test('emit clientDisconnect event', function (t) { t.plan(1) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('clientDisconnect', function (client) { t.equal(client.id, 'abcde', 'client matches') @@ -269,7 +269,7 @@ test('emits client', function (t) { t.plan(1) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('client', function (client) { t.equal(client.id, 'abcde', 'clientId matches') @@ -284,7 +284,7 @@ test('get aedes version', function (t) { t.plan(1) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) t.equal(broker.version, require('../package.json').version) }) @@ -293,7 +293,7 @@ test('connect and connackSent event', { timeout: 50 }, function (t) { t.plan(3) const s = setup() - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const clientId = 'my-client' @@ -312,7 +312,7 @@ test('connect and connackSent event', { timeout: 50 }, function (t) { }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'connack', returnCode: 0, length: 2, diff --git a/test/not-blocking.js b/test/not-blocking.js index 7d428c89..a1ebd83a 100644 --- a/test/not-blocking.js +++ b/test/not-blocking.js @@ -19,7 +19,7 @@ test('connect 500 concurrent clients', function (t) { t.error(err, 'no error') const clock = Faketimers.createClock() - t.tearDown(clock.reset.bind(clock)) + t.teardown(clock.reset.bind(clock)) const port = server.address().port @@ -72,7 +72,7 @@ test('do not block after a subscription', function (t) { t.error(err, 'no error') const clock = Faketimers.createClock() - t.tearDown(clock.reset.bind(clock)) + t.teardown(clock.reset.bind(clock)) const clockId = clock.setTimeout(finish, total) @@ -156,7 +156,7 @@ test('do not block with overlapping subscription', function (t) { t.error(err, 'no error') const clock = Faketimers.createClock() - t.tearDown(clock.reset.bind(clock)) + t.teardown(clock.reset.bind(clock)) const clockId = clock.setTimeout(finish, total) diff --git a/test/qos1.js b/test/qos1.js index baac1dce..acf365e6 100644 --- a/test/qos1.js +++ b/test/qos1.js @@ -9,7 +9,7 @@ test('publish QoS 1', function (t) { t.plan(1) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const expected = { cmd: 'puback', @@ -29,7 +29,7 @@ test('publish QoS 1', function (t) { }) s.outStream.on('data', function (packet) { - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) @@ -37,7 +37,7 @@ test('publish QoS 1 throws error', function (t) { t.plan(1) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.persistence.subscriptionsByTopic = function (packet, done) { return done(new Error('Throws error')) @@ -60,7 +60,7 @@ test('publish QoS 1 throws error on write', function (t) { t.plan(1) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.on('client', function (client) { client.connected = false @@ -84,7 +84,7 @@ test('publish QoS 1 and check offline queue', function (t) { t.plan(13) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker), { clean: false }) const subscriberClient = { @@ -118,16 +118,16 @@ test('publish QoS 1 and check offline queue', function (t) { const queue = [] subscribe(t, subscriber, 'hello', 1, function () { publisher.outStream.on('data', function (packet) { - t.deepEqual(packet, expectedAck, 'ack packet must patch') + t.same(packet, expectedAck, 'ack packet must patch') }) subscriber.outStream.on('data', function (packet) { queue.push(packet) delete packet.payload delete packet.length - t.notEqual(packet.messageId, undefined, 'messageId is assigned a value') - t.notEqual(packet.messageId, 10, 'messageId should be unique') + t.not(packet.messageId, undefined, 'messageId is assigned a value') + t.not(packet.messageId, 10, 'messageId should be unique') expected.messageId = packet.messageId - t.deepEqual(packet, expected, 'publish packet must patch') + t.same(packet, expected, 'publish packet must patch') if (queue.length === 2) { setImmediate(() => { for (let i = 0; i < queue.length; i++) { @@ -139,7 +139,7 @@ test('publish QoS 1 and check offline queue', function (t) { delete origPacket.messageId delete sent.payload delete sent.messageId - t.deepEqual(origPacket, sent, 'origPacket must match') + t.same(origPacket, sent, 'origPacket must match') } }) } @@ -156,7 +156,7 @@ test('publish QoS 1 and empty offline queue', function (t) { t.plan(13) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker), { clean: false }) const subscriberClient = { @@ -190,16 +190,16 @@ test('publish QoS 1 and empty offline queue', function (t) { const queue = [] subscribe(t, subscriber, 'hello', 1, function () { publisher.outStream.on('data', function (packet) { - t.deepEqual(packet, expectedAck, 'ack packet must patch') + t.same(packet, expectedAck, 'ack packet must patch') }) subscriber.outStream.on('data', function (packet) { queue.push(packet) delete packet.payload delete packet.length - t.notEqual(packet.messageId, undefined, 'messageId is assigned a value') - t.notEqual(packet.messageId, 10, 'messageId should be unique') + t.not(packet.messageId, undefined, 'messageId is assigned a value') + t.not(packet.messageId, 10, 'messageId should be unique') expected.messageId = packet.messageId - t.deepEqual(packet, expected, 'publish packet must patch') + t.same(packet, expected, 'publish packet must patch') if (queue.length === 2) { setImmediate(() => { broker.clients[subscriberClient.id].emptyOutgoingQueue(function () { @@ -222,7 +222,7 @@ test('subscribe QoS 1', function (t) { t.plan(5) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker)) const subscriber = connect(setup(broker)) @@ -242,9 +242,9 @@ test('subscribe QoS 1', function (t) { cmd: 'puback', messageId: packet.messageId }) - t.notEqual(packet.messageId, 42, 'messageId must differ') + t.not(packet.messageId, 42, 'messageId must differ') delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) publisher.inStream.write({ @@ -261,7 +261,7 @@ test('subscribe QoS 0, but publish QoS 1', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker)) const subscriber = connect(setup(broker)) @@ -277,7 +277,7 @@ test('subscribe QoS 0, but publish QoS 1', function (t) { subscribe(t, subscriber, 'hello', 0, function () { subscriber.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) publisher.inStream.write({ @@ -294,7 +294,7 @@ test('restore QoS 1 subscriptions not clean', function (t) { t.plan(7) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) let subscriber = connect(setup(broker), { clean: false, clientId: 'abcde' }) const expected = { @@ -332,9 +332,9 @@ test('restore QoS 1 subscriptions not clean', function (t) { cmd: 'puback', messageId: packet.messageId }) - t.notEqual(packet.messageId, 42, 'messageId must differ') + t.not(packet.messageId, 42, 'messageId must differ') delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) @@ -343,7 +343,7 @@ test('restore multiple QoS 1 subscriptions not clean w/ authorizeSubscribe', fun t.plan(11) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) let subscriber = connect(setup(broker), { clean: false, clientId: 'abcde' }) const expected = { @@ -389,9 +389,9 @@ test('restore multiple QoS 1 subscriptions not clean w/ authorizeSubscribe', fun cmd: 'puback', messageId: packet.messageId }) - t.notEqual(packet.messageId, 48, 'messageId must differ') + t.not(packet.messageId, 48, 'messageId must differ') delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) @@ -401,7 +401,7 @@ test('remove stored subscriptions if connected with clean=true', function (t) { t.plan(5) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) let subscriber = connect(setup(broker), { clean: false, clientId: 'abcde' }) @@ -448,7 +448,7 @@ test('resend publish on non-clean reconnect QoS 1', function (t) { t.plan(8) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const opts = { clean: false, clientId: 'abcde' } let subscriber = connect(setup(broker), opts) @@ -494,14 +494,14 @@ test('resend publish on non-clean reconnect QoS 1', function (t) { cmd: 'puback', messageId: packet.messageId }) - t.notEqual(packet.messageId, 42, 'messageId must differ') + t.not(packet.messageId, 42, 'messageId must differ') delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') setImmediate(() => { const stream = broker.persistence.outgoingStream(subscriberClient) stream.pipe(concat(function (list) { t.equal(list.length, 1, 'should remain one item in queue') - t.deepEqual(list[0].payload, Buffer.from('world world'), 'packet must match') + t.same(list[0].payload, Buffer.from('world world'), 'packet must match') })) }) }) @@ -513,7 +513,7 @@ test('resend many publish on non-clean reconnect QoS 1', function (t) { t.plan(38) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const opts = { clean: false, clientId: 'abcde' } let subscriber = connect(setup(broker), opts) @@ -567,8 +567,8 @@ test('resend many publish on non-clean reconnect QoS 1', function (t) { const [messageId, payload] = expected[recievedCount++] - t.notEqual(packet.messageId, messageId, 'messageId should not match') - t.deepEqual(packet.payload, Buffer.from(payload), 'payload should match') + t.not(packet.messageId, messageId, 'messageId should not match') + t.same(packet.payload, Buffer.from(payload), 'payload should match') }) }) }) @@ -578,7 +578,7 @@ test('do not resend QoS 1 packets at each reconnect', function (t) { t.plan(6) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) let subscriber = connect(setup(broker), { clean: false, clientId: 'abcde' }) const expected = { @@ -615,9 +615,9 @@ test('do not resend QoS 1 packets at each reconnect', function (t) { messageId: packet.messageId }) - t.notEqual(packet.messageId, 42, 'messageId must differ') + t.not(packet.messageId, 42, 'messageId must differ') delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') const subscriber2 = connect(setup(broker), { clean: false, clientId: 'abcde' }) @@ -633,7 +633,7 @@ test('do not resend QoS 1 packets if reconnect is clean', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) let subscriber = connect(setup(broker), { clean: false, clientId: 'abcde' }) @@ -666,7 +666,7 @@ test('do not resend QoS 1 packets at reconnect if puback was received', function t.plan(5) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) let subscriber = connect(setup(broker), { clean: false, clientId: 'abcde' }) const expected = { @@ -701,7 +701,7 @@ test('do not resend QoS 1 packets at reconnect if puback was received', function }) delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') subscriber = connect(setup(broker), { clean: false, clientId: 'abcde' }) @@ -716,7 +716,7 @@ test('remove stored subscriptions after unsubscribe', function (t) { t.plan(5) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) let subscriber = connect(setup(broker), { clean: false, clientId: 'abcde' }) @@ -728,7 +728,7 @@ test('remove stored subscriptions after unsubscribe', function (t) { }) subscriber.outStream.once('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'unsuback', messageId: 43, dup: false, @@ -777,7 +777,7 @@ test('upgrade a QoS 0 subscription to QoS 1', function (t) { t.plan(8) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const expected = { cmd: 'publish', @@ -794,7 +794,7 @@ test('upgrade a QoS 0 subscription to QoS 1', function (t) { s.outStream.once('data', function (packet) { t.ok(packet.messageId, 'has messageId') delete packet.messageId - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') }) s.broker.publish({ @@ -811,7 +811,7 @@ test('downgrade QoS 0 publish on QoS 1 subsciption', function (t) { t.plan(4) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const expected = { cmd: 'publish', @@ -825,7 +825,7 @@ test('downgrade QoS 0 publish on QoS 1 subsciption', function (t) { subscribe(t, s, 'hello', 1, function () { s.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet matches') + t.same(packet, expected, 'packet matches') }) s.broker.publish({ cmd: 'publish', @@ -840,7 +840,7 @@ test('subscribe and publish QoS 1 in parallel', function (t) { t.plan(5) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = connect(setup(broker)) const expected = { @@ -863,7 +863,7 @@ test('subscribe and publish QoS 1 in parallel', function (t) { t.equal(packet.messageId, 42, 'messageId must match') s.outStream.on('data', function (packet) { if (packet.cmd === 'suback') { - t.deepEqual(packet.granted, [1]) + t.same(packet.granted, [1]) t.equal(packet.messageId, 24) } if (packet.cmd === 'publish') { @@ -872,7 +872,7 @@ test('subscribe and publish QoS 1 in parallel', function (t) { messageId: packet.messageId }) delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') } }) }) diff --git a/test/qos2.js b/test/qos2.js index f24031dd..e87ac093 100644 --- a/test/qos2.js +++ b/test/qos2.js @@ -11,7 +11,7 @@ function publish (t, s, packet, done) { s.inStream.write(packet) s.outStream.once('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'pubrec', messageId: msgId, length: 2, @@ -26,7 +26,7 @@ function publish (t, s, packet, done) { }) s.outStream.once('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'pubcomp', messageId: msgId, length: 2, @@ -44,12 +44,12 @@ function publish (t, s, packet, done) { function receive (t, subscriber, expected, done) { subscriber.outStream.once('data', function (packet) { - t.notEqual(packet.messageId, expected.messageId, 'messageId must differ') + t.not(packet.messageId, expected.messageId, 'messageId must differ') const msgId = packet.messageId delete packet.messageId delete expected.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') subscriber.inStream.write({ cmd: 'pubrec', @@ -61,7 +61,7 @@ function receive (t, subscriber, expected, done) { cmd: 'pubcomp', messageId: msgId }) - t.deepEqual(packet, { + t.same(packet, { cmd: 'pubrel', messageId: msgId, length: 2, @@ -81,7 +81,7 @@ test('publish QoS 2', function (t) { t.plan(2) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const packet = { cmd: 'publish', @@ -97,7 +97,7 @@ test('subscribe QoS 2', function (t) { t.plan(8) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker)) const subscriber = connect(setup(broker)) @@ -123,7 +123,7 @@ test('publish QoS 2 throws error on write', function (t) { t.plan(1) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.on('client', function (client) { client.connected = false @@ -147,7 +147,7 @@ test('pubrec handler calls done when outgoingUpdate fails (clean=false)', functi t.plan(1) const s = connect(setup(), { clean: false }) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const handle = require('../lib/handlers/pubrec.js') @@ -164,7 +164,7 @@ test('client.publish with clean=true subscribption QoS 2', function (t) { t.plan(8) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const toPublish = { cmd: 'publish', @@ -201,7 +201,7 @@ test('call published method with client with QoS 2', function (t) { t.plan(9) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker)) const subscriber = connect(setup(broker)) @@ -236,7 +236,7 @@ test('call published method with client with QoS 2', function (t) { t.plan(9) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const opts = { clean: cleanSession } const publisher = connect(setup(broker)) @@ -262,15 +262,15 @@ test('call published method with client with QoS 2', function (t) { broker.authorizeForward = function (client, packet) { forwarded.brokerId = broker.id forwarded.brokerCounter = broker.counter - t.deepEqual(packet, forwarded, 'forwarded packet must match') + t.same(packet, forwarded, 'forwarded packet must match') return packet } subscribe(t, subscriber, 'hello', 2, function () { subscriber.outStream.once('data', function (packet) { - t.notEqual(packet.messageId, 42) + t.not(packet.messageId, 42) delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) publish(t, publisher, { @@ -300,7 +300,7 @@ test('call published method with client with QoS 2', function (t) { t.plan(6) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const opts = { clean: cleanSession } @@ -338,7 +338,7 @@ test('subscribe QoS 0, but publish QoS 2', function (t) { t.plan(6) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker)) const subscriber = connect(setup(broker)) @@ -354,7 +354,7 @@ test('subscribe QoS 0, but publish QoS 2', function (t) { subscribe(t, subscriber, 'hello', 0, function () { subscriber.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) publish(t, publisher, { @@ -373,7 +373,7 @@ test('subscribe QoS 1, but publish QoS 2', function (t) { t.plan(6) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker)) const subscriber = connect(setup(broker)) @@ -390,7 +390,7 @@ test('subscribe QoS 1, but publish QoS 2', function (t) { subscribe(t, subscriber, 'hello', 1, function () { subscriber.outStream.once('data', function (packet) { delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) publish(t, publisher, { @@ -409,7 +409,7 @@ test('restore QoS 2 subscriptions not clean', function (t) { t.plan(9) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) let subscriber = connect(setup(broker), { clean: false, clientId: 'abcde' }) const expected = { @@ -441,7 +441,7 @@ test('resend publish on non-clean reconnect QoS 2', function (t) { t.plan(8) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const opts = { clean: false, clientId: 'abcde' } let subscriber = connect(setup(broker), opts) @@ -473,7 +473,7 @@ test('resend pubrel on non-clean reconnect QoS 2', function (t) { t.plan(9) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const opts = { clean: false, clientId: 'abcde' } let subscriber = connect(setup(broker), opts) @@ -497,12 +497,12 @@ test('resend pubrel on non-clean reconnect QoS 2', function (t) { subscriber = connect(setup(broker), opts) subscriber.outStream.once('data', function (packet) { - t.notEqual(packet.messageId, expected.messageId, 'messageId must differ') + t.not(packet.messageId, expected.messageId, 'messageId must differ') const msgId = packet.messageId delete packet.messageId delete expected.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') subscriber.inStream.write({ cmd: 'pubrec', @@ -510,7 +510,7 @@ test('resend pubrel on non-clean reconnect QoS 2', function (t) { }) subscriber.outStream.once('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'pubrel', messageId: msgId, length: 2, @@ -524,7 +524,7 @@ test('resend pubrel on non-clean reconnect QoS 2', function (t) { subscriber = connect(setup(broker), opts) subscriber.outStream.once('data', function (packet) { - t.deepEqual(packet, { + t.same(packet, { cmd: 'pubrel', messageId: msgId, length: 2, @@ -548,7 +548,7 @@ test('publish after disconnection', function (t) { t.plan(10) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker)) const subscriber = connect(setup(broker)) @@ -612,7 +612,7 @@ test('multiple publish and store one', function (t) { broker.persistence.incomingGetPacket(sid, toPublish, function (err, origPacket) { delete origPacket.brokerId delete origPacket.brokerCounter - t.deepEqual(origPacket, toPublish, 'packet must match') + t.same(origPacket, toPublish, 'packet must match') t.error(err) }) }) @@ -624,7 +624,7 @@ test('packet is written to stream after being stored', function (t) { const broker = s.broker - t.tearDown(broker.close.bind(s.broker)) + t.teardown(broker.close.bind(s.broker)) let packetStored = false @@ -659,7 +659,7 @@ test('not send pubrec when persistence fails to store packet', function (t) { const s = connect(setup()) const broker = s.broker - t.tearDown(broker.close.bind(s.broker)) + t.teardown(broker.close.bind(s.broker)) s.broker.persistence.incomingStorePacket = function (client, packet, done) { t.pass('packet stored') diff --git a/test/regr-21.js b/test/regr-21.js index 45e1cfb8..546392bb 100644 --- a/test/regr-21.js +++ b/test/regr-21.js @@ -9,7 +9,7 @@ test('after an error, outstanding packets are discarded', function (t) { const s = connect(setup(), { keepalive: 1000 }) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) const packet = { cmd: 'publish', diff --git a/test/retain.js b/test/retain.js index 4cce0fb2..64c7a3c4 100644 --- a/test/retain.js +++ b/test/retain.js @@ -20,11 +20,11 @@ test('live retain packets', function (t) { } const s = noError(connect(setup()), t) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) subscribe(t, s, 'hello', 0, function () { s.outStream.on('data', function (packet) { - t.deepEqual(packet, expected) + t.same(packet, expected) }) s.broker.publish({ @@ -45,7 +45,7 @@ test('retain messages', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker)) const subscriber = connect(setup(broker)) @@ -67,7 +67,7 @@ test('retain messages', function (t) { setImmediate(function () { subscribe(t, subscriber, 'hello', 0, function () { subscriber.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) @@ -80,7 +80,7 @@ test('retain messages propagates through broker subscriptions', function (t) { t.plan(1) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const expected = { cmd: 'publish', @@ -97,7 +97,7 @@ test('retain messages propagates through broker subscriptions', function (t) { delete packet.brokerCounter cb() setImmediate(function () { - t.deepEqual(packet, expected, 'packet must not have been modified') + t.same(packet, expected, 'packet must not have been modified') }) } @@ -110,7 +110,7 @@ test('avoid wrong deduping of retain messages', function (t) { t.plan(7) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker)) const subscriber = connect(setup(broker)) @@ -141,7 +141,7 @@ test('avoid wrong deduping of retain messages', function (t) { subscriber.outStream.once('data', function (packet) { subscribe(t, subscriber, 'hello', 0, function () { subscriber.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) @@ -155,7 +155,7 @@ test('reconnected subscriber will not receive retained messages when QoS 0 and c t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker), { clean: true }) let subscriber = connect(setup(broker), { clean: true }) @@ -177,7 +177,7 @@ test('reconnected subscriber will not receive retained messages when QoS 0 and c retain: false }) subscriber.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') subscriber.inStream.end() publisher.inStream.write({ cmd: 'publish', @@ -200,7 +200,7 @@ test('new QoS 0 subscribers receive QoS 0 retained messages when clean', functio const clock = Faketimers.createClock() const broker = aedes() - t.tearDown(function () { + t.teardown(function () { clock.reset() broker.close() }) @@ -225,14 +225,14 @@ test('new QoS 0 subscribers receive QoS 0 retained messages when clean', functio const subscriber1 = connect(setup(broker), { clean: true }) subscribe(t, subscriber1, 'hello/world', 0, function () { subscriber1.outStream.on('data', function (packet) { - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') clock.tick(100) }) }) const subscriber2 = connect(setup(broker), { clean: true }) subscribe(t, subscriber2, 'hello/+', 0, function () { subscriber2.outStream.on('data', function (packet) { - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') clock.tick(100) }) }) @@ -270,9 +270,9 @@ test('new QoS 0 subscribers receive downgraded QoS 1 retained messages when clea const subscriber = connect(setup(broker), { clean: true }) subscribe(t, subscriber, 'hello', 0, function () { subscriber.outStream.on('data', function (packet) { - t.notEqual(packet.messageId, 42, 'messageId should not be the same') + t.not(packet.messageId, 42, 'messageId should not be the same') delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') broker.close() }) }) @@ -287,7 +287,7 @@ test('clean retained messages', function (t) { t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker), { clean: true }) publisher.inStream.write({ @@ -317,7 +317,7 @@ test('broker not store zero-byte retained messages', function (t) { t.plan(0) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = connect(setup(broker)) @@ -342,7 +342,7 @@ test('fail to clean retained messages without retain flag', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker), { clean: true }) const expected = { @@ -371,7 +371,7 @@ test('fail to clean retained messages without retain flag', function (t) { const subscriber = connect(setup(broker), { clean: true }) subscribe(t, subscriber, 'hello', 0, function () { subscriber.outStream.on('data', function (packet) { - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) @@ -380,7 +380,7 @@ test('only get the last retained messages in same topic', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker), { clean: true }) const expected = { @@ -409,7 +409,7 @@ test('only get the last retained messages in same topic', function (t) { const subscriber = connect(setup(broker), { clean: true }) subscribe(t, subscriber, 'hello', 0, function () { subscriber.outStream.on('data', function (packet) { - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) @@ -418,7 +418,7 @@ test('deliver QoS 1 retained messages to new subscriptions', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker)) const subscriber = connect(setup(broker)) @@ -445,7 +445,7 @@ test('deliver QoS 1 retained messages to new subscriptions', function (t) { subscribe(t, subscriber, 'hello', 1, function () { subscriber.outStream.once('data', function (packet) { delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) @@ -455,7 +455,7 @@ test('deliver QoS 1 retained messages to established subscriptions', function (t t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker)) const subscriber = connect(setup(broker)) @@ -472,7 +472,7 @@ test('deliver QoS 1 retained messages to established subscriptions', function (t subscribe(t, subscriber, 'hello', 1, function () { subscriber.outStream.once('data', function (packet) { delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) publisher.inStream.write({ cmd: 'publish', @@ -489,7 +489,7 @@ test('deliver QoS 0 retained message with QoS 1 subscription', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker)) const subscriber = connect(setup(broker)) @@ -511,7 +511,7 @@ test('deliver QoS 0 retained message with QoS 1 subscription', function (t) { setImmediate(function () { subscribe(t, subscriber, 'hello', 1, function () { subscriber.outStream.once('data', function (packet) { - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) @@ -531,7 +531,7 @@ test('disconnect and retain messages with QoS 1 [clean=false]', function (t) { t.plan(7) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) let subscriber = noError(connect(setup(broker), { clean: false, clientId: 'abcde' }), t) const expected = { @@ -573,10 +573,10 @@ test('disconnect and retain messages with QoS 1 [clean=false]', function (t) { subscriber.outStream.once('data', function (packet) { // receive any queued messages (no matter they are retained messages) at the disconnected time - t.notEqual(packet.messageId, 42, 'messageId must differ') + t.not(packet.messageId, 42, 'messageId must differ') delete packet.messageId packet.length = 14 - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') // there should be no messages come from restored subscriptions subscriber.outStream.once('data', function (packet) { @@ -591,7 +591,7 @@ test('disconnect and two retain messages with QoS 1 [clean=false]', function (t) t.plan(15) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) let subscriber = noError(connect(setup(broker), { clean: false, clientId: 'abcde' }), t) const expected = { @@ -644,28 +644,28 @@ test('disconnect and two retain messages with QoS 1 [clean=false]', function (t) subscriber.outStream.once('data', function (packet) { // receive any queued messages (included retained messages) at the disconnected time - t.notEqual(packet.messageId, 41, 'messageId must differ') + t.not(packet.messageId, 41, 'messageId must differ') delete packet.messageId packet.length = 14 expected.payload = Buffer.from('world') - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') // receive any queued messages (included retained messages) at the disconnected time subscriber.outStream.once('data', function (packet) { - t.notEqual(packet.messageId, 42, 'messageId must differ') + t.not(packet.messageId, 42, 'messageId must differ') delete packet.messageId packet.length = 14 expected.payload = Buffer.from('world2') - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') // should get the last retained message when we do a subscribe subscribe(t, subscriber, 'hello', 1, function () { subscriber.outStream.on('data', function (packet) { - t.notEqual(packet.messageId, 42, 'messageId must differ') + t.not(packet.messageId, 42, 'messageId must differ') delete packet.messageId packet.length = 14 expected.payload = Buffer.from('world2') - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) diff --git a/test/topics.js b/test/topics.js index f0814414..d770a52c 100644 --- a/test/topics.js +++ b/test/topics.js @@ -9,7 +9,7 @@ test('Single-level wildcard should match empty level', function (t) { t.plan(4) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) subscribe(t, s, 'a/+/b', 0, function () { s.outStream.once('data', function (packet) { @@ -51,7 +51,7 @@ test('publish invalid topic with #', function (t) { t.plan(4) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) subscribe(t, s, '#', 0, function () { s.outStream.once('data', function (packet) { @@ -74,7 +74,7 @@ test('publish invalid topic with +', function (t) { t.plan(4) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) subscribe(t, s, '#', 0, function () { s.outStream.once('data', function (packet) { @@ -98,7 +98,7 @@ test('publish invalid topic with +', function (t) { t.plan(1) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.on('clientError', function () { t.pass('raise an error') @@ -118,7 +118,7 @@ test('publish invalid topic with +', function (t) { t.plan(1) const s = connect(setup()) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.on('clientError', function () { t.pass('raise an error') @@ -136,7 +136,7 @@ test('topics are case-sensitive', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const publisher = connect(setup(broker), { clean: true }) const subscriber = connect(setup(broker), { clean: true }) @@ -152,7 +152,7 @@ test('topics are case-sensitive', function (t) { subscribe(t, subscriber, 'hello', 0, function () { subscriber.outStream.on('data', function (packet) { - t.deepEqual(packet, expected, 'packet mush match') + t.same(packet, expected, 'packet mush match') }) ;['hello', 'HELLO', 'heLLo', 'HELLO/#', 'hello/+'].forEach(function (topic) { publisher.inStream.write({ @@ -176,7 +176,7 @@ function subscribeMultipleTopics (t, broker, qos, subscriber, subscriptions, don subscriber.outStream.once('data', function (packet) { t.equal(packet.cmd, 'suback') - t.deepEqual(packet.granted, subscriptions.map(obj => obj.qos)) + t.same(packet.granted, subscriptions.map(obj => obj.qos)) t.equal(packet.messageId, 24) publisher.inStream.write({ @@ -197,7 +197,7 @@ test('Overlapped topics with same QoS', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const subscriber = connect(setup(broker)) const expected = { @@ -215,7 +215,7 @@ test('Overlapped topics with same QoS', function (t) { subscribeMultipleTopics(t, broker, 1, subscriber, sub, function () { subscriber.outStream.on('data', function (packet) { delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) @@ -225,7 +225,7 @@ test('deliver overlapped topics respecting the maximum QoS of all the matching s t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const subscriber = connect(setup(broker)) const expected = { @@ -243,7 +243,7 @@ test('deliver overlapped topics respecting the maximum QoS of all the matching s subscribeMultipleTopics(t, broker, 0, subscriber, sub, function () { subscriber.outStream.on('data', function (packet) { delete packet.messageId - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) @@ -253,7 +253,7 @@ test('deliver overlapped topics respecting the maximum QoS of all the matching s t.plan(3) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const subscriber = connect(setup(broker)) @@ -271,7 +271,7 @@ test('Overlapped topics with QoS downgrade', function (t) { t.plan(4) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const subscriber = connect(setup(broker)) const expected = { @@ -288,7 +288,7 @@ test('Overlapped topics with QoS downgrade', function (t) { { topic: 'hello/#', qos: 1 }] subscribeMultipleTopics(t, broker, 0, subscriber, sub, function () { subscriber.outStream.on('data', function (packet) { - t.deepEqual(packet, expected, 'packet must match') + t.same(packet, expected, 'packet must match') }) }) }) diff --git a/test/will.js b/test/will.js index dc7cca1c..bac09b8f 100644 --- a/test/will.js +++ b/test/will.js @@ -29,11 +29,11 @@ test('delivers a will', function (t) { s.conn.destroy() } ) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.mq.on('mywill', function (packet, cb) { t.equal(packet.topic, opts.will.topic, 'topic matches') - t.deepEqual(packet.payload, opts.will.payload, 'payload matches') + t.same(packet.payload, opts.will.payload, 'payload matches') t.equal(packet.qos, opts.will.qos, 'qos matches') t.equal(packet.retain, opts.will.retain, 'retain matches') cb() @@ -45,7 +45,7 @@ test('calling close two times should not deliver two wills', function (t) { const opts = {} const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('client', function (client) { client.close() @@ -61,7 +61,7 @@ test('calling close two times should not deliver two wills', function (t) { broker.mq.removeListener('mywill', onWill) broker.mq.on('mywill', t.fail.bind(t)) t.equal(packet.topic, opts.will.topic, 'topic matches') - t.deepEqual(packet.payload, opts.will.payload, 'payload matches') + t.same(packet.payload, opts.will.payload, 'payload matches') t.equal(packet.qos, opts.will.qos, 'qos matches') t.equal(packet.retain, opts.will.retain, 'retain matches') cb() @@ -93,7 +93,7 @@ test('delivers old will in case of a crash', function (t) { persistence: persistence, heartbeatInterval: interval }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const start = Date.now() @@ -103,7 +103,7 @@ test('delivers old will in case of a crash', function (t) { broker.mq.removeListener('mywill', check) t.ok(Date.now() - start >= 3 * interval, 'the will needs to be emitted after 3 heartbeats') t.equal(packet.topic, will.topic, 'topic matches') - t.deepEqual(packet.payload, will.payload, 'payload matches') + t.same(packet.payload, will.payload, 'payload matches') t.equal(packet.qos, will.qos, 'qos matches') t.equal(packet.retain, will.retain, 'retain matches') broker.mq.on('mywill', function (packet) { @@ -123,7 +123,7 @@ test('delete old broker', function (t) { const broker = aedes({ heartbeatInterval: heartbeatInterval }) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const brokerId = 'dummyBroker' @@ -147,7 +147,7 @@ test('store the will in the persistence', function (t) { // willConnect populates opts with a will const s = willConnect(setup(), opts) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.on('client', function () { // this is connack @@ -155,10 +155,10 @@ test('store the will in the persistence', function (t) { id: opts.clientId }, function (err, packet) { t.error(err, 'no error') - t.deepEqual(packet.topic, opts.will.topic, 'will topic matches') - t.deepEqual(packet.payload, opts.will.payload, 'will payload matches') - t.deepEqual(packet.qos, opts.will.qos, 'will qos matches') - t.deepEqual(packet.retain, opts.will.retain, 'will retain matches') + t.same(packet.topic, opts.will.topic, 'will topic matches') + t.same(packet.payload, opts.will.payload, 'will payload matches') + t.same(packet.qos, opts.will.qos, 'will qos matches') + t.same(packet.retain, opts.will.retain, 'will retain matches') }) }) }) @@ -171,7 +171,7 @@ test('delete the will in the persistence after publish', function (t) { } const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.on('client', function (client) { setImmediate(function () { @@ -216,7 +216,7 @@ test('delivers a will with authorization', function (t) { s.conn.destroy() } ) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.on('clientDisconnect', function (client) { t.equal(client.connected, false) @@ -224,7 +224,7 @@ test('delivers a will with authorization', function (t) { s.broker.mq.on('mywill', function (packet, cb) { t.equal(packet.topic, opts.will.topic, 'topic matches') - t.deepEqual(packet.payload, opts.will.payload, 'payload matches') + t.same(packet.payload, opts.will.payload, 'payload matches') t.equal(packet.qos, opts.will.qos, 'qos matches') t.equal(packet.retain, opts.will.retain, 'retain matches') t.equal(authorized, true, 'authorization called') @@ -250,7 +250,7 @@ test('delivers a will waits for authorization', function (t) { s.conn.destroy() } ) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.on('clientDisconnect', function () { t.pass('client is disconnected') @@ -258,7 +258,7 @@ test('delivers a will waits for authorization', function (t) { s.broker.mq.on('mywill', function (packet, cb) { t.equal(packet.topic, opts.will.topic, 'topic matches') - t.deepEqual(packet.payload, opts.will.payload, 'payload matches') + t.same(packet.payload, opts.will.payload, 'payload matches') t.equal(packet.qos, opts.will.qos, 'qos matches') t.equal(packet.retain, opts.will.retain, 'retain matches') t.equal(authorized, true, 'authorization called') @@ -284,7 +284,7 @@ test('does not deliver a will without authorization', function (t) { s.conn.destroy() } ) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.on('clientDisconnect', function () { t.equal(authorized, true, 'authorization called') @@ -311,7 +311,7 @@ test('does not deliver a will without authentication', function (t) { })), opts ) - t.tearDown(s.broker.close.bind(s.broker)) + t.teardown(s.broker.close.bind(s.broker)) s.broker.on('clientError', function () { t.equal(authenticated, true, 'authentication called') @@ -355,7 +355,7 @@ test('does not deliver will when client sends a DISCONNECT', function (t) { t.plan(0) const broker = aedes() - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const s = noError(willConnect(setup(broker), {}, function () { s.inStream.end({ @@ -428,7 +428,7 @@ test('don\'t delivers a will if broker alive', function (t) { let count = 0 const broker = aedes(opts) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) const streamWill = persistence.streamWill persistence.streamWill = function () { @@ -481,7 +481,7 @@ test('handle will publish error', function (t) { } const broker = aedes(opts) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.once('error', function (err) { t.equal('Throws error', err.message, 'throws error') @@ -518,7 +518,7 @@ test('handle will publish error 2', function (t) { } const broker = aedes(opts) - t.tearDown(broker.close.bind(broker)) + t.teardown(broker.close.bind(broker)) broker.once('error', function (err) { t.equal('Throws error', err.message, 'throws error')