chore: validation reuses endpoints schema
This commit is contained in:
@@ -8,6 +8,7 @@ export const collectionSlug = 'endpoints';
|
||||
export const globalSlug = 'global-endpoints';
|
||||
|
||||
export const globalEndpoint = 'global';
|
||||
export const applicationEndpoint = 'path';
|
||||
|
||||
export default buildConfig({
|
||||
collections: [
|
||||
@@ -68,6 +69,15 @@ export default buildConfig({
|
||||
fields: [],
|
||||
},
|
||||
],
|
||||
endpoints: [
|
||||
{
|
||||
path: applicationEndpoint,
|
||||
method: 'post',
|
||||
handler: (req: PayloadRequest, res: Response): void => {
|
||||
res.json(req.body);
|
||||
},
|
||||
},
|
||||
],
|
||||
onInit: async (payload) => {
|
||||
await payload.create({
|
||||
collection: 'users',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { initPayloadTest } from '../helpers/configHelpers';
|
||||
import { RESTClient } from '../helpers/rest';
|
||||
import { collectionSlug, globalEndpoint, globalSlug } from './config';
|
||||
import { applicationEndpoint, collectionSlug, globalEndpoint, globalSlug } from './config';
|
||||
|
||||
require('isomorphic-fetch');
|
||||
|
||||
@@ -45,4 +45,14 @@ describe('Endpoints', () => {
|
||||
expect(params).toMatchObject(data);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Application', () => {
|
||||
it('should call custom endpoint', async () => {
|
||||
const params = { app: 'response' };
|
||||
const { status, data } = await client.endpoint(`/${applicationEndpoint}`, 'post', params);
|
||||
|
||||
expect(status).toBe(200);
|
||||
expect(params).toMatchObject(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user