mirror of
https://github.com/strapi/strapi.git
synced 2025-09-01 21:03:02 +00:00
remi feedback
This commit is contained in:
parent
5616903ac8
commit
acd8b1a7c8
@ -1,12 +1,16 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const _ = require('lodash');
|
||||||
const buildComponentSchema = require('../server/services/helpers/build-component-schema');
|
const buildComponentSchema = require('../server/services/helpers/build-component-schema');
|
||||||
const strapi = require('../__mocks__/strapi');
|
const strapi = require('../__mocks__/strapi');
|
||||||
|
|
||||||
describe('Build Component Schema', () => {
|
describe('Build Component Schema', () => {
|
||||||
it('builds the Response schema', () => {
|
beforeEach(() => {
|
||||||
global.strapi = strapi;
|
// Reset the mocked strapi instance
|
||||||
|
global.strapi = _.cloneDeep(strapi);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('builds the Response schema', () => {
|
||||||
const apiMocks = [
|
const apiMocks = [
|
||||||
{
|
{
|
||||||
name: 'users-permissions',
|
name: 'users-permissions',
|
||||||
@ -16,7 +20,7 @@ describe('Build Component Schema', () => {
|
|||||||
{ name: 'restaurant', getter: 'api', ctNames: ['restaurant'] },
|
{ name: 'restaurant', getter: 'api', ctNames: ['restaurant'] },
|
||||||
];
|
];
|
||||||
|
|
||||||
let schemas;
|
let schemas = {};
|
||||||
for (const mock of apiMocks) {
|
for (const mock of apiMocks) {
|
||||||
schemas = {
|
schemas = {
|
||||||
...schemas,
|
...schemas,
|
||||||
@ -49,25 +53,12 @@ describe('Build Component Schema', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('builds the ResponseList schema', () => {
|
it('builds the ResponseList schema', () => {
|
||||||
global.strapi = {
|
global.strapi.plugins['users-permissions'].routes['content-api'].routes = [
|
||||||
...strapi,
|
{ method: 'GET', path: '/test', handler: 'test.find' },
|
||||||
plugins: {
|
];
|
||||||
'users-permissions': {
|
global.strapi.api.restaurant.routes.restaurant.routes = [
|
||||||
...strapi.plugins['users-permissions'],
|
{ method: 'GET', path: '/test', handler: 'test.find' },
|
||||||
routes: {
|
];
|
||||||
'content-api': { routes: [{ method: 'GET', path: '/test', handler: 'test.find' }] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
api: {
|
|
||||||
restaurant: {
|
|
||||||
...strapi.api.restaurant,
|
|
||||||
routes: {
|
|
||||||
restaurant: { routes: [{ method: 'GET', path: '/test', handler: 'test.find' }] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const apiMocks = [
|
const apiMocks = [
|
||||||
{
|
{
|
||||||
@ -78,7 +69,7 @@ describe('Build Component Schema', () => {
|
|||||||
{ name: 'restaurant', getter: 'api', ctNames: ['restaurant'] },
|
{ name: 'restaurant', getter: 'api', ctNames: ['restaurant'] },
|
||||||
];
|
];
|
||||||
|
|
||||||
let schemas;
|
let schemas = {};
|
||||||
for (const mock of apiMocks) {
|
for (const mock of apiMocks) {
|
||||||
schemas = {
|
schemas = {
|
||||||
...schemas,
|
...schemas,
|
||||||
@ -126,25 +117,12 @@ describe('Build Component Schema', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('builds the Request schema', () => {
|
it('builds the Request schema', () => {
|
||||||
global.strapi = {
|
global.strapi.plugins['users-permissions'].routes['content-api'].routes = [
|
||||||
...strapi,
|
{ method: 'POST', path: '/test', handler: 'test.create' },
|
||||||
plugins: {
|
];
|
||||||
'users-permissions': {
|
global.strapi.api.restaurant.routes.restaurant.routes = [
|
||||||
...strapi.plugins['users-permissions'],
|
{ method: 'POST', path: '/test', handler: 'test.create' },
|
||||||
routes: {
|
];
|
||||||
'content-api': { routes: [{ method: 'POST', path: '/test', handler: 'test.create' }] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
api: {
|
|
||||||
restaurant: {
|
|
||||||
...strapi.api.restaurant,
|
|
||||||
routes: {
|
|
||||||
restaurant: { routes: [{ method: 'POST', path: '/test', handler: 'test.create' }] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const apiMocks = [
|
const apiMocks = [
|
||||||
{
|
{
|
||||||
@ -155,7 +133,7 @@ describe('Build Component Schema', () => {
|
|||||||
{ name: 'restaurant', getter: 'api', ctNames: ['restaurant'] },
|
{ name: 'restaurant', getter: 'api', ctNames: ['restaurant'] },
|
||||||
];
|
];
|
||||||
|
|
||||||
let schemas;
|
let schemas = {};
|
||||||
for (const mock of apiMocks) {
|
for (const mock of apiMocks) {
|
||||||
schemas = {
|
schemas = {
|
||||||
...schemas,
|
...schemas,
|
||||||
@ -185,25 +163,12 @@ describe('Build Component Schema', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('builds the LocalizationResponse schema', () => {
|
it('builds the LocalizationResponse schema', () => {
|
||||||
global.strapi = {
|
global.strapi.plugins['users-permissions'].routes['content-api'].routes = [
|
||||||
...strapi,
|
{ method: 'GET', path: '/localizations', handler: 'test' },
|
||||||
plugins: {
|
];
|
||||||
'users-permissions': {
|
global.strapi.api.restaurant.routes.restaurant.routes = [
|
||||||
...strapi.plugins['users-permissions'],
|
{ method: 'GET', path: '/localizations', handler: 'test' },
|
||||||
routes: {
|
];
|
||||||
'content-api': { routes: [{ method: 'GET', path: '/localizations', handler: 'test' }] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
api: {
|
|
||||||
restaurant: {
|
|
||||||
...strapi.api.restaurant,
|
|
||||||
routes: {
|
|
||||||
restaurant: { routes: [{ method: 'GET', path: '/localizations', handler: 'test' }] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const apiMocks = [
|
const apiMocks = [
|
||||||
{
|
{
|
||||||
@ -214,7 +179,7 @@ describe('Build Component Schema', () => {
|
|||||||
{ name: 'restaurant', getter: 'api', ctNames: ['restaurant'] },
|
{ name: 'restaurant', getter: 'api', ctNames: ['restaurant'] },
|
||||||
];
|
];
|
||||||
|
|
||||||
let schemas;
|
let schemas = {};
|
||||||
for (const mock of apiMocks) {
|
for (const mock of apiMocks) {
|
||||||
schemas = {
|
schemas = {
|
||||||
...schemas,
|
...schemas,
|
||||||
@ -242,27 +207,12 @@ describe('Build Component Schema', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('builds the LocalizationRequest schema', () => {
|
it('builds the LocalizationRequest schema', () => {
|
||||||
global.strapi = {
|
global.strapi.plugins['users-permissions'].routes['content-api'].routes = [
|
||||||
...strapi,
|
{ method: 'POST', path: '/localizations', handler: 'test' },
|
||||||
plugins: {
|
];
|
||||||
'users-permissions': {
|
global.strapi.api.restaurant.routes.restaurant.routes = [
|
||||||
...strapi.plugins['users-permissions'],
|
{ method: 'POST', path: '/localizations', handler: 'test' },
|
||||||
routes: {
|
];
|
||||||
'content-api': {
|
|
||||||
routes: [{ method: 'POST', path: '/localizations', handler: 'test' }],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
api: {
|
|
||||||
restaurant: {
|
|
||||||
...strapi.api.restaurant,
|
|
||||||
routes: {
|
|
||||||
restaurant: { routes: [{ method: 'POST', path: '/localizations', handler: 'test' }] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const apiMocks = [
|
const apiMocks = [
|
||||||
{
|
{
|
||||||
@ -273,7 +223,7 @@ describe('Build Component Schema', () => {
|
|||||||
{ name: 'restaurant', getter: 'api', ctNames: ['restaurant'] },
|
{ name: 'restaurant', getter: 'api', ctNames: ['restaurant'] },
|
||||||
];
|
];
|
||||||
|
|
||||||
let schemas;
|
let schemas = {};
|
||||||
for (const mock of apiMocks) {
|
for (const mock of apiMocks) {
|
||||||
schemas = {
|
schemas = {
|
||||||
...schemas,
|
...schemas,
|
||||||
@ -298,7 +248,6 @@ describe('Build Component Schema', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('creates the correct name given multiple content types', () => {
|
it('creates the correct name given multiple content types', () => {
|
||||||
global.strapi = strapi;
|
|
||||||
const apiMock = {
|
const apiMock = {
|
||||||
name: 'users-permissions',
|
name: 'users-permissions',
|
||||||
getter: 'plugin',
|
getter: 'plugin',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user