mirror of
https://github.com/seejohnrun/haste-server
synced 2025-07-31 09:20:05 -07:00
fix code, readme and lint
This commit is contained in:
parent
42c60c64c2
commit
350abbdf3b
14 changed files with 158 additions and 153 deletions
|
@ -1,25 +1,35 @@
|
|||
import { createMock } from 'ts-auto-mock';
|
||||
import { createMock } from 'ts-auto-mock'
|
||||
import DocumentHandler from 'src/lib/document-handler/index'
|
||||
import Generator from 'src/lib/key-generators/random'
|
||||
import constants from 'src/constants'
|
||||
import { Config } from 'src/types/config'
|
||||
import { Store } from 'src/lib/document-stores';
|
||||
import { Store } from 'src/lib/document-stores'
|
||||
|
||||
const store : Store = createMock<Store>();
|
||||
const config : Config = createMock<Config>();
|
||||
const store: Store = createMock<Store>()
|
||||
const config: Config = createMock<Config>()
|
||||
|
||||
describe('document-handler', () => {
|
||||
describe('with random key', () => {
|
||||
it('should choose a key of the proper length', () => {
|
||||
const gen = new Generator({ type: 'random' })
|
||||
const dh = new DocumentHandler({ keyLength: 6, keyGenerator: gen, store, config})
|
||||
expect(dh.acceptableKey()?.length).toEqual(6);
|
||||
const dh = new DocumentHandler({
|
||||
keyLength: 6,
|
||||
keyGenerator: gen,
|
||||
store,
|
||||
config
|
||||
})
|
||||
expect(dh.acceptableKey()?.length).toEqual(6)
|
||||
})
|
||||
|
||||
it('should choose a default key length', () => {
|
||||
const gen = new Generator({ type: 'random' })
|
||||
const dh = new DocumentHandler({ keyGenerator: gen, maxLength: 1, store, config })
|
||||
expect(dh.keyLength).toEqual(constants.DEFAULT_KEY_LENGTH);
|
||||
const dh = new DocumentHandler({
|
||||
keyGenerator: gen,
|
||||
maxLength: 1,
|
||||
store,
|
||||
config
|
||||
})
|
||||
expect(dh.keyLength).toEqual(constants.DEFAULT_KEY_LENGTH)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue