Files
supabase/apps/studio/hooks/custom-content/useCustomContent.test.ts
Charis 180ce515f6 style: require @ imports and sort imports for studio/hooks (#44444)
* **Chores**
* Updated internal module import paths across hook files to use
standardized path aliases for improved code consistency and
maintainability.
2026-04-01 11:48:02 -04:00

37 lines
1.2 KiB
TypeScript

import { cleanup, renderHook } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
beforeEach(() => {
vi.clearAllMocks()
vi.resetModules()
cleanup()
})
describe('useCustomContent', () => {
it('should return null if content is not found in the custom-content.json file', async () => {
vi.doMock('./custom-content.json', () => ({
default: {
'organization:legal_documents': null,
},
}))
const { useCustomContent } = await import('./useCustomContent')
const { result } = renderHook(() => useCustomContent(['organization:legal_documents']))
expect(result.current.organizationLegalDocuments).toEqual(null)
})
it('should return the content for the key passed in if it exists in the custom-content.json file', async () => {
vi.doMock('./custom-content.json', () => ({
default: {
'organization:legal_documents': {
someValue: 'foo',
},
},
}))
const { useCustomContent } = await import('./useCustomContent')
const { result } = renderHook(() => useCustomContent(['organization:legal_documents']))
expect(result.current.organizationLegalDocuments).toEqual({ someValue: 'foo' })
})
})