2017-11-01 01:40:43 +01:00
|
|
|
/* global describe, it */
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
const Generator = require('../../lib/key_generators/random');
|
|
|
|
|
2017-11-01 01:55:51 +01:00
|
|
|
describe('RandomKeyGenerator', () => {
|
2022-02-14 18:59:14 +01:00
|
|
|
describe('generation', () => {
|
2017-11-01 01:55:51 +01:00
|
|
|
it('should return a key of the proper length', () => {
|
|
|
|
const gen = new Generator();
|
2022-02-14 18:59:14 +01:00
|
|
|
assert.equal(gen.createKey(6).length, 6);
|
2017-11-01 01:40:43 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should use a key from the given keyset if given', () => {
|
2017-11-01 01:55:51 +01:00
|
|
|
const gen = new Generator({keyspace: 'A'});
|
2022-02-14 18:59:14 +01:00
|
|
|
assert.equal(gen.createKey(6), 'AAAAAA');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not use a key from the given keyset if not given', () => {
|
|
|
|
const gen = new Generator({keyspace: 'A'});
|
|
|
|
assert.ok(!gen.createKey(6).includes('B'));
|
2017-11-01 01:40:43 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|