Skip to content

Commit

Permalink
Merge branch 'revert-55-renovate/major-typescript-eslint-monorepo'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidetaka Okamoto committed Jun 27, 2020
2 parents cb27323 + 9ea239c commit f469a8a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/test/libs/wrappers/handlerInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,33 @@ import {
} from '../request'
import { SessionEndedRequestFactory } from '../request/SessionEndRequest'
import { SessionResumedRequestFactory } from '../request/SessionResumedRequest'
import { MockPersistenceAdapter } from '../adaptors'

export class HandlerInputCreator {
private locale: string
private _enablePersistenceAdapter: boolean = false

public constructor (locale: string = 'en-US') {
this.locale = locale
}

public withPersistenceAdapterMock (enable: boolean = true) {
this._enablePersistenceAdapter = enable
return this
}

private _setPersistenceAdapter (factory: HandlerInputFactory): HandlerInputFactory {
if (this._enablePersistenceAdapter === true) {
factory.setPersistanceAdapter(new MockPersistenceAdapter())
}
return factory
}

private create<T extends RequestFactory = RequestFactory> (request: T): HandlerInput {
const factory = new HandlerInputFactory(
new RequestEnvelopeFactory<T>(request)
)
return factory.create()
return this._setPersistenceAdapter(factory).create()
}

public changeLocale (locale: string): this {
Expand Down

0 comments on commit f469a8a

Please sign in to comment.