2016-06-03 13:51:06 +03:00
|
|
|
import Pretender from 'pretender';
|
2016-05-24 15:06:59 +03:00
|
|
|
import config from 'ghost-admin/config/environment';
|
2021-02-05 12:12:26 +03:00
|
|
|
import ghostPaths from 'ghost-admin/utils/ghost-paths';
|
2017-05-29 21:50:03 +03:00
|
|
|
import {describe, it} from 'mocha';
|
|
|
|
import {expect} from 'chai';
|
|
|
|
import {setupTest} from 'ember-mocha';
|
2016-06-03 13:51:06 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
describe('Integration: Service: store', function () {
|
2019-05-13 15:43:53 +03:00
|
|
|
setupTest();
|
2016-06-03 13:51:06 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
let server;
|
2016-06-03 13:51:06 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
beforeEach(function () {
|
|
|
|
server = new Pretender();
|
|
|
|
});
|
2016-06-03 13:51:06 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
afterEach(function () {
|
|
|
|
server.shutdown();
|
|
|
|
});
|
2016-06-03 13:51:06 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
it('adds Ghost version header to requests', function (done) {
|
|
|
|
let {version} = config.APP;
|
2019-05-13 15:43:53 +03:00
|
|
|
let store = this.owner.lookup('service:store');
|
2016-11-24 01:50:57 +03:00
|
|
|
|
2021-02-05 12:12:26 +03:00
|
|
|
server.get(`${ghostPaths().apiRoot}/posts/1/`, function () {
|
2016-11-24 01:50:57 +03:00
|
|
|
return [
|
|
|
|
404,
|
|
|
|
{'Content-Type': 'application/json'},
|
|
|
|
JSON.stringify({})
|
|
|
|
];
|
|
|
|
});
|
2016-06-03 13:51:06 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
store.find('post', 1).catch(() => {
|
|
|
|
let [request] = server.handledRequests;
|
|
|
|
expect(request.requestHeaders['X-Ghost-Version']).to.equal(version);
|
|
|
|
done();
|
2016-06-03 13:51:06 +03:00
|
|
|
});
|
2016-11-24 01:50:57 +03:00
|
|
|
});
|
|
|
|
});
|