Skip to content

Commit

Permalink
test: updated codec.encode unit test to work across all Node.js versions
Browse files Browse the repository at this point in the history
  • Loading branch information
bizob2828 committed Dec 4, 2023
1 parent 5148ebc commit d69bf20
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/unit/util/codec.test.js
Expand Up @@ -5,6 +5,7 @@

'use strict'
const { test } = require('tap')
const zlib = require('zlib')
const codec = require('../../../lib/util/codec')
const DATA = { foo: 'bar' }
const ENCODED = 'eJyrVkrLz1eyUkpKLFKqBQAdegQ0'
Expand All @@ -22,13 +23,14 @@ test('codec', function (t) {
})

t.test('should not error for circular payloads', function (t) {
const val = 'eJyrVkrLz1eyUkpKLFLSUcpPygKyo50zi5JLcxKLFOpilWoBuCkK6A=='
const val = '{"foo":"bar","obj":"[Circular ~]"}'
const obj = { foo: 'bar' }
obj.obj = obj

codec.encode(obj, function (err, encoded) {
t.error(err)
t.equal(encoded, val)
const decoded = zlib.inflateSync(Buffer.from(encoded, 'base64')).toString()
t.equal(decoded, val)
t.end()
})
})
Expand Down

0 comments on commit d69bf20

Please sign in to comment.