Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit db8d5f5

Browse files
authored
Merge branch 'next' into next-vls-controls
2 parents 311c94e + 4b2e55e commit db8d5f5

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

lib/change.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ Object.defineProperties(Change.prototype, {
8181
val[k].forEach(function (v) {
8282
_attr.addValue(v.toString())
8383
})
84+
} else if (Buffer.isBuffer(val[k])) {
85+
_attr.addValue(val[k])
8486
} else if (val[k] !== undefined && val[k] !== null) {
8587
_attr.addValue(val[k].toString())
8688
}

test/change.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict'
22

3+
const fs = require('fs')
4+
const path = require('path')
35
const { test } = require('tap')
46
const { BerReader, BerWriter } = require('asn1')
57
const { Attribute, Change } = require('../lib')
@@ -28,6 +30,26 @@ test('new with args', function (t) {
2830
t.end()
2931
})
3032

33+
test('new with args and buffer', function (t) {
34+
var img = fs.readFileSync(path.join(__dirname, '/imgs/test.jpg'))
35+
36+
var change = new Change({
37+
operation: 'add',
38+
modification: {
39+
thumbnailPhoto: img
40+
}
41+
})
42+
43+
t.ok(change)
44+
45+
t.equal(change.operation, 'add')
46+
t.equal(change.modification.type, 'thumbnailPhoto')
47+
t.equal(change.modification.vals.length, 1)
48+
t.equal(change.modification.buffers[0].compare(img), 0)
49+
50+
t.end()
51+
})
52+
3153
test('validate fields', function (t) {
3254
const c = new Change()
3355
t.ok(c)

test/imgs/test.jpg

740 Bytes
Loading

0 commit comments

Comments
 (0)