1
0
Fork 0
mirror of https://github.com/SunRed/haste-server.git synced 2024-11-01 01:30:21 +01:00
haste-server/test/key_generators/dictionary_spec.js

34 lines
816 B
JavaScript
Raw Normal View History

/* global describe, it */
const assert = require('assert');
const fs = require('fs');
const Generator = require('../../lib/key_generators/dictionary');
2020-08-28 04:39:03 +02:00
describe('RandomKeyGenerator', function(){
describe('randomKey', function(){
it('should throw an error if given no options', () => {
assert.throws(() => {
new Generator();
}, Error);
});
2020-08-28 04:39:03 +02:00
it('should throw an error if given no path', () => {
assert.throws(() => {
new Generator({});
}, Error);
});
2020-08-28 04:39:03 +02:00
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'));
2020-08-28 04:39:03 +02:00
const gen = new Generator({path}, () => {
assert.equal('catcatcat', gen.createKey(3));
});
});
});
});