Merge branch 'next' into next-vls-controls

This commit is contained in:
James Sumners 2019-09-08 07:34:14 -04:00 committed by GitHub
commit db8d5f5ccb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View File

@ -81,6 +81,8 @@ Object.defineProperties(Change.prototype, {
val[k].forEach(function (v) {
_attr.addValue(v.toString())
})
} else if (Buffer.isBuffer(val[k])) {
_attr.addValue(val[k])
} else if (val[k] !== undefined && val[k] !== null) {
_attr.addValue(val[k].toString())
}

View File

@ -1,5 +1,7 @@
'use strict'
const fs = require('fs')
const path = require('path')
const { test } = require('tap')
const { BerReader, BerWriter } = require('asn1')
const { Attribute, Change } = require('../lib')
@ -28,6 +30,26 @@ test('new with args', function (t) {
t.end()
})
test('new with args and buffer', function (t) {
var img = fs.readFileSync(path.join(__dirname, '/imgs/test.jpg'))
var change = new Change({
operation: 'add',
modification: {
thumbnailPhoto: img
}
})
t.ok(change)
t.equal(change.operation, 'add')
t.equal(change.modification.type, 'thumbnailPhoto')
t.equal(change.modification.vals.length, 1)
t.equal(change.modification.buffers[0].compare(img), 0)
t.end()
})
test('validate fields', function (t) {
const c = new Change()
t.ok(c)

BIN
test/imgs/test.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B