0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/test/unit/api/shared/serializers/input/all.test.js
Hannah Wolfe 12e8c974a1
Cleaned up weird refs to versions in tests
refs: https://github.com/TryGhost/Toolbox/issues/168

- These are all places where we reference an API version like v2 or v3 but it's not actually
used or relevant.
- The aim is to get rid of all mentions of these old versions to make it clearer that we're only running tests on canary
2022-01-21 15:10:03 +00:00

81 lines
2.7 KiB
JavaScript

const should = require('should');
const shared = require('../../../../../../core/server/api/shared');
describe('Unit: 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);
});
});
});
});