-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(core): adapt tests to work with botState model, disabling hando…
…ff tests for 1.0
- Loading branch information
1 parent
3c8aa2c
commit a295c73
Showing
6 changed files
with
277 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,42 @@ | ||
import { PATH_PAYLOAD_IDENTIFIER, PROVIDER, Session } from '../../src' | ||
import { BotState, PATH_PAYLOAD_IDENTIFIER, Session } from '../../src' | ||
|
||
export function testRoute(): any { | ||
return {} | ||
} | ||
|
||
export function testSession(): Session { | ||
return {} | ||
} | ||
|
||
type BotStateAttrs = { | ||
isFirstInteraction?: boolean | ||
lastRoutePath?: string | ||
retries?: number | ||
} | ||
export function testBotState(botStateAttrs?: BotStateAttrs): BotState { | ||
return { | ||
user: { id: 'userid', provider: PROVIDER.DEV }, | ||
bot: { id: 'bot_id' }, | ||
is_first_interaction: true, | ||
__retries: 0, | ||
botId: '1234', | ||
isFirstInteraction: botStateAttrs?.isFirstInteraction | ||
? botStateAttrs?.isFirstInteraction | ||
: true, | ||
isHandoff: false, | ||
isShadowing: false, | ||
lastRoutePath: botStateAttrs?.lastRoutePath ?? null, | ||
locale: undefined, | ||
retries: botStateAttrs?.retries ?? 0, | ||
} | ||
} | ||
|
||
export const botStateWithLastRoutePath = (lastRoutePath: any): BotState => { | ||
return testBotState({ lastRoutePath }) | ||
} | ||
|
||
export const botStateWithLastRoutePathAndRetries = ( | ||
lastRoutePath: any, | ||
retries: number | ||
): BotState => { | ||
return testBotState({ lastRoutePath, retries }) | ||
} | ||
|
||
export const createPathPayload = (pathWithParams: string): string => | ||
`${PATH_PAYLOAD_IDENTIFIER}${pathWithParams}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.