Skip to content

Commit

Permalink
test(plugin-flow-builder): create a mock and test for smart intent
Browse files Browse the repository at this point in the history
  • Loading branch information
Iru89 committed May 12, 2024
1 parent 3ac108d commit 9798e31
Show file tree
Hide file tree
Showing 3 changed files with 544 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { jest } from '@jest/globals'

import { SmartIntentsApi } from '../../src/user-input/smart-intent'

export function mockSmartIntent(intentName?: string) {
// Spy on the private function getInference
const getInferenceSpy = jest.spyOn(
SmartIntentsApi.prototype as any,
'getInference'
)

// Change the implementation of getInference
getInferenceSpy.mockImplementation(async () => {
return intentName ? { data: { intent_name: intentName } } : undefined
})
}

0 comments on commit 9798e31

Please sign in to comment.