Skip to content

Commit

Permalink
chore(core): add tests for resolve default plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin committed May 6, 2024
1 parent 15803b6 commit e0c3c5e
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions packages/sanity/src/core/config/__tests__/resolveConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {firstValueFrom, lastValueFrom, of} from 'rxjs'
import {bufferTime} from 'rxjs/operators'

import {createMockAuthStore} from '../../store'
import {definePlugin} from '../definePlugin'
import {createSourceFromConfig, createWorkspaceFromConfig, resolveConfig} from '../resolveConfig'

describe('resolveConfig', () => {
Expand Down Expand Up @@ -136,6 +137,59 @@ describe('resolveConfig', () => {
},
])
})

it('includes all the default plugins', async () => {
const projectId = 'ppsg7ml5'
const dataset = 'production'
const client = createClient({
projectId,
apiVersion: '2021-06-07',
dataset,
useCdn: false,
})
const mockPlugin = definePlugin({name: 'sanity/mock-plugin'})
const [workspace] = await firstValueFrom(
resolveConfig({
name: 'default',
dataset,
projectId,
auth: createMockAuthStore({client, currentUser: null}),
plugins: [mockPlugin()],
}),
)
expect(workspace.__internal.options.plugins).toMatchObject([
{name: 'sanity/mock-plugin'},
{name: 'sanity/comments'},
{name: 'sanity/tasks'},
{name: 'sanity/scheduled-publishing'},
])
})

it('wont include scheduled publishing default plugin', async () => {
// Schedule publishing should not be included when none other plugin is included in the user config.
const projectId = 'ppsg7ml5'
const dataset = 'production'
const client = createClient({
projectId,
apiVersion: '2021-06-07',
dataset,
useCdn: false,
})
const [workspace] = await firstValueFrom(
resolveConfig({
name: 'default',
dataset,
projectId,
auth: createMockAuthStore({client, currentUser: null}),
plugins: [], // No plugins
}),
)

expect(workspace.__internal.options.plugins).toMatchObject([
{name: 'sanity/comments'},
{name: 'sanity/tasks'},
])
})
})

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

0 comments on commit e0c3c5e

Please sign in to comment.