Skip to content

Node.js based forum software built for the modern web

notif controller test

barisusaklicbd6853ccb3d
diff --git a/src/controllers/accounts/notifications.js b/src/controllers/accounts/notifications.js
index 91b9eb1d07..50a5a5913b 100644
--- a/src/controllers/accounts/notifications.js
+++ b/src/controllers/accounts/notifications.js
@@ -1,8 +1,7 @@
'use strict';
-var user = require('../../user'),
- helpers = require('../helpers');
-
+var user = require('../../user');
+var helpers = require('../helpers');
var notificationsController = {};
diff --git a/test/controllers.js b/test/controllers.js
index 1d1d12f39b..51d1495e82 100644
--- a/test/controllers.js
+++ b/test/controllers.js
@@ -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 () {