This repository was archived by the owner on May 14, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,8 @@ Object.defineProperties(Change.prototype, {
81
81
val [ k ] . forEach ( function ( v ) {
82
82
_attr . addValue ( v . toString ( ) )
83
83
} )
84
+ } else if ( Buffer . isBuffer ( val [ k ] ) ) {
85
+ _attr . addValue ( val [ k ] )
84
86
} else if ( val [ k ] !== undefined && val [ k ] !== null ) {
85
87
_attr . addValue ( val [ k ] . toString ( ) )
86
88
}
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
+ const fs = require ( 'fs' )
4
+ const path = require ( 'path' )
3
5
const { test } = require ( 'tap' )
4
6
const { BerReader, BerWriter } = require ( 'asn1' )
5
7
const { Attribute, Change } = require ( '../lib' )
@@ -28,6 +30,26 @@ test('new with args', function (t) {
28
30
t . end ( )
29
31
} )
30
32
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
+
31
53
test ( 'validate fields' , function ( t ) {
32
54
const c = new Change ( )
33
55
t . ok ( c )
You can’t perform that action at this time.
0 commit comments