mirror of
https://github.com/langgenius/dify.git
synced 2026-06-18 07:41:09 +08:00
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: fatelei <fatelei@gmail.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com> Co-authored-by: gigglewang <gigglewang@dify.ai> Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai> Co-authored-by: chariri <w@chariri.moe> Co-authored-by: Evan <2869018789@qq.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { act, renderHook } from '@testing-library/react'
|
|
import { ACCOUNT_SETTING_TAB } from '../constants'
|
|
import { useIntegrationsSetting } from '../use-integrations-setting'
|
|
|
|
const { mockSetShowAccountSettingModal } = vi.hoisted(() => ({
|
|
mockSetShowAccountSettingModal: vi.fn(),
|
|
}))
|
|
|
|
vi.mock('@/context/modal-context', () => ({
|
|
useModalContext: () => ({
|
|
setShowAccountSettingModal: mockSetShowAccountSettingModal,
|
|
}),
|
|
}))
|
|
|
|
describe('useIntegrationsSetting', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
it.each([
|
|
[ACCOUNT_SETTING_TAB.PROVIDER, 'provider'],
|
|
[ACCOUNT_SETTING_TAB.DATA_SOURCE, 'data-source'],
|
|
[ACCOUNT_SETTING_TAB.API_BASED_EXTENSION, 'custom-endpoint'],
|
|
])('should open integrations settings for migrated tab %s', (tab, section) => {
|
|
const { result } = renderHook(() => useIntegrationsSetting())
|
|
|
|
act(() => {
|
|
result.current({ payload: tab })
|
|
})
|
|
|
|
expect(mockSetShowAccountSettingModal).toHaveBeenCalledWith({ payload: section })
|
|
})
|
|
|
|
it('should open integrations settings from a direct section', () => {
|
|
const { result } = renderHook(() => useIntegrationsSetting())
|
|
|
|
act(() => {
|
|
result.current({ section: 'mcp' })
|
|
})
|
|
|
|
expect(mockSetShowAccountSettingModal).toHaveBeenCalledWith({ payload: 'mcp' })
|
|
})
|
|
})
|