Skip to content

Commit

Permalink
try verify the ack packets test
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Aug 21, 2024
1 parent ebfa806 commit 179c416
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/mqtt5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,24 +379,31 @@ export async function subPubUnsubTest(client: mqtt5.Mqtt5Client, qos: mqtt5.QoS,

await connectionSuccess;

await client.subscribe({
const suback = await client.subscribe({
subscriptions: [
{ qos : mqtt5.QoS.AtLeastOnce, topicFilter: topic }
]
});

await client.publish({
expect(suback.qos).toEqual(mqtt5.QoS.AtLeastOnce)

const puback = await client.publish({
topicName: topic,
qos: qos,
payload: testPayload
});

expect(puback.qos).toEqual(qos)


await messageReceived;

await client.unsubscribe({
const unsuback = await client.unsubscribe({
topicFilters: [ topic ]
});

expect(unsuback.reasonCodes).toEqual([qos])

await client.publish({
topicName: topic,
qos: mqtt5.QoS.AtLeastOnce,
Expand Down Expand Up @@ -456,7 +463,6 @@ export async function nullSubscribeTest(client: mqtt5.Mqtt5Client) {
client.start();
await connected;

// @ts-ignore
await expect(client.subscribe(null)).rejects.toThrow();

client.stop();
Expand All @@ -472,7 +478,6 @@ export async function nullUnsubscribeTest(client: mqtt5.Mqtt5Client) {
client.start();
await connected;

// @ts-ignore
await expect(client.unsubscribe(null)).rejects.toThrow();

client.stop();
Expand All @@ -488,7 +493,6 @@ export async function nullPublishTest(client: mqtt5.Mqtt5Client) {
client.start();
await connected;

// @ts-ignore
await expect(client.publish(null)).rejects.toThrow();

client.stop();
Expand Down

0 comments on commit 179c416

Please sign in to comment.