2017-11-01 02:10:25 +01:00
|
|
|
/* global describe, it */
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const Generator = require('../../lib/key_generators/phonetic');
|
|
|
|
|
2020-09-23 01:07:32 +02:00
|
|
|
describe('KeyGenerator', () => {
|
|
|
|
describe('phonetic', () => {
|
2020-08-28 23:57:50 +02:00
|
|
|
it('should return a key of the proper length', () => {
|
|
|
|
const gen = new Generator();
|
2020-09-23 01:07:32 +02:00
|
|
|
assert.strictEqual(6, gen.createKey(6).length);
|
2020-08-28 23:57:50 +02:00
|
|
|
});
|
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-09-23 01:07:32 +02:00
|
|
|
const vowels = 'aeiouy';
|
2020-08-28 23:57:50 +02:00
|
|
|
const key = gen.createKey(3);
|
2017-11-01 02:10:25 +01:00
|
|
|
|
2020-09-23 01:07:32 +02:00
|
|
|
if (vowels.includes(key[0])) assert.ok(vowels.includes(key[2]));
|
|
|
|
else assert.ok(vowels.includes(key[1]));
|
2020-08-28 23:57:50 +02:00
|
|
|
});
|
|
|
|
});
|
2017-11-01 02:10:25 +01:00
|
|
|
});
|