Skip to content

Commit

Permalink
test(structure): fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge committed Nov 15, 2024
1 parent 92bf40a commit dae4e00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/sanity/src/core/releases/hooks/usePerspective.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {useCallback, useMemo} from 'react'
import {useRouter} from 'sanity/router'

import {resolveBundlePerspective} from '../../util/resolvePerspective'
import {useReleases} from '../store'
import {type ReleaseDocument} from '../store/types'
import {useReleases} from '../store/useReleases'
import {LATEST} from '../util/const'
import {getBundleIdFromReleaseDocumentId} from '../util/getBundleIdFromReleaseDocumentId'
import {isPublishedPerspective} from '../util/util'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import {
type SanityClient,
unstable_useValuePreview as useValuePreview,
useDocumentVersions,
useReleases,
} from 'sanity'
import {useRouter} from 'sanity/router'
import {beforeEach, describe, expect, it, type Mock, type MockedFunction, vi} from 'vitest'
import {beforeEach, describe, expect, it, type MockedFunction, vi} from 'vitest'

import {createMockSanityClient} from '../../../../../../../../test/mocks/mockSanityClient'
import {createTestProvider} from '../../../../../../../../test/testUtils/TestProvider'
Expand All @@ -16,6 +15,8 @@ import {type DocumentPaneContextValue} from '../../../../DocumentPaneContext'
import {useDocumentPane} from '../../../../useDocumentPane'
import {DocumentHeaderTitle} from '../../DocumentHeaderTitle'

const mockUseReleases = vi.fn()

function createWrapperComponent(client: SanityClient) {
const config = defineConfig({
projectId: 'test',
Expand All @@ -29,21 +30,21 @@ function createWrapperComponent(client: SanityClient) {
})
}

vi.mock('../../../../../core/releases/store/useReleases', () => mockUseReleases)

vi.mock('../../../../useDocumentPane')

vi.mock('sanity', async (importOriginal) => {
return {
...(await importOriginal()),
unstable_useValuePreview: vi.fn(),
useDocumentVersions: vi.fn(),
useReleases: vi.fn(),
usePerspective: vi.fn(() => ({perspective: undefined})),
}
})

vi.mock('sanity/router')

const mockUseReleases = useReleases as Mock<typeof useReleases>
const mockUseDocumentVersions = useDocumentVersions as MockedFunction<typeof useDocumentVersions>

describe('DocumentHeaderTitle', () => {
Expand Down

0 comments on commit dae4e00

Please sign in to comment.