1
0
mirror of https://github.com/seejohnrun/haste-server.git synced 2026-02-10 16:01:32 +00:00

Add tests and fix docker files

This commit is contained in:
Yusuf Yilmaz
2022-05-27 15:04:54 +02:00
parent 9f45927593
commit f527b13535
30 changed files with 2126 additions and 4468 deletions
+24
View File
@@ -0,0 +1,24 @@
import Generator from '../../src/lib/key-generators/dictionary'
jest.mock('fs', () => ({
readFile: jest.fn().mockImplementation((_, a, callback) =>
callback(null, 'cat'),
)
}))
describe('DictionaryGenerator', () => {
describe('options', () => {
it('should throw an error if given no options or path', () => {
expect(() => new Generator({ type: '' })).toThrow()
})
})
describe('generation', () => {
it('should return a key of the proper number of words from the given dictionary', () => {
const path = '/tmp/haste-server-test-dictionary'
const gen = new Generator({ path, type: '' })
expect(gen.createKey(3)).toEqual('catcatcat')
})
})
})