chore: hoists tests out of payload package
This commit is contained in:
1
test/plugins/.gitignore
vendored
Normal file
1
test/plugins/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
media
|
||||
40
test/plugins/config.ts
Normal file
40
test/plugins/config.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { buildConfigWithDefaults } from '../buildConfigWithDefaults'
|
||||
import { devUser } from '../credentials'
|
||||
|
||||
export const pagesSlug = 'pages'
|
||||
|
||||
export default buildConfigWithDefaults({
|
||||
collections: [
|
||||
{
|
||||
slug: 'users',
|
||||
auth: true,
|
||||
fields: [],
|
||||
},
|
||||
],
|
||||
plugins: [
|
||||
async (config) => ({
|
||||
...config,
|
||||
collections: [
|
||||
...(config.collections || []),
|
||||
{
|
||||
slug: pagesSlug,
|
||||
fields: [
|
||||
{
|
||||
name: 'title',
|
||||
type: 'text',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
onInit: async (payload) => {
|
||||
await payload.create({
|
||||
collection: 'users',
|
||||
data: {
|
||||
email: devUser.email,
|
||||
password: devUser.password,
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
0
test/plugins/e2e.todo-spec.ts
Normal file
0
test/plugins/e2e.todo-spec.ts
Normal file
28
test/plugins/int.spec.ts
Normal file
28
test/plugins/int.spec.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import payload from '../../packages/payload/src'
|
||||
import { initPayloadTest } from '../helpers/configHelpers'
|
||||
import { RESTClient } from '../helpers/rest'
|
||||
import configPromise, { pagesSlug } from './config'
|
||||
|
||||
require('isomorphic-fetch')
|
||||
|
||||
let client
|
||||
|
||||
describe('Collections - Plugins', () => {
|
||||
beforeAll(async () => {
|
||||
const { serverURL } = await initPayloadTest({ __dirname, init: { local: false } })
|
||||
const config = await configPromise
|
||||
client = new RESTClient(config, { serverURL, defaultSlug: pagesSlug })
|
||||
await client.login()
|
||||
})
|
||||
|
||||
it('created pages collection', async () => {
|
||||
const { id } = await payload.create({
|
||||
collection: pagesSlug,
|
||||
data: {
|
||||
title: 'Test Page',
|
||||
},
|
||||
})
|
||||
|
||||
expect(id).toEqual(expect.any(String))
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user