diff --git a/app/client/src/ce/hooks/hooks.test.ts b/app/client/src/ce/hooks/hooks.test.ts new file mode 100644 index 0000000000..8259537e9d --- /dev/null +++ b/app/client/src/ce/hooks/hooks.test.ts @@ -0,0 +1,25 @@ +import { useEditorType, EditorNames } from "./index"; +import { + BUILDER_VIEWER_PATH_PREFIX, + BUILDER_BASE_PATH_DEPRECATED, +} from "constants/routes"; + +describe("useEditorType", () => { + it('should return "app" for BUILDER_VIEWER_PATH_PREFIX', () => { + const result = useEditorType(BUILDER_VIEWER_PATH_PREFIX); + + expect(result).toBe(EditorNames.APPLICATION); + }); + + it('should return "app" for BUILDER_BASE_PATH_DEPRECATED', () => { + const result = useEditorType(BUILDER_BASE_PATH_DEPRECATED); + + expect(result).toBe(EditorNames.APPLICATION); + }); + + it('should default to "app" for unmatched paths', () => { + const result = useEditorType("/some-random-path"); + + expect(result).toBe(EditorNames.APPLICATION); + }); +}); diff --git a/app/client/src/ce/hooks/index.ts b/app/client/src/ce/hooks/index.ts index 2112914bd3..cd84f5ca1d 100644 --- a/app/client/src/ce/hooks/index.ts +++ b/app/client/src/ce/hooks/index.ts @@ -15,6 +15,7 @@ export interface EditorType { export const editorType: EditorType = { [BUILDER_VIEWER_PATH_PREFIX]: EditorNames.APPLICATION, + [BUILDER_BASE_PATH_DEPRECATED]: EditorNames.APPLICATION, }; export const useEditorType = (path: string) => {