refactor(hooks): reduce null types (#3111)

(cherry picked from commit 8b5d997322)
This commit is contained in:
Alex Yang
2023-07-09 13:01:09 +08:00
parent fdffac6911
commit 0ddbe89d88
8 changed files with 31 additions and 58 deletions
+1 -13
View File
@@ -3,14 +3,13 @@
*/
import 'fake-indexeddb/auto';
import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant';
import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
import { assertExists } from '@blocksuite/global/utils';
import type { Page } from '@blocksuite/store';
import { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
import { renderHook } from '@testing-library/react';
import { useAtomValue } from 'jotai';
import { describe, expect, test, vitest } from 'vitest';
import { describe, expect, test } from 'vitest';
import { beforeEach } from 'vitest';
import { useBlockSuitePagePreview } from '../use-block-suite-page-preview';
@@ -52,17 +51,6 @@ describe('useBlockSuiteWorkspaceName', () => {
workspaceNameHook.result.current[1]('test 3');
expect(blockSuiteWorkspace.meta.name).toBe('test 3');
});
test('null', () => {
const workspaceNameHook = renderHook(() =>
useBlockSuiteWorkspaceName(null)
);
vitest.spyOn(globalThis.console, 'warn');
expect(workspaceNameHook.result.current[0]).toBe(UNTITLED_WORKSPACE_NAME);
workspaceNameHook.result.current[1]('test');
expect(globalThis.console.warn).toHaveBeenCalledTimes(2);
expect(workspaceNameHook.result.current[0]).toBe(UNTITLED_WORKSPACE_NAME);
});
});
describe('useBlockSuiteWorkspacePageTitle', () => {