2016-08-17 18:14:33 +03:00
|
|
|
import mockAuthentication from './config/authentication';
|
2016-10-28 16:07:50 +03:00
|
|
|
import mockConfiguration from './config/configuration';
|
2016-09-26 19:03:53 +03:00
|
|
|
import mockInvites from './config/invites';
|
2016-08-17 18:14:33 +03:00
|
|
|
import mockPosts from './config/posts';
|
|
|
|
import mockRoles from './config/roles';
|
|
|
|
import mockSettings from './config/settings';
|
|
|
|
import mockSlugs from './config/slugs';
|
|
|
|
import mockSubscribers from './config/subscribers';
|
|
|
|
import mockTags from './config/tags';
|
2016-08-17 18:01:46 +03:00
|
|
|
import mockThemes from './config/themes';
|
2016-08-17 18:14:33 +03:00
|
|
|
import mockUsers from './config/users';
|
2015-10-13 16:52:41 +03:00
|
|
|
|
2016-08-17 18:14:33 +03:00
|
|
|
// import {versionMismatchResponse} from 'utils';
|
2016-04-15 17:45:50 +03:00
|
|
|
|
2015-10-13 16:52:41 +03:00
|
|
|
export default function () {
|
|
|
|
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
|
2016-07-31 22:47:19 +03:00
|
|
|
this.namespace = '/ghost/api/v0.1'; // make this `api`, for example, if your API is namespaced
|
2016-04-15 17:45:50 +03:00
|
|
|
this.timing = 400; // delay for each request, automatically set to 0 during testing
|
2015-10-13 16:52:41 +03:00
|
|
|
|
2016-09-24 18:48:06 +03:00
|
|
|
// Mock endpoints here to override real API requests during development, eg...
|
2016-06-30 17:45:02 +03:00
|
|
|
// this.put('/posts/:id/', versionMismatchResponse);
|
2016-09-24 18:48:06 +03:00
|
|
|
// mockTags(this);
|
|
|
|
// this.loadFixtures('settings');
|
2016-04-13 12:44:09 +03:00
|
|
|
|
|
|
|
// keep this line, it allows all other API requests to hit the real server
|
|
|
|
this.passthrough();
|
|
|
|
|
|
|
|
// add any external domains to make sure those get passed through too
|
|
|
|
this.passthrough('https://count.ghost.org/');
|
|
|
|
this.passthrough('http://www.gravatar.com/**');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mock all endpoints here as there is no real API during testing
|
|
|
|
export function testConfig() {
|
2017-01-10 02:00:12 +03:00
|
|
|
this.passthrough('/write-coverage'); // For code coverage
|
2016-04-13 12:44:09 +03:00
|
|
|
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
|
2016-07-31 22:47:19 +03:00
|
|
|
this.namespace = '/ghost/api/v0.1'; // make this `api`, for example, if your API is namespaced
|
2016-04-13 12:44:09 +03:00
|
|
|
// this.timing = 400; // delay for each request, automatically set to 0 during testing
|
2016-07-22 16:36:50 +03:00
|
|
|
// this.logging = true;
|
2016-04-13 12:44:09 +03:00
|
|
|
|
2016-08-17 18:14:33 +03:00
|
|
|
mockAuthentication(this);
|
2016-10-28 16:07:50 +03:00
|
|
|
mockConfiguration(this);
|
2016-09-26 19:03:53 +03:00
|
|
|
mockInvites(this);
|
2016-08-17 18:14:33 +03:00
|
|
|
mockPosts(this);
|
|
|
|
mockRoles(this);
|
|
|
|
mockSettings(this);
|
|
|
|
mockSlugs(this);
|
|
|
|
mockSubscribers(this);
|
|
|
|
mockTags(this);
|
2016-08-17 18:01:46 +03:00
|
|
|
mockThemes(this);
|
2016-08-17 18:14:33 +03:00
|
|
|
mockUsers(this);
|
2015-11-13 14:48:59 +03:00
|
|
|
|
2015-10-13 16:52:41 +03:00
|
|
|
/* Notifications -------------------------------------------------------- */
|
|
|
|
|
2017-01-02 21:49:44 +03:00
|
|
|
this.get('/notifications/');
|
2015-10-13 16:52:41 +03:00
|
|
|
|
2016-03-29 11:40:44 +03:00
|
|
|
/* Apps - Slack Test Notification --------------------------------------------------------- */
|
|
|
|
|
|
|
|
this.post('/slack/test', function () {
|
|
|
|
return {};
|
|
|
|
});
|
|
|
|
|
2016-08-17 18:14:33 +03:00
|
|
|
/* External sites ------------------------------------------------------- */
|
2015-12-07 00:24:06 +03:00
|
|
|
|
2016-08-17 18:14:33 +03:00
|
|
|
let downloadCount = 0;
|
|
|
|
this.get('https://count.ghost.org/', function () {
|
|
|
|
downloadCount++;
|
2015-12-07 00:24:06 +03:00
|
|
|
return {
|
2016-08-17 18:14:33 +03:00
|
|
|
count: downloadCount
|
2015-12-07 00:24:06 +03:00
|
|
|
};
|
|
|
|
});
|
2016-03-03 11:52:27 +03:00
|
|
|
|
2016-04-12 14:34:40 +03:00
|
|
|
this.get('http://www.gravatar.com/avatar/:md5', function () {
|
|
|
|
return '';
|
|
|
|
}, 200);
|
2015-10-13 16:52:41 +03:00
|
|
|
}
|