mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 02:41:50 +03:00
f08a55c21f
refs: https://github.com/TryGhost/Team/issues/856 refs: https://github.com/TryGhost/Team/issues/756 - The .test.js extension is better than _spec.js as it's more obvious that it's an extension - It also meaans we can use the --extension parameter in mocha, which should result in a better default behaviour for `yarn test` - It also highlights that some of our tests were named incorrectly and were not (and still will not be) run (see https://github.com/TryGhost/Team/issues/856) - Note: even with this change, `yarn test` is throwing errors, I believe because of this issue https://github.com/TryGhost/Team/issues/756
82 lines
2.7 KiB
JavaScript
82 lines
2.7 KiB
JavaScript
const should = require('should');
|
|
const shared = require('../../../../../../core/server/api/shared');
|
|
|
|
describe('Unit: v2/utils/serializers/input/all', function () {
|
|
describe('all', function () {
|
|
it('transforms into model readable format', function () {
|
|
const apiConfig = {};
|
|
const frame = {
|
|
original: {
|
|
include: 'tags',
|
|
fields: 'id,status',
|
|
formats: 'html'
|
|
},
|
|
options: {
|
|
include: 'tags',
|
|
fields: 'id,status',
|
|
formats: 'html',
|
|
context: {}
|
|
}
|
|
};
|
|
|
|
shared.serializers.input.all.all(apiConfig, frame);
|
|
|
|
should.exist(frame.original.include);
|
|
should.exist(frame.original.fields);
|
|
should.exist(frame.original.formats);
|
|
|
|
should.not.exist(frame.options.include);
|
|
should.not.exist(frame.options.fields);
|
|
should.exist(frame.options.formats);
|
|
should.exist(frame.options.columns);
|
|
should.exist(frame.options.withRelated);
|
|
|
|
frame.options.withRelated.should.eql(['tags']);
|
|
frame.options.columns.should.eql(['id','status','html']);
|
|
frame.options.formats.should.eql(['html']);
|
|
});
|
|
|
|
describe('extra allowed internal options', function () {
|
|
it('internal access', function () {
|
|
const frame = {
|
|
options: {
|
|
context: {
|
|
internal: true
|
|
},
|
|
transacting: true,
|
|
forUpdate: true
|
|
}
|
|
};
|
|
|
|
const apiConfig = {};
|
|
|
|
shared.serializers.input.all.all(apiConfig, frame);
|
|
|
|
should.exist(frame.options.transacting);
|
|
should.exist(frame.options.forUpdate);
|
|
should.exist(frame.options.context);
|
|
});
|
|
|
|
it('no internal access', function () {
|
|
const frame = {
|
|
options: {
|
|
context: {
|
|
user: true
|
|
},
|
|
transacting: true,
|
|
forUpdate: true
|
|
}
|
|
};
|
|
|
|
const apiConfig = {};
|
|
|
|
shared.serializers.input.all.all(apiConfig, frame);
|
|
|
|
should.not.exist(frame.options.transacting);
|
|
should.not.exist(frame.options.forUpdate);
|
|
should.exist(frame.options.context);
|
|
});
|
|
});
|
|
});
|
|
});
|