mirror of
https://github.com/strapi/strapi.git
synced 2026-01-09 05:41:03 +00:00
Fix test, add missing global
Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
parent
7e41e28bf8
commit
a0c87af098
@ -1,6 +1,23 @@
|
||||
const { validateKind, validateUpdateContentTypeInput } = require('../content-type');
|
||||
|
||||
describe('Content type validator', () => {
|
||||
global.strapi = {
|
||||
plugins: {
|
||||
'content-type-builder': {
|
||||
services: {
|
||||
builder: {
|
||||
getReservedNames() {
|
||||
return {
|
||||
models: [],
|
||||
attributes: ['thisIsReserved'],
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
describe('validateKind', () => {
|
||||
it('Only allows for single and collection types', async () => {
|
||||
await expect(validateKind('wrong')).rejects.toBeDefined();
|
||||
@ -16,6 +33,30 @@ describe('Content type validator', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Prevents use of reservedNames', () => {
|
||||
test('Throws when resverd names are used', async () => {
|
||||
const data = {
|
||||
contentType: {
|
||||
name: 'test',
|
||||
attributes: {
|
||||
thisIsReserved: {
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
await validateUpdateContentTypeInput(data).catch(err => {
|
||||
expect(err).toMatchObject({
|
||||
'contentType.attributes.thisIsReserved': [
|
||||
expect.stringMatching('Attribute keys cannot be one of'),
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateUpdateContentTypeInput', () => {
|
||||
test('Deletes empty defaults', async () => {
|
||||
const data = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user