2019-08-09 19:55:12 +05:30
|
|
|
const should = require('should');
|
|
|
|
const supertest = require('supertest');
|
|
|
|
const sinon = require('sinon');
|
|
|
|
const testUtils = require('../../../../utils');
|
2019-10-02 17:09:33 +02:00
|
|
|
const localUtils = require('./utils');
|
2020-05-27 12:47:53 -05:00
|
|
|
const config = require('../../../../../core/shared/config');
|
2021-04-27 14:18:04 +01:00
|
|
|
const events = require('../../../../../core/server/lib/common/events');
|
2019-08-09 19:55:12 +05:30
|
|
|
|
|
|
|
let request;
|
|
|
|
|
|
|
|
describe('Slack API', function () {
|
|
|
|
let ghostServer;
|
|
|
|
|
|
|
|
before(function () {
|
2021-11-24 12:39:00 +04:00
|
|
|
return testUtils.startGhost()
|
2019-08-09 19:55:12 +05:30
|
|
|
.then(function (_ghostServer) {
|
|
|
|
ghostServer = _ghostServer;
|
|
|
|
request = supertest.agent(config.get('url'));
|
|
|
|
})
|
|
|
|
.then(function () {
|
|
|
|
return localUtils.doAuth(request);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
after(function () {
|
|
|
|
sinon.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Can post slack test', function (done) {
|
2020-05-28 11:54:18 -05:00
|
|
|
const eventSpy = sinon.spy(events, 'emit');
|
2019-08-09 19:55:12 +05:30
|
|
|
request.post(localUtils.API.getApiQuery('slack/test/'))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
|
|
const jsonResponse = res.body;
|
|
|
|
should.exist(jsonResponse);
|
|
|
|
eventSpy.calledWith('slack.test').should.be.true();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|