Skip to content

Commit

Permalink
test(mqtt): make use of broker server more type-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Dec 4, 2023
1 parent 80afe18 commit 5f124e7
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ should();

describe("MQTT client implementation", () => {
let servient: Servient;
let brokerServer: MqttBrokerServer;
let brokerServer: MqttBrokerServer | undefined;

const brokerAddress = "localhost";
const brokerPort = 1889;
Expand All @@ -43,7 +43,7 @@ describe("MQTT client implementation", () => {

afterEach(async () => {
await servient.shutdown();
await brokerServer.stop();
await brokerServer?.stop();
});

it("should expose via broker", function (done: Mocha.Done) {
Expand All @@ -59,8 +59,8 @@ describe("MQTT client implementation", () => {
servient.addClientFactory(new MqttClientFactory());

servient.start().then((WoT) => {
expect(brokerServer.getPort()).to.equal(brokerPort);
expect(brokerServer.getAddress()).to.equal(brokerAddress);
expect(brokerServer?.getPort()).to.equal(brokerPort);
expect(brokerServer?.getAddress()).to.equal(brokerAddress);

const eventNumber = Math.floor(Math.random() * 1000000);
const eventName: string = "event" + eventNumber;
Expand Down Expand Up @@ -121,8 +121,8 @@ describe("MQTT client implementation", () => {
servient.addClientFactory(new MqttsClientFactory({ rejectUnauthorized: false }));

servient.start().then((WoT) => {
expect(brokerServer.getPort()).to.equal(brokerPort);
expect(brokerServer.getAddress()).to.equal(brokerAddress);
expect(brokerServer?.getPort()).to.equal(brokerPort);
expect(brokerServer?.getAddress()).to.equal(brokerAddress);

const eventNumber = Math.floor(Math.random() * 1000000);
const eventName: string = "event" + eventNumber;
Expand Down

0 comments on commit 5f124e7

Please sign in to comment.