mirror of
https://github.com/supabase/supabase.git
synced 2026-05-31 18:03:33 +08:00
* Init custom content hook * Implement useCustomContent hook similarly to useIsFeatureEnabled, and implement extension of organization documents * Attempt to type things nicely * add test --------- Co-authored-by: Jordi Enric <jordi.err@gmail.com>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { renderHook, cleanup } 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' })
|
|
})
|
|
})
|