mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
bb17e1c0e9
closes #1189 - added tests - added request module - added status codes to API calls - fixed return values of API calls - fixed that drafts caused an error when being deleted - fixed X-Invalidate-Cache headers - moved testUtils.js to utils/index.js
26 lines
863 B
JavaScript
26 lines
863 B
JavaScript
var _ = require('underscore'),
|
|
url = require('url'),
|
|
ApiRouteBase = '/ghost/api/v0.1/',
|
|
host = 'localhost',
|
|
port = '2369';
|
|
schema = "http://"
|
|
|
|
function getApiURL (route) {
|
|
var baseURL = url.resolve(schema + host + ':' + port, ApiRouteBase);
|
|
return url.resolve(baseURL, route);
|
|
}
|
|
function getSigninURL () {
|
|
return url.resolve(schema + host + ':' + port, 'ghost/signin/');
|
|
}
|
|
|
|
// make sure the API only returns expected properties only
|
|
function checkResponse (jsonResponse, expectedProperties) {
|
|
Object.keys(jsonResponse).length.should.eql(expectedProperties.length);
|
|
for(var i=0; i<expectedProperties.length; i = i + 1) {
|
|
jsonResponse.should.have.property(expectedProperties[i]);
|
|
}
|
|
}
|
|
|
|
module.exports.getApiURL = getApiURL;
|
|
module.exports.getSigninURL = getSigninURL;
|
|
module.exports.checkResponse = checkResponse;
|