mirror of
https://github.com/toptal/haste-server.git
synced 2024-11-24 06:20:14 -08:00
cb4809195b
* Improve tests This PR adds some necessary tests, fixes the naming on describe (everything was set to RandomKeyGenerator, perhaps a copy/paste exception) and fixes the consonant/vowel alternation test, since it was failing if the keyspace started with a vowel. * Remove unecessary file
35 lines
913 B
JavaScript
35 lines
913 B
JavaScript
/* global describe, it */
|
|
|
|
const assert = require('assert');
|
|
|
|
const fs = require('fs');
|
|
|
|
const Generator = require('../../lib/key_generators/dictionary');
|
|
|
|
describe('DictionaryGenerator', function() {
|
|
describe('options', function() {
|
|
it('should throw an error if given no options', () => {
|
|
assert.throws(() => {
|
|
new Generator();
|
|
}, Error);
|
|
});
|
|
|
|
it('should throw an error if given no path', () => {
|
|
assert.throws(() => {
|
|
new Generator({});
|
|
}, Error);
|
|
});
|
|
});
|
|
describe('generation', function() {
|
|
it('should return a key of the proper number of words from the given dictionary', () => {
|
|
const path = '/tmp/haste-server-test-dictionary';
|
|
const words = ['cat'];
|
|
fs.writeFileSync(path, words.join('\n'));
|
|
|
|
const gen = new Generator({path}, () => {
|
|
assert.equal('catcatcat', gen.createKey(3));
|
|
});
|
|
});
|
|
});
|
|
});
|