Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

Commit

Permalink
Little test fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Apr 28, 2014
1 parent d17a240 commit 8c5151a
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion test/abstract_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ module.exports = function(moscaSettings, createConnection) {
}, keepalive * 1000 / 2);
});

fastForward(100, 4000);
fastForward(50, 3000);
});
});

Expand Down Expand Up @@ -1556,6 +1556,7 @@ module.exports = function(moscaSettings, createConnection) {
client.on("publish", function(packet) {
expect(packet.topic).to.be.eql("hello");
expect(packet.payload).to.be.eql("world");
expect(packet.qos).to.be.eql(1);
client.disconnect();
});
});
Expand Down Expand Up @@ -1672,6 +1673,66 @@ module.exports = function(moscaSettings, createConnection) {
], done);
});

it("should support offline messaging", function(done) {
var opts = buildOpts();

opts.clientId = "mosca-unclean-clients-test2";
opts.clean = false;
opts.keepalive = 0;

async.series([

function(cb) {
buildAndConnect(cb, opts, function(client) {
var subscriptions = [{
topic: "hello",
qos: 1
}];

client.subscribe({
subscriptions: subscriptions,
messageId: 42
});

client.on("suback", function() {
client.disconnect();
});
});
},

function(cb) {
buildClient(cb, function(client) {
client.connect(buildOpts());

client.publish({
topic: "hello",
qos: 1,
payload: "world",
messageId: 42
});

client.on("puback", function(packet) {
client.disconnect();
});
});
},

function(cb) {
buildAndConnect(cb, opts, function(client) {

client.on("publish", function(packet) {
client.puback({ messageId: packet.messageId });
client.disconnect();

expect(packet.topic).to.eql("hello");
expect(packet.payload).to.eql("world");
expect(packet.qos).to.eql(1);
});
});
}
], done);
});

describe("pattern matching", function() {

var buildTest = function(subscribed, published, expected) {
Expand Down

0 comments on commit 8c5151a

Please sign in to comment.