Skip to content

Commit 9305798

Browse files
committed
#152 - add test
1 parent 24ba53b commit 9305798

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

test.js

+57-1
Original file line numberDiff line numberDiff line change
@@ -3068,7 +3068,6 @@ test('userProperties null prototype', t => {
30683068
topicAliasMaximum: 456,
30693069
requestResponseInformation: true,
30703070
requestProblemInformation: true,
3071-
correlationData: undefined,
30723071
userProperties: {
30733072
test: 'test'
30743073
},
@@ -3162,6 +3161,63 @@ test('stops parsing after first error', t => {
31623161
]))
31633162
})
31643163

3164+
test('undefined properties', t => {
3165+
t.plan(2)
3166+
3167+
const packet = mqtt.generate({
3168+
cmd: 'connect',
3169+
retain: false,
3170+
qos: 0,
3171+
dup: false,
3172+
length: 125,
3173+
protocolId: 'MQTT',
3174+
protocolVersion: 5,
3175+
will: {
3176+
retain: true,
3177+
qos: 2,
3178+
properties: {
3179+
willDelayInterval: 1234,
3180+
payloadFormatIndicator: false,
3181+
messageExpiryInterval: 4321,
3182+
contentType: 'test',
3183+
responseTopic: 'topic',
3184+
correlationData: Buffer.from([1, 2, 3, 4]),
3185+
userProperties: {
3186+
test: 'test'
3187+
}
3188+
},
3189+
topic: 'topic',
3190+
payload: Buffer.from([4, 3, 2, 1])
3191+
},
3192+
clean: true,
3193+
keepalive: 30,
3194+
properties: {
3195+
sessionExpiryInterval: 1234,
3196+
receiveMaximum: 432,
3197+
maximumPacketSize: 100,
3198+
topicAliasMaximum: 456,
3199+
requestResponseInformation: true,
3200+
requestProblemInformation: true,
3201+
correlationData: undefined,
3202+
userProperties: {
3203+
test: 'test'
3204+
},
3205+
authenticationMethod: 'test',
3206+
authenticationData: Buffer.from([1, 2, 3, 4])
3207+
},
3208+
clientId: 'test'
3209+
})
3210+
3211+
const parser = mqtt.parser()
3212+
3213+
parser.on('packet', packet => {
3214+
t.equal(packet.cmd, 'connect')
3215+
t.equal(Object.hasOwn(packet.properties, 'correlationData'), false)
3216+
})
3217+
3218+
parser.parse(packet)
3219+
})
3220+
31653221
testGenerateErrorMultipleCmds([
31663222
'publish',
31673223
'puback',

0 commit comments

Comments
 (0)