mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
7f1d3ebc07
- move all test files from core/test to test/ - updated all imports and other references - all code inside of core/ is then application code - tests are correctly at the root level - consistent with other repos/projects Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
64 lines
2.2 KiB
JavaScript
64 lines
2.2 KiB
JavaScript
const should = require('should');
|
|
const shared = require('../../../../core/server/api/shared');
|
|
|
|
describe('Unit: api/shared/headers', function () {
|
|
it('empty headers config', function () {
|
|
return shared.headers.get().then((result) => {
|
|
result.should.eql({});
|
|
});
|
|
});
|
|
|
|
describe('config.disposition', function () {
|
|
it('json', function () {
|
|
return shared.headers.get({}, {disposition: {type: 'json', value: 'value'}})
|
|
.then((result) => {
|
|
result.should.eql({
|
|
'Content-Disposition': 'Attachment; filename=\"value\"',
|
|
'Content-Type': 'application/json',
|
|
'Content-Length': 2
|
|
});
|
|
});
|
|
});
|
|
|
|
it('csv', function () {
|
|
return shared.headers.get({}, {disposition: {type: 'csv', value: 'my.csv'}})
|
|
.then((result) => {
|
|
result.should.eql({
|
|
'Content-Disposition': 'Attachment; filename=\"my.csv\"',
|
|
'Content-Type': 'text/csv'
|
|
});
|
|
});
|
|
});
|
|
|
|
it('yaml', function () {
|
|
return shared.headers.get('yaml file', {disposition: {type: 'yaml', value: 'my.yaml'}})
|
|
.then((result) => {
|
|
result.should.eql({
|
|
'Content-Disposition': 'Attachment; filename=\"my.yaml\"',
|
|
'Content-Type': 'application/yaml',
|
|
'Content-Length': 11
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('config.cacheInvalidate', function () {
|
|
it('default', function () {
|
|
return shared.headers.get({}, {cacheInvalidate: true})
|
|
.then((result) => {
|
|
result.should.eql({
|
|
'X-Cache-Invalidate': '/*'
|
|
});
|
|
});
|
|
});
|
|
|
|
it('custom value', function () {
|
|
return shared.headers.get({}, {cacheInvalidate: {value: 'value'}})
|
|
.then((result) => {
|
|
result.should.eql({
|
|
'X-Cache-Invalidate': 'value'
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|