Skip to content

Commit

Permalink
Unit test for key/value serialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
flatheadmill authored and ralphtheninja committed Sep 4, 2017
1 parent 2b75f31 commit bc49587
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test.js
Expand Up @@ -62,6 +62,30 @@ test('test core extensibility', function (t) {
;new Test('foobar')
})

test('test key/value serialization', function (t) {
function Test (location) {
AbstractLevelDOWN.call(this, location)
}

util.inherits(Test, AbstractLevelDOWN)

var buffer = new Buffer(0)
var test = new Test('foobar')

t.ok(test._serializeKey(1) === '1', '_serializeKey converts to string')
t.ok(test._serializeKey(buffer) === buffer, '_serializeKey returns Buffer as is')

t.ok(test._serializeValue(1) === '1', '_serializeValue converts to string')
t.equal(test._serializeValue(null), '', '_serializeValue converts null to empty string')
t.ok(test._serializeValue(buffer) === buffer, '_serializeValue returns Buffer as is')

process.browser = true
t.ok(test._serializeValue(1) === 1, '_serializeValue returns value as is when process.browser')
delete process.browser

t.end()
})

test('test open() extensibility', function (t) {
var spy = sinon.spy()
, expectedCb = function () {}
Expand Down

0 comments on commit bc49587

Please sign in to comment.