Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some glaring issues reported by eslint in test.js. #19

Merged
merged 1 commit into from Jan 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 15 additions & 15 deletions test.js
Expand Up @@ -183,9 +183,9 @@ tape('rcode', function (t) {
}

const ops = ['QUERY', 'IQUERY', 'STATUS', 'OPCODE_3', 'NOTIFY', 'UPDATE', 'OPCODE_6', 'OPCODE_7', 'OPCODE_8', 'OPCODE_9', 'OPCODE_10', 'OPCODE_11', 'OPCODE_12', 'OPCODE_13', 'OPCODE_14', 'OPCODE_15']
for (i in ops) {
code = opcodes.toOpcode(ops[i])
t.ok(ops[i] === opcodes.toString(code), 'opcode conversion from/to string matches: ' + opcodes.toString(code))
for (var j in ops) {
var ocode = opcodes.toOpcode(ops[j])
t.ok(ops[j] === opcodes.toString(ocode), 'opcode conversion from/to string matches: ' + opcodes.toString(ocode))
}

var buf = packet.encode({
Expand Down Expand Up @@ -245,30 +245,30 @@ tape('name_encoding', function (t) {
t.end()
})

function testEncoder (t, packet, val) {
var buf = packet.encode(val)
var val2 = packet.decode(buf)
function testEncoder (t, rpacket, val) {
var buf = rpacket.encode(val)
var val2 = rpacket.decode(buf)

t.same(buf.length, packet.encode.bytes, 'encode.bytes was set correctly')
t.same(buf.length, packet.encodingLength(val), 'encoding length matches')
t.same(buf.length, rpacket.encode.bytes, 'encode.bytes was set correctly')
t.same(buf.length, rpacket.encodingLength(val), 'encoding length matches')
t.ok(compare(t, val, val2), 'decoded object match')

var buf2 = packet.encode(val2)
var val3 = packet.decode(buf2)
var buf2 = rpacket.encode(val2)
var val3 = rpacket.decode(buf2)

t.same(buf2.length, packet.encode.bytes, 'encode.bytes was set correctly on re-encode')
t.same(buf2.length, packet.encodingLength(val), 'encoding length matches on re-encode')
t.same(buf2.length, rpacket.encode.bytes, 'encode.bytes was set correctly on re-encode')
t.same(buf2.length, rpacket.encodingLength(val), 'encoding length matches on re-encode')

t.ok(compare(t, val, val3), 'decoded object match on re-encode')
t.ok(compare(t, val2, val3), 're-encoded decoded object match on re-encode')

var bigger = Buffer.allocUnsafe(buf2.length + 10)

var buf3 = packet.encode(val, bigger, 10)
var val4 = packet.decode(buf3, 10)
var buf3 = rpacket.encode(val, bigger, 10)
var val4 = rpacket.decode(buf3, 10)

t.ok(buf3 === bigger, 'echoes buffer on external buffer')
t.same(packet.encode.bytes, buf.length, 'encode.bytes is the same on external buffer')
t.same(rpacket.encode.bytes, buf.length, 'encode.bytes is the same on external buffer')
t.ok(compare(t, val, val4), 'decoded object match on external buffer')
}

Expand Down