Skip to content

Instantly share code, notes, and snippets.

@BoDonkey
Created March 30, 2023 20:55
Show Gist options
  • Save BoDonkey/8dbd7b27f393ceb34877ed41e91d1248 to your computer and use it in GitHub Desktop.
Save BoDonkey/8dbd7b27f393ceb34877ed41e91d1248 to your computer and use it in GitHub Desktop.
test to check if the schema field is forbidden
const t = require('../test-lib/test.js');
const assert = require('assert');
let apos;
const apiKey = 'this is a test api key';
describe('Pieces malformed', function () {
this.timeout(t.timeout);
after(async function () {
return t.destroy(apos);
});
it('should not initialize with a forbidden field schema name', async function () {
const actual = async () => {
apos = await t.create({
root: module,
modules: {
'@apostrophecms/express': {
options: {
apiKeys: {
[apiKey]: {
role: 'admin'
}
}
}
},
malformed: {
extend: '@apostrophecms/piece-type',
fields: {
add: {
type: {
label: 'Type',
type: 'string'
}
}
}
}
}
});
assert(false);
};
const expected = new Error('@apostrophecms/piece-type field property name cannot be "type"');
await assert.rejects(actual, expected);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment