node-ldapjs/test/messages/unbind_request.test.js

58 lines
948 B
JavaScript
Raw Normal View History

2011-08-04 20:32:01 +00:00
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
var test = require('tap').test;
var asn1 = require('asn1');
///--- Globals
var BerReader = asn1.BerReader;
var BerWriter = asn1.BerWriter;
var UnbindRequest;
///--- Tests
test('load library', function (t) {
2011-08-04 20:32:01 +00:00
UnbindRequest = require('../../lib/index').UnbindRequest;
t.ok(UnbindRequest);
t.end();
});
test('new no args', function (t) {
2011-08-04 20:32:01 +00:00
t.ok(new UnbindRequest());
t.end();
});
test('new with args', function (t) {
2011-08-04 20:32:01 +00:00
var req = new UnbindRequest({});
t.ok(req);
t.end();
});
test('parse', function (t) {
2011-08-04 20:32:01 +00:00
var ber = new BerWriter();
var req = new UnbindRequest();
t.ok(req._parse(new BerReader(ber.buffer)));
t.end();
});
test('toBer', function (t) {
2011-08-04 20:32:01 +00:00
var req = new UnbindRequest({
messageID: 123
});
t.ok(req);
var ber = new BerReader(req.toBer());
t.ok(ber);
t.equal(ber.readSequence(), 0x30);
t.equal(ber.readInt(), 123);
t.end();
});