2019-08-09 17:25:12 +03:00
|
|
|
const should = require('should');
|
|
|
|
const supertest = require('supertest');
|
|
|
|
const sinon = require('sinon');
|
2022-02-06 19:18:41 +03:00
|
|
|
const testUtils = require('../../../utils');
|
2019-10-02 18:09:33 +03:00
|
|
|
const localUtils = require('./utils');
|
2022-02-06 19:18:41 +03:00
|
|
|
const config = require('../../../../core/shared/config');
|
|
|
|
const events = require('../../../../core/server/lib/common/events');
|
2019-08-09 17:25:12 +03:00
|
|
|
|
|
|
|
let request;
|
|
|
|
|
|
|
|
describe('Slack API', function () {
|
2021-11-24 12:42:57 +03:00
|
|
|
before(async function () {
|
2021-11-24 16:29:45 +03:00
|
|
|
await localUtils.startGhost();
|
2021-11-24 12:42:57 +03:00
|
|
|
request = supertest.agent(config.get('url'));
|
|
|
|
await localUtils.doAuth(request);
|
2019-08-09 17:25:12 +03:00
|
|
|
});
|
|
|
|
after(function () {
|
|
|
|
sinon.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Can post slack test', function (done) {
|
2020-05-28 19:54:18 +03:00
|
|
|
const eventSpy = sinon.spy(events, 'emit');
|
2019-08-09 17:25:12 +03:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|