Ghost/ghost/admin/tests/unit/transforms/slack-settings-test.js
Aileen Nowak 753f307382 Slack integration
closes #6584
- Frontend Changes:
	- adds 'Apps' to Navigation Menu
	- adds 'Slack' as nested page to Apps
	- adds `apps.css`
	- adds `slack-integration` model and uses `slack-settings` custom transform to parse JSON file
	- adds validation for `slack` model
	- adds fixtures and `slack/test` API endpoint to Mirage
	- adds acceptance tests for `apps-test` and `slack-test`
	- adds unit tests for `slack-settings` and `slack-integration`
- Backend Changes:
	- adds API endpoint `slack/test` to send Test Notification
	- adds default-values for slack model
	- sends payload to slack:
		- text: the url of the blogpost / test message
		- icon_url: url to ghost logo
		- username: Ghost
	- adds `slack/index.js` to send webhook to slack if
		- a new post is published (if slack webhook url is saved in settings)
		- user clicks on 'Send Test Notification' in UI
	- adds `slack.init()` to `server.index.js` to add event listener
	- adds unit test for `slack/index`
2016-05-08 12:49:15 +02:00

38 lines
1.3 KiB
JavaScript

/* jshint expr:true */
import { expect } from 'chai';
import { describeModule, it } from 'ember-mocha';
import Ember from 'ember';
import SlackIntegration from 'ghost/models/slack-integration';
const emberA = Ember.A;
describeModule(
'transform:slack-settings',
'Unit: Transform: slack-settings',
{
// Specify the other units that are required for this test.
// needs: ['transform:foo']
},
function() {
it('deserializes settings json', function () {
let transform = this.subject();
let serialized = '[{"url":"http://myblog.com/blogpost1"}]';
let result = transform.deserialize(serialized);
expect(result.length).to.equal(1);
expect(result[0]).to.be.instanceof(SlackIntegration);
expect(result[0].get('url')).to.equal('http://myblog.com/blogpost1');
});
it('serializes array of Slack settings', function () {
let transform = this.subject();
let deserialized = emberA([
SlackIntegration.create({url: 'http://myblog.com/blogpost1'})
]);
let result = transform.serialize(deserialized);
expect(result).to.equal('[{"url":"http://myblog.com/blogpost1"}]');
});
}
);