1
0
Fork 0
mirror of https://github.com/seejohnrun/haste-server.git synced 2024-11-01 19:41:21 +00:00
haste-server/test/key-generators/random.test.ts

21 lines
698 B
TypeScript
Raw Normal View History

2022-06-06 17:38:20 +00:00
import Generator from 'src/lib/key-generators/random'
2022-05-27 13:04:54 +00:00
describe('RandomKeyGenerator', () => {
describe('generation', () => {
it('should return a key of the proper length', () => {
const gen = new Generator({ type: 'random' })
expect(gen.createKey(6).length).toEqual(6)
})
it('should use a key from the given keyset if given', () => {
const gen = new Generator({ type: 'random', keyspace: 'A' })
expect(gen.createKey(6)).toEqual('AAAAAA')
})
it('should not use a key from the given keyset if not given', () => {
const gen = new Generator({ type: 'random', keyspace: 'A' })
expect(gen.createKey(6).includes('B')).toBeFalsy()
})
})
})