@@ -4,9 +4,10 @@ const tap = require('tap')
44const { BerWriter } = require ( '@ldapjs/asn1' )
55const Control = require ( './control' )
66
7- tap . test ( 'contructor ' , t => {
7+ tap . test ( 'constructor ' , t => {
88 t . test ( 'new no args' , function ( t ) {
99 t . ok ( new Control ( ) )
10+ t . equal ( Object . prototype . toString . call ( new Control ( ) ) , '[object LdapControl]' )
1011 t . end ( )
1112 } )
1213
@@ -24,7 +25,35 @@ tap.test('contructor', t => {
2425 t . end ( )
2526} )
2627
27- tap . test ( '#toBer' , t => {
28+ tap . test ( 'pojo' , t => {
29+ t . test ( 'passes through _pojo' , async t => {
30+ class Foo extends Control {
31+ _pojo ( obj ) {
32+ obj . foo = 'foo'
33+ }
34+ }
35+ const control = new Foo ( )
36+ t . strictSame ( control . pojo , {
37+ type : '' ,
38+ value : null ,
39+ criticality : false ,
40+ foo : 'foo'
41+ } )
42+ } )
43+
44+ t . test ( 'returns basic object' , async t => {
45+ const control = new Control ( { type : '1.2.3' , criticality : false , value : 'foo' } )
46+ t . strictSame ( control . pojo , {
47+ type : '1.2.3' ,
48+ value : 'foo' ,
49+ criticality : false
50+ } )
51+ } )
52+
53+ t . end ( )
54+ } )
55+
56+ tap . test ( 'toBer' , t => {
2857 t . test ( 'converts empty instance to BER' , async t => {
2958 const target = new BerWriter ( )
3059 target . startSequence ( )
@@ -128,28 +157,3 @@ tap.test('#toBer', t => {
128157
129158 t . end ( )
130159} )
131-
132- tap . test ( '#plainObject' , t => {
133- t . test ( 'passes through _updatePlainObject' , async t => {
134- t . plan ( 2 )
135- const control = new Control ( )
136- control . _updatePlainObject = ( ) => {
137- t . pass ( )
138- return 'foo'
139- }
140- const str = control . plainObject
141- t . equal ( str , 'foo' )
142- } )
143-
144- t . test ( 'returns basic object' , async t => {
145- const control = new Control ( { type : '1.2.3' , criticality : false , value : 'foo' } )
146- const str = control . plainObject
147- t . same ( str , {
148- controlType : '1.2.3' ,
149- criticality : false ,
150- controlValue : 'foo'
151- } )
152- } )
153-
154- t . end ( )
155- } )
0 commit comments