From 221be98e8cfe83a78b8f2078f13459c9dcd5ba14 Mon Sep 17 00:00:00 2001 From: NFish Date: Fri, 16 May 2025 11:01:17 +0800 Subject: [PATCH] fix: test run failed --- web/hooks/use-document-title.spec.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/web/hooks/use-document-title.spec.ts b/web/hooks/use-document-title.spec.ts index 6359458d56..88239ffbdf 100644 --- a/web/hooks/use-document-title.spec.ts +++ b/web/hooks/use-document-title.spec.ts @@ -7,10 +7,28 @@ jest.mock('@/service/common', () => ({ getSystemFeatures: jest.fn(() => ({ ...defaultSystemFeatures })), })) +describe('title should be empty if systemFeatures is pending', () => { + act(() => { + useGlobalPublicStore.setState({ + systemFeatures: { ...defaultSystemFeatures, branding: { ...defaultSystemFeatures.branding, enabled: false } }, + isPending: true, + }) + }) + it('document title should be empty if set title', () => { + renderHook(() => useDocumentTitle('test')) + expect(document.title).toBe('') + }) + it('document title should be empty if not set title', () => { + renderHook(() => useDocumentTitle('')) + expect(document.title).toBe('') + }) +}) + describe('use default branding', () => { beforeEach(() => { act(() => { useGlobalPublicStore.setState({ + isPending: false, systemFeatures: { ...defaultSystemFeatures, branding: { ...defaultSystemFeatures.branding, enabled: false } }, }) }) @@ -30,6 +48,7 @@ describe('use specific branding', () => { beforeEach(() => { act(() => { useGlobalPublicStore.setState({ + isPending: false, systemFeatures: { ...defaultSystemFeatures, branding: { ...defaultSystemFeatures.branding, enabled: true, application_title: 'Test' } }, }) })