notif controller test

This commit is contained in:
barisusakli
2016-12-05 17:16:28 +03:00
parent 8691256a67
commit cbd6853ccb
2 changed files with 43 additions and 4 deletions

View File

@@ -703,7 +703,7 @@ describe('Controllers', function () {
});
});
describe('account post pages', function () {
describe('account pages', function () {
var helpers = require('./helpers');
var jar;
before(function (done) {
@@ -785,6 +785,46 @@ describe('Controllers', function () {
done();
});
});
it('should load notifications page', function (done) {
var notifications = require('../src/notifications');
var notifData = {
bodyShort: '[[notifications:user_posted_to, test1, test2]]',
bodyLong: 'some post content',
pid: 1,
path: '/post/' + 1,
nid: 'new_post:tid:' + 1 + ':pid:' + 1 + ':uid:' + fooUid,
tid: 1,
from: fooUid,
mergeId: 'notifications:user_posted_to|' + 1,
topicTitle: 'topic title'
};
async.waterfall([
function (next) {
notifications.create(notifData, next);
},
function (notification, next) {
notifications.push(notification, fooUid, next);
},
function (next) {
setTimeout(next, 2500);
},
function (next) {
request(nconf.get('url') + '/api/notifications', {jar: jar, json: true}, next);
},
function (res, body, next) {
assert.equal(res.statusCode, 200);
assert(body);
var notif = body.notifications[0];
assert.equal(notif.bodyShort, notifData.bodyShort);
assert.equal(notif.bodyLong, notifData.bodyLong);
assert.equal(notif.pid, notifData.pid);
assert.equal(notif.path, notifData.path);
assert.equal(notif.nid, notifData.nid);
next();
}
], done);
});
});
describe('account follow page', function () {