2017-11-01 02:10:25 +01:00
|
|
|
/* global describe, it */
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
const Generator = require('../../lib/key_generators/phonetic');
|
|
|
|
|
|
|
|
const vowels = 'aeiou';
|
|
|
|
const consonants = 'bcdfghjklmnpqrstvwxyz';
|
|
|
|
|
|
|
|
describe('RandomKeyGenerator', () => {
|
2020-08-28 23:57:50 +02:00
|
|
|
describe('randomKey', () => {
|
|
|
|
it('should return a key of the proper length', () => {
|
|
|
|
const gen = new Generator();
|
|
|
|
assert.equal(6, gen.createKey(6).length);
|
|
|
|
});
|
2017-11-01 02:10:25 +01:00
|
|
|
|
2020-08-28 23:57:50 +02:00
|
|
|
it('should alternate consonants and vowels', () => {
|
|
|
|
const gen = new Generator();
|
2017-11-01 02:10:25 +01:00
|
|
|
|
2020-08-28 23:57:50 +02:00
|
|
|
const key = gen.createKey(3);
|
2017-11-01 02:10:25 +01:00
|
|
|
|
2020-08-28 23:57:50 +02:00
|
|
|
assert.ok(consonants.includes(key[0]));
|
|
|
|
assert.ok(consonants.includes(key[2]));
|
|
|
|
assert.ok(vowels.includes(key[1]));
|
|
|
|
});
|
|
|
|
});
|
2017-11-01 02:10:25 +01:00
|
|
|
});
|