mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 00:18:28 +08:00
test: update useDocumentTitle test
This commit is contained in:
parent
94c64b661e
commit
62de9ae5d9
@ -1,12 +1,20 @@
|
|||||||
import { defaultSystemFeatures } from '@/types/feature'
|
import { defaultSystemFeatures } from '@/types/feature'
|
||||||
import { renderHook } from '@testing-library/react'
|
import { act, renderHook } from '@testing-library/react'
|
||||||
import useDocumentTitle from './use-document-title'
|
import useDocumentTitle from './use-document-title'
|
||||||
|
import { useGlobalPublicStore } from '@/context/global-public-context'
|
||||||
|
|
||||||
jest.mock('@/context/global-public-context', () => ({
|
jest.mock('@/service/common', () => ({
|
||||||
useGlobalPublicStore: jest.fn(() => ({ ...defaultSystemFeatures })),
|
getSystemFeatures: jest.fn(() => ({ ...defaultSystemFeatures })),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
describe('branding.enabled is false', () => {
|
describe('use default branding', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
act(() => {
|
||||||
|
useGlobalPublicStore.setState({
|
||||||
|
systemFeatures: { ...defaultSystemFeatures, branding: { ...defaultSystemFeatures.branding, enabled: false } },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
it('document title should be test-Dify if set title', () => {
|
it('document title should be test-Dify if set title', () => {
|
||||||
renderHook(() => useDocumentTitle('test'))
|
renderHook(() => useDocumentTitle('test'))
|
||||||
expect(document.title).toBe('test - Dify')
|
expect(document.title).toBe('test - Dify')
|
||||||
@ -17,3 +25,22 @@ describe('branding.enabled is false', () => {
|
|||||||
expect(document.title).toBe('Dify')
|
expect(document.title).toBe('Dify')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('use specific branding', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
act(() => {
|
||||||
|
useGlobalPublicStore.setState({
|
||||||
|
systemFeatures: { ...defaultSystemFeatures, branding: { ...defaultSystemFeatures.branding, enabled: true, application_title: 'Test' } },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('document title should be test-Test if set title', () => {
|
||||||
|
renderHook(() => useDocumentTitle('test'))
|
||||||
|
expect(document.title).toBe('test - Test')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('document title should be Test if not set title', () => {
|
||||||
|
renderHook(() => useDocumentTitle(''))
|
||||||
|
expect(document.title).toBe('Test')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user