-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): update getPreviewPaths function (#5362)
- Loading branch information
1 parent
37cc483
commit bd77e0e
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
packages/sanity/src/core/preview/utils/getPreviewPaths.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {SchemaType} from '@sanity/types' | ||
import {getPreviewPaths} from './getPreviewPaths' | ||
|
||
const preview: SchemaType['preview'] = { | ||
select: { | ||
title: 'name', | ||
awards: 'awards', | ||
role: 'role', | ||
relatedAuthors: 'relatedAuthors', | ||
lastUpdated: '_updatedAt', | ||
media: 'image', | ||
}, | ||
} | ||
|
||
describe('getPreviewPaths', () => { | ||
it('Should return undefined if no selection is provided', () => { | ||
const paths = getPreviewPaths({ | ||
select: undefined, | ||
}) | ||
expect(paths).toBeUndefined() | ||
}) | ||
it('should return the default preview paths', () => { | ||
const paths = getPreviewPaths(preview) | ||
expect(paths).toEqual([ | ||
['name'], | ||
['awards'], | ||
['role'], | ||
['relatedAuthors'], | ||
['_updatedAt'], | ||
['image'], | ||
['_createdAt'], | ||
['_updatedAt'], | ||
]) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters