mirror of
https://github.com/seejohnrun/haste-server
synced 2025-08-13 09:16:50 -07:00
convert optional fiels to required fields
This commit is contained in:
parent
fa9d3f98e9
commit
9c2f1d24ba
6 changed files with 172 additions and 23 deletions
|
@ -1,18 +1,24 @@
|
|||
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 { Store } from '../../src/types/store'
|
||||
import { Config } from '../../src/types/config'
|
||||
|
||||
const store : Store = createMock<Store>();
|
||||
const config : Config = createMock<Config>();
|
||||
|
||||
describe('document-handler', () => {
|
||||
describe('with randomKey', () => {
|
||||
it('should choose a key of the proper length', () => {
|
||||
const gen = new Generator({ type: 'random' })
|
||||
const dh = new DocumentHandler({ keyLength: 6, keyGenerator: gen})
|
||||
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 })
|
||||
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