Commit ea949ba5 authored by Ray Bellis's avatar Ray Bellis

more vendors fixes and unit tests

parent dd855a69
......@@ -287,7 +287,10 @@ function vendor(id)
// create default Vendor object if not found
if (!vendors.has(id)) {
vendors.set(id, new Vendor(vendor_id, `Vendor${vendor_id}`));
const name = `Vendor${id}`;
const v = new Vendor(name, id);
vendors.set(id, v);
vendors.set(name.toLowerCase(), v);
}
return vendors.get(id);
......
......@@ -2,6 +2,7 @@ const assert = require('assert').strict;
const Dictionary = require('../lib/dictionary.js');
Dictionary.load(__dirname + '/dictionary/dictionary.rfc2865');
Dictionary.load(__dirname + '/dictionary/dictionary.lucent');
describe('Dictionary', () => {
describe('get', () => {
......@@ -49,12 +50,25 @@ describe('Dictionary', () => {
assert.throws(() => Dictionary.vendor({}), TypeError);
assert.throws(() => Dictionary.vendor(() => {}, TypeError));
});
it('should return expected values for a known Vendor', () => {
let v = Dictionary.vendor(4846);
assert.equal(v.name, 'Lucent');
assert.equal(v.typeSize, 2);
assert.equal(v.lengthSize, 1);
});
it('should return expected values for an unknown Vendor', () => {
let v = Dictionary.vendor(100);
assert.equal(v.name, 'Vendor100');
assert.equal(v.id, 100);
assert.equal(v.typeSize, 1);
assert.equal(v.lengthSize, 1);
});
});
describe('vsa', () => {
Dictionary.load(__dirname + '/dictionary/dictionary.lucent');
it('should throw if a VSA lookup uses the wrong type for parameter 1', () => {
assert.throws(() => Dictionary.vsa(undefined, 1), TypeError);
assert.throws(() => Dictionary.vsa('', 1), TypeError);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment