1
0
Fork 0
mirror of https://github.com/seejohnrun/haste-server.git synced 2024-11-22 12:41:21 +00:00
haste-server/test/key_generators/random_spec.js

25 lines
713 B
JavaScript
Raw Normal View History

/* global describe, it */
const assert = require('assert');
const Generator = require('../../lib/key_generators/random');
2017-11-01 00:55:51 +00:00
describe('RandomKeyGenerator', () => {
describe('generation', () => {
2017-11-01 00:55:51 +00:00
it('should return a key of the proper length', () => {
const gen = new Generator();
assert.equal(gen.createKey(6).length, 6);
});
it('should use a key from the given keyset if given', () => {
2017-11-01 00:55:51 +00:00
const gen = new Generator({keyspace: 'A'});
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'));
});
});
});