', function (done) {
- request(nconf.get('url') + '/outgoing?url=http://youtube.com', function (err, res, body) {
+ request(`${nconf.get('url')}/outgoing?url=http://youtube.com`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -378,7 +378,7 @@ describe('Controllers', function () {
});
it('should 404 on /outgoing with no url', function (done) {
- request(nconf.get('url') + '/outgoing', function (err, res, body) {
+ request(`${nconf.get('url')}/outgoing`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
assert(body);
@@ -387,7 +387,7 @@ describe('Controllers', function () {
});
it('should 404 on /outgoing with javascript: protocol', function (done) {
- request(nconf.get('url') + '/outgoing?url=javascript:alert(1);', function (err, res, body) {
+ request(`${nconf.get('url')}/outgoing?url=javascript:alert(1);`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
assert(body);
@@ -396,7 +396,7 @@ describe('Controllers', function () {
});
it('should 404 on /outgoing with invalid url', function (done) {
- request(nconf.get('url') + '/outgoing?url=derp', function (err, res, body) {
+ request(`${nconf.get('url')}/outgoing?url=derp`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
assert(body);
@@ -406,7 +406,7 @@ describe('Controllers', function () {
it('should load /tos', function (done) {
meta.config.termsOfUse = 'please accept our tos';
- request(nconf.get('url') + '/tos', function (err, res, body) {
+ request(`${nconf.get('url')}/tos`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -417,7 +417,7 @@ describe('Controllers', function () {
it('should load 404 if meta.config.termsOfUse is empty', function (done) {
meta.config.termsOfUse = '';
- request(nconf.get('url') + '/tos', function (err, res, body) {
+ request(`${nconf.get('url')}/tos`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
assert(body);
@@ -426,7 +426,7 @@ describe('Controllers', function () {
});
it('should load /sping', function (done) {
- request(nconf.get('url') + '/sping', function (err, res, body) {
+ request(`${nconf.get('url')}/sping`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body, 'healthy');
@@ -435,7 +435,7 @@ describe('Controllers', function () {
});
it('should load /ping', function (done) {
- request(nconf.get('url') + '/ping', function (err, res, body) {
+ request(`${nconf.get('url')}/ping`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body, '200');
@@ -444,7 +444,7 @@ describe('Controllers', function () {
});
it('should handle 404', function (done) {
- request(nconf.get('url') + '/arouteinthevoid', function (err, res, body) {
+ request(`${nconf.get('url')}/arouteinthevoid`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
assert(body);
@@ -453,7 +453,7 @@ describe('Controllers', function () {
});
it('should load topic rss feed', function (done) {
- request(nconf.get('url') + '/topic/' + tid + '.rss', function (err, res, body) {
+ request(`${nconf.get('url')}/topic/${tid}.rss`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -462,7 +462,7 @@ describe('Controllers', function () {
});
it('should load category rss feed', function (done) {
- request(nconf.get('url') + '/category/' + cid + '.rss', function (err, res, body) {
+ request(`${nconf.get('url')}/category/${cid}.rss`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -471,7 +471,7 @@ describe('Controllers', function () {
});
it('should load topics rss feed', function (done) {
- request(nconf.get('url') + '/topics.rss', function (err, res, body) {
+ request(`${nconf.get('url')}/topics.rss`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -480,7 +480,7 @@ describe('Controllers', function () {
});
it('should load recent rss feed', function (done) {
- request(nconf.get('url') + '/recent.rss', function (err, res, body) {
+ request(`${nconf.get('url')}/recent.rss`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -489,7 +489,7 @@ describe('Controllers', function () {
});
it('should load top rss feed', function (done) {
- request(nconf.get('url') + '/top.rss', function (err, res, body) {
+ request(`${nconf.get('url')}/top.rss`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -498,7 +498,7 @@ describe('Controllers', function () {
});
it('should load popular rss feed', function (done) {
- request(nconf.get('url') + '/popular.rss', function (err, res, body) {
+ request(`${nconf.get('url')}/popular.rss`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -507,7 +507,7 @@ describe('Controllers', function () {
});
it('should load popular rss feed with term', function (done) {
- request(nconf.get('url') + '/popular/day.rss', function (err, res, body) {
+ request(`${nconf.get('url')}/popular/day.rss`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -516,7 +516,7 @@ describe('Controllers', function () {
});
it('should load recent posts rss feed', function (done) {
- request(nconf.get('url') + '/recentposts.rss', function (err, res, body) {
+ request(`${nconf.get('url')}/recentposts.rss`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -525,7 +525,7 @@ describe('Controllers', function () {
});
it('should load category recent posts rss feed', function (done) {
- request(nconf.get('url') + '/category/' + cid + '/recentposts.rss', function (err, res, body) {
+ request(`${nconf.get('url')}/category/${cid}/recentposts.rss`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -534,7 +534,7 @@ describe('Controllers', function () {
});
it('should load user topics rss feed', function (done) {
- request(nconf.get('url') + '/user/foo/topics.rss', function (err, res, body) {
+ request(`${nconf.get('url')}/user/foo/topics.rss`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -543,7 +543,7 @@ describe('Controllers', function () {
});
it('should load tag rss feed', function (done) {
- request(nconf.get('url') + '/tags/nodebb.rss', function (err, res, body) {
+ request(`${nconf.get('url')}/tags/nodebb.rss`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -552,7 +552,7 @@ describe('Controllers', function () {
});
it('should load client.css', function (done) {
- request(nconf.get('url') + '/assets/client.css', function (err, res, body) {
+ request(`${nconf.get('url')}/assets/client.css`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -561,7 +561,7 @@ describe('Controllers', function () {
});
it('should load admin.css', function (done) {
- request(nconf.get('url') + '/assets/admin.css', function (err, res, body) {
+ request(`${nconf.get('url')}/assets/admin.css`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -571,7 +571,7 @@ describe('Controllers', function () {
it('should load nodebb.min.js', function (done) {
- request(nconf.get('url') + '/assets/nodebb.min.js', function (err, res, body) {
+ request(`${nconf.get('url')}/assets/nodebb.min.js`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -580,7 +580,7 @@ describe('Controllers', function () {
});
it('should load acp.min.js', function (done) {
- request(nconf.get('url') + '/assets/acp.min.js', function (err, res, body) {
+ request(`${nconf.get('url')}/assets/acp.min.js`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -589,7 +589,7 @@ describe('Controllers', function () {
});
it('should load sitemap.xml', function (done) {
- request(nconf.get('url') + '/sitemap.xml', function (err, res, body) {
+ request(`${nconf.get('url')}/sitemap.xml`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -598,7 +598,7 @@ describe('Controllers', function () {
});
it('should load sitemap/pages.xml', function (done) {
- request(nconf.get('url') + '/sitemap/pages.xml', function (err, res, body) {
+ request(`${nconf.get('url')}/sitemap/pages.xml`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -607,7 +607,7 @@ describe('Controllers', function () {
});
it('should load sitemap/categories.xml', function (done) {
- request(nconf.get('url') + '/sitemap/categories.xml', function (err, res, body) {
+ request(`${nconf.get('url')}/sitemap/categories.xml`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -616,7 +616,7 @@ describe('Controllers', function () {
});
it('should load sitemap/topics/1.xml', function (done) {
- request(nconf.get('url') + '/sitemap/topics.1.xml', function (err, res, body) {
+ request(`${nconf.get('url')}/sitemap/topics.1.xml`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -625,7 +625,7 @@ describe('Controllers', function () {
});
it('should load robots.txt', function (done) {
- request(nconf.get('url') + '/robots.txt', function (err, res, body) {
+ request(`${nconf.get('url')}/robots.txt`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -634,7 +634,7 @@ describe('Controllers', function () {
});
it('should load theme screenshot', function (done) {
- request(nconf.get('url') + '/css/previews/nodebb-theme-persona', function (err, res, body) {
+ request(`${nconf.get('url')}/css/previews/nodebb-theme-persona`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -643,7 +643,7 @@ describe('Controllers', function () {
});
it('should load users page', function (done) {
- request(nconf.get('url') + '/users', function (err, res, body) {
+ request(`${nconf.get('url')}/users`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -652,7 +652,7 @@ describe('Controllers', function () {
});
it('should load users page', function (done) {
- request(nconf.get('url') + '/users?section=online', function (err, res, body) {
+ request(`${nconf.get('url')}/users?section=online`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -661,7 +661,7 @@ describe('Controllers', function () {
});
it('should error if guests do not have search privilege', function (done) {
- request(nconf.get('url') + '/api/users?query=bar§ion=sort-posts', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/users?query=bar§ion=sort-posts`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 500);
assert(body);
@@ -673,7 +673,7 @@ describe('Controllers', function () {
it('should load users search page', function (done) {
privileges.global.give(['groups:search:users'], 'guests', function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/users?query=bar§ion=sort-posts', function (err, res, body) {
+ request(`${nconf.get('url')}/users?query=bar§ion=sort-posts`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -683,7 +683,7 @@ describe('Controllers', function () {
});
it('should load groups page', function (done) {
- request(nconf.get('url') + '/groups', function (err, res, body) {
+ request(`${nconf.get('url')}/groups`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -707,7 +707,7 @@ describe('Controllers', function () {
cid: cid,
}, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/groups/group-details', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/groups/group-details`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -720,7 +720,7 @@ describe('Controllers', function () {
});
it('should load group members page', function (done) {
- request(nconf.get('url') + '/groups/group-details/members', function (err, res, body) {
+ request(`${nconf.get('url')}/groups/group-details/members`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -736,7 +736,7 @@ describe('Controllers', function () {
hidden: 1,
}, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/groups/hidden-group/members', function (err, res) {
+ request(`${nconf.get('url')}/groups/hidden-group/members`, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -745,7 +745,7 @@ describe('Controllers', function () {
});
it('should get recent posts', function (done) {
- request(nconf.get('url') + '/api/recent/posts/month', function (err, res, body) {
+ request(`${nconf.get('url')}/api/recent/posts/month`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -754,7 +754,7 @@ describe('Controllers', function () {
});
it('should get post data', function (done) {
- request(nconf.get('url') + '/api/v3/posts/' + pid, function (err, res, body) {
+ request(`${nconf.get('url')}/api/v3/posts/${pid}`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -763,7 +763,7 @@ describe('Controllers', function () {
});
it('should get topic data', function (done) {
- request(nconf.get('url') + '/api/v3/topics/' + tid, function (err, res, body) {
+ request(`${nconf.get('url')}/api/v3/topics/${tid}`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -772,7 +772,7 @@ describe('Controllers', function () {
});
it('should get category data', function (done) {
- request(nconf.get('url') + '/api/v3/categories/' + cid, function (err, res, body) {
+ request(`${nconf.get('url')}/api/v3/categories/${cid}`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -800,7 +800,7 @@ describe('Controllers', function () {
});
it('should fail to revoke session with missing uuid', function (done) {
- request.del(nconf.get('url') + '/api/user/revokeme/session', {
+ request.del(`${nconf.get('url')}/api/user/revokeme/session`, {
jar: jar,
headers: {
'x-csrf-token': csrf_token,
@@ -832,7 +832,7 @@ describe('Controllers', function () {
});
it('should revoke user session', function (done) {
- db.getSortedSetRange('uid:' + uid + ':sessions', 0, -1, function (err, sids) {
+ db.getSortedSetRange(`uid:${uid}:sessions`, 0, -1, function (err, sids) {
assert.ifError(err);
var sid = sids[0];
@@ -890,7 +890,7 @@ describe('Controllers', function () {
});
it('should return {} if there are no widgets', function (done) {
- request(nconf.get('url') + '/api/category/' + cid, { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/category/${cid}`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body.widgets);
@@ -900,7 +900,7 @@ describe('Controllers', function () {
});
it('should render templates', function (done) {
- var url = nconf.get('url') + '/api/categories';
+ var url = `${nconf.get('url')}/api/categories`;
request(url, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
@@ -914,7 +914,7 @@ describe('Controllers', function () {
it('should reset templates', function (done) {
widgets.resetTemplates(['categories', 'category'], function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/categories', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/categories`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body.widgets);
@@ -942,7 +942,7 @@ describe('Controllers', function () {
});
it('should render tags page', function (done) {
- request(nconf.get('url') + '/api/tags', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/tags`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -952,7 +952,7 @@ describe('Controllers', function () {
});
it('should render tag page with no topics', function (done) {
- request(nconf.get('url') + '/api/tags/notag', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/tags/notag`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -963,7 +963,7 @@ describe('Controllers', function () {
});
it('should render tag page with 1 topic', function (done) {
- request(nconf.get('url') + '/api/tags/nodebb', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/tags/nodebb`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -986,7 +986,7 @@ describe('Controllers', function () {
});
it('should return 503 in maintenance mode', function (done) {
- request(nconf.get('url') + '/recent', { json: true }, function (err, res) {
+ request(`${nconf.get('url')}/recent`, { json: true }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 503);
done();
@@ -994,7 +994,7 @@ describe('Controllers', function () {
});
it('should return 503 in maintenance mode', function (done) {
- request(nconf.get('url') + '/api/recent', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/recent`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 503);
assert(body);
@@ -1003,7 +1003,7 @@ describe('Controllers', function () {
});
it('should return 200 in maintenance mode', function (done) {
- request(nconf.get('url') + '/api/login', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/login`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1023,7 +1023,7 @@ describe('Controllers', function () {
});
it('should redirect to account page with logged in user', function (done) {
- request(nconf.get('url') + '/api/login', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/login`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(res.headers['x-redirect'], '/user/foo');
@@ -1033,7 +1033,7 @@ describe('Controllers', function () {
});
it('should 404 if uid is not a number', function (done) {
- request(nconf.get('url') + '/api/uid/test', { json: true }, function (err, res) {
+ request(`${nconf.get('url')}/api/uid/test`, { json: true }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -1041,7 +1041,7 @@ describe('Controllers', function () {
});
it('should redirect to userslug', function (done) {
- request(nconf.get('url') + '/api/uid/' + fooUid, { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/uid/${fooUid}`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(res.headers['x-redirect'], '/user/foo');
@@ -1051,7 +1051,7 @@ describe('Controllers', function () {
});
it('should 404 if user does not exist', function (done) {
- request(nconf.get('url') + '/api/uid/123123', { json: true }, function (err, res) {
+ request(`${nconf.get('url')}/api/uid/123123`, { json: true }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -1060,7 +1060,7 @@ describe('Controllers', function () {
describe('/me/*', function () {
it('should redirect to user profile', function (done) {
- request(nconf.get('url') + '/me', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/me`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body.includes('"template":{"name":"account/profile","account/profile":true}'));
@@ -1069,7 +1069,7 @@ describe('Controllers', function () {
});
});
it('api should redirect to /user/[userslug]/bookmarks', function (done) {
- request(nconf.get('url') + '/api/me/bookmarks', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/me/bookmarks`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(res.headers['x-redirect'], '/user/foo/bookmarks');
@@ -1078,7 +1078,7 @@ describe('Controllers', function () {
});
});
it('api should redirect to /user/[userslug]/edit/username', function (done) {
- request(nconf.get('url') + '/api/me/edit/username', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/me/edit/username`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(res.headers['x-redirect'], '/user/foo/edit/username');
@@ -1087,7 +1087,7 @@ describe('Controllers', function () {
});
});
it('should redirect to login if user is not logged in', function (done) {
- request(nconf.get('url') + '/me/bookmarks', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/me/bookmarks`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body.includes('Login to your account'), body.substr(0, 500));
@@ -1097,7 +1097,7 @@ describe('Controllers', function () {
});
it('should 401 if user is not logged in', function (done) {
- request(nconf.get('url') + '/api/admin', { json: true }, function (err, res) {
+ request(`${nconf.get('url')}/api/admin`, { json: true }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 401);
done();
@@ -1105,7 +1105,7 @@ describe('Controllers', function () {
});
it('should 403 if user is not admin', function (done) {
- request(nconf.get('url') + '/api/admin', { jar: jar, json: true }, function (err, res) {
+ request(`${nconf.get('url')}/api/admin`, { jar: jar, json: true }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 403);
done();
@@ -1113,7 +1113,7 @@ describe('Controllers', function () {
});
it('should load /user/foo/posts', function (done) {
- request(nconf.get('url') + '/api/user/foo/posts', function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/posts`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1122,7 +1122,7 @@ describe('Controllers', function () {
});
it('should 401 if not logged in', function (done) {
- request(nconf.get('url') + '/api/user/foo/bookmarks', function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/bookmarks`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 401);
assert(body);
@@ -1131,7 +1131,7 @@ describe('Controllers', function () {
});
it('should load /user/foo/bookmarks', function (done) {
- request(nconf.get('url') + '/api/user/foo/bookmarks', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/bookmarks`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1140,7 +1140,7 @@ describe('Controllers', function () {
});
it('should load /user/foo/upvoted', function (done) {
- request(nconf.get('url') + '/api/user/foo/upvoted', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/upvoted`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1149,7 +1149,7 @@ describe('Controllers', function () {
});
it('should load /user/foo/downvoted', function (done) {
- request(nconf.get('url') + '/api/user/foo/downvoted', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/downvoted`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1158,7 +1158,7 @@ describe('Controllers', function () {
});
it('should load /user/foo/best', function (done) {
- request(nconf.get('url') + '/api/user/foo/best', function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/best`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1167,7 +1167,7 @@ describe('Controllers', function () {
});
it('should load /user/foo/watched', function (done) {
- request(nconf.get('url') + '/api/user/foo/watched', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/watched`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1176,7 +1176,7 @@ describe('Controllers', function () {
});
it('should load /user/foo/ignored', function (done) {
- request(nconf.get('url') + '/api/user/foo/ignored', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/ignored`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1185,7 +1185,7 @@ describe('Controllers', function () {
});
it('should load /user/foo/topics', function (done) {
- request(nconf.get('url') + '/api/user/foo/topics', function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/topics`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1194,7 +1194,7 @@ describe('Controllers', function () {
});
it('should load /user/foo/blocks', function (done) {
- request(nconf.get('url') + '/api/user/foo/blocks', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/blocks`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1203,7 +1203,7 @@ describe('Controllers', function () {
});
it('should load /user/foo/consent', function (done) {
- request(nconf.get('url') + '/api/user/foo/consent', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/consent`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1212,7 +1212,7 @@ describe('Controllers', function () {
});
it('should load /user/foo/sessions', function (done) {
- request(nconf.get('url') + '/api/user/foo/sessions', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/sessions`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1221,7 +1221,7 @@ describe('Controllers', function () {
});
it('should load /user/foo/categories', function (done) {
- request(nconf.get('url') + '/api/user/foo/categories', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/categories`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1230,7 +1230,7 @@ describe('Controllers', function () {
});
it('should load /user/foo/uploads', function (done) {
- request(nconf.get('url') + '/api/user/foo/uploads', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/uploads`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1239,7 +1239,7 @@ describe('Controllers', function () {
});
it('should export users posts', function (done) {
- request(nconf.get('url') + '/api/user/uid/foo/export/posts', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/uid/foo/export/posts`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1248,7 +1248,7 @@ describe('Controllers', function () {
});
it('should export users uploads', function (done) {
- request(nconf.get('url') + '/api/user/uid/foo/export/uploads', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/uid/foo/export/uploads`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1257,7 +1257,7 @@ describe('Controllers', function () {
});
it('should export users profile', function (done) {
- request(nconf.get('url') + '/api/user/uid/foo/export/profile', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/uid/foo/export/profile`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1271,11 +1271,11 @@ describe('Controllers', function () {
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,
+ path: `/post/${1}`,
+ nid: `new_post:tid:${1}:pid:${1}:uid:${fooUid}`,
tid: 1,
from: fooUid,
- mergeId: 'notifications:user_posted_to|' + 1,
+ mergeId: `notifications:user_posted_to|${1}`,
topicTitle: 'topic title',
};
async.waterfall([
@@ -1289,7 +1289,7 @@ describe('Controllers', function () {
setTimeout(next, 2500);
},
function (next) {
- request(nconf.get('url') + '/api/notifications', { jar: jar, json: true }, next);
+ request(`${nconf.get('url')}/api/notifications`, { jar: jar, json: true }, next);
},
function (res, body, next) {
assert.equal(res.statusCode, 200);
@@ -1306,7 +1306,7 @@ describe('Controllers', function () {
});
it('should 404 if user does not exist', function (done) {
- request(nconf.get('url') + '/api/user/email/doesnotexist', function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/email/doesnotexist`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
assert(body);
@@ -1315,7 +1315,7 @@ describe('Controllers', function () {
});
it('should load user by uid', function (done) {
- request(nconf.get('url') + '/api/user/uid/' + fooUid, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/uid/${fooUid}`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1324,7 +1324,7 @@ describe('Controllers', function () {
});
it('should load user by username', function (done) {
- request(nconf.get('url') + '/api/user/username/foo', function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/username/foo`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1333,7 +1333,7 @@ describe('Controllers', function () {
});
it('should load user by email', function (done) {
- request(nconf.get('url') + '/api/user/email/foo@test.com', function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/email/foo@test.com`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1344,7 +1344,7 @@ describe('Controllers', function () {
it('should return 401 if user does not have view:users privilege', function (done) {
privileges.global.rescind(['groups:view:users'], 'guests', function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/user/foo', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 401);
assert.deepEqual(body, {
@@ -1364,10 +1364,10 @@ describe('Controllers', function () {
assert.ifError(err);
helpers.loginUser('regularJoe', 'barbar', function (err, jar) {
assert.ifError(err);
- request(nconf.get('url') + '/api/user/foo/info', { jar: jar, json: true }, function (err, res) {
+ request(`${nconf.get('url')}/api/user/foo/info`, { jar: jar, json: true }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 403);
- request(nconf.get('url') + '/api/user/foo/edit', { jar: jar, json: true }, function (err, res) {
+ request(`${nconf.get('url')}/api/user/foo/edit`, { jar: jar, json: true }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 403);
done();
@@ -1378,7 +1378,7 @@ describe('Controllers', function () {
});
it('should load correct user', function (done) {
- request(nconf.get('url') + '/api/user/FOO', { jar: jar, json: true }, function (err, res) {
+ request(`${nconf.get('url')}/api/user/FOO`, { jar: jar, json: true }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
done();
@@ -1386,7 +1386,7 @@ describe('Controllers', function () {
});
it('should redirect', function (done) {
- request(nconf.get('url') + '/user/FOO', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/user/FOO`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1395,7 +1395,7 @@ describe('Controllers', function () {
});
it('should 404 if user does not exist', function (done) {
- request(nconf.get('url') + '/api/user/doesnotexist', { jar: jar }, function (err, res) {
+ request(`${nconf.get('url')}/api/user/doesnotexist`, { jar: jar }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -1403,7 +1403,7 @@ describe('Controllers', function () {
});
it('should not increase profile view if you visit your own profile', (done) => {
- request(nconf.get('url') + '/api/user/foo', { jar: jar }, function (err, res) {
+ request(`${nconf.get('url')}/api/user/foo`, { jar: jar }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
setTimeout(function () {
@@ -1417,7 +1417,7 @@ describe('Controllers', function () {
});
it('should not increase profile view if a guest visits a profile', (done) => {
- request(nconf.get('url') + '/api/user/foo', {}, function (err, res) {
+ request(`${nconf.get('url')}/api/user/foo`, {}, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
setTimeout(function () {
@@ -1433,7 +1433,7 @@ describe('Controllers', function () {
it('should increase profile view', function (done) {
helpers.loginUser('regularJoe', 'barbar', function (err, jar) {
assert.ifError(err);
- request(nconf.get('url') + '/api/user/foo', { jar: jar }, function (err, res) {
+ request(`${nconf.get('url')}/api/user/foo`, { jar: jar }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
setTimeout(function () {
@@ -1450,7 +1450,7 @@ describe('Controllers', function () {
it('should parse about me', function (done) {
user.setUserFields(fooUid, { picture: '/path/to/picture', aboutme: 'hi i am a bot' }, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/user/foo', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body.aboutme, 'hi i am a bot');
@@ -1462,7 +1462,7 @@ describe('Controllers', function () {
it('should not return reputation if reputation is disabled', function (done) {
meta.config['reputation:disabled'] = 1;
- request(nconf.get('url') + '/api/user/foo', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo`, { json: true }, function (err, res, body) {
meta.config['reputation:disabled'] = 0;
assert.ifError(err);
assert.equal(res.statusCode, 200);
@@ -1490,7 +1490,7 @@ describe('Controllers', function () {
posts.delete(pidToDelete, fooUid, next);
},
function (next) {
- request(nconf.get('url') + '/api/user/foo', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
var contents = body.posts.map(function (p) {
@@ -1512,7 +1512,7 @@ describe('Controllers', function () {
assert.ifError(err);
groups.join('selectedGroup', uid, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/user/groupie', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/groupie`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(Array.isArray(body.selectedGroup));
@@ -1527,7 +1527,7 @@ describe('Controllers', function () {
it('should 404 if user does not exist', function (done) {
groups.join('administrators', fooUid, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/user/doesnotexist/edit', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/doesnotexist/edit`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
groups.leave('administrators', fooUid, done);
@@ -1536,7 +1536,7 @@ describe('Controllers', function () {
});
it('should render edit/password', function (done) {
- request(nconf.get('url') + '/api/user/foo/edit/password', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/edit/password`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
done();
@@ -1544,7 +1544,7 @@ describe('Controllers', function () {
});
it('should render edit/email', function (done) {
- request(nconf.get('url') + '/api/user/foo/edit/email', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/edit/email`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
done();
@@ -1552,7 +1552,7 @@ describe('Controllers', function () {
});
it('should render edit/username', function (done) {
- request(nconf.get('url') + '/api/user/foo/edit/username', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/edit/username`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
done();
@@ -1579,7 +1579,7 @@ describe('Controllers', function () {
});
it('should get followers page', function (done) {
- request(nconf.get('url') + '/api/user/foo/followers', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/followers`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body.users[0].username, 'follower');
@@ -1588,7 +1588,7 @@ describe('Controllers', function () {
});
it('should get following page', function (done) {
- request(nconf.get('url') + '/api/user/follower/following', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/follower/following`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body.users[0].username, 'foo');
@@ -1599,7 +1599,7 @@ describe('Controllers', function () {
it('should return empty after unfollow', function (done) {
socketUser.unfollow({ uid: uid }, { uid: fooUid }, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/user/foo/followers', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/foo/followers`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body.users.length, 0);
@@ -1620,7 +1620,7 @@ describe('Controllers', function () {
});
it('should 404 for invalid pid', function (done) {
- request(nconf.get('url') + '/api/post/fail', function (err, res) {
+ request(`${nconf.get('url')}/api/post/fail`, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -1630,7 +1630,7 @@ describe('Controllers', function () {
it('should 403 if user does not have read privilege', function (done) {
privileges.categories.rescind(['groups:topics:read'], category.cid, 'registered-users', function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/post/' + pid, { jar: jar }, function (err, res) {
+ request(`${nconf.get('url')}/api/post/${pid}`, { jar: jar }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 403);
privileges.categories.give(['groups:topics:read'], category.cid, 'registered-users', done);
@@ -1639,7 +1639,7 @@ describe('Controllers', function () {
});
it('should return correct post path', function (done) {
- request(nconf.get('url') + '/api/post/' + pid, { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/post/${pid}`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(res.headers['x-redirect'], '/topic/1/test-topic-title/1');
@@ -1651,7 +1651,7 @@ describe('Controllers', function () {
describe('cookie consent', function () {
it('should return relevant data in configs API route', function (done) {
- request(nconf.get('url') + '/api/config', function (err, res, body) {
+ request(`${nconf.get('url')}/api/config`, function (err, res, body) {
var parsed;
assert.ifError(err);
assert.equal(res.statusCode, 200);
@@ -1675,7 +1675,7 @@ describe('Controllers', function () {
meta.configs.set('cookieConsentMessage', 'Julian\'s Message', function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/config', function (err, res, body) {
+ request(`${nconf.get('url')}/api/config`, function (err, res, body) {
var parsed;
assert.ifError(err);
assert.equal(res.statusCode, 200);
@@ -1694,7 +1694,7 @@ describe('Controllers', function () {
});
it('should return osd data', function (done) {
- request(nconf.get('url') + '/osd.xml', function (err, res, body) {
+ request(`${nconf.get('url')}/osd.xml`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1710,7 +1710,7 @@ describe('Controllers', function () {
});
it('should handle topic malformed uri', function (done) {
- request(nconf.get('url') + '/topic/1/a%AFc', function (err, res, body) {
+ request(`${nconf.get('url')}/topic/1/a%AFc`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1719,7 +1719,7 @@ describe('Controllers', function () {
});
it('should handle category malformed uri', function (done) {
- request(nconf.get('url') + '/category/1/a%AFc', function (err, res, body) {
+ request(`${nconf.get('url')}/category/1/a%AFc`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1728,7 +1728,7 @@ describe('Controllers', function () {
});
it('should handle malformed uri ', function (done) {
- request(nconf.get('url') + '/user/a%AFc', function (err, res, body) {
+ request(`${nconf.get('url')}/user/a%AFc`, function (err, res, body) {
assert.ifError(err);
assert(body);
assert.equal(res.statusCode, 400);
@@ -1737,7 +1737,7 @@ describe('Controllers', function () {
});
it('should handle malformed uri in api', function (done) {
- request(nconf.get('url') + '/api/user/a%AFc', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/a%AFc`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 400);
assert.equal(body.error, '[[global:400.title]]');
@@ -1755,7 +1755,7 @@ describe('Controllers', function () {
},
});
- request(nconf.get('url') + '/users', {}, function (err, res) {
+ request(`${nconf.get('url')}/users`, {}, function (err, res) {
plugins.loadedHooks['filter:router.page'] = [];
assert.ifError(err);
assert.equal(res.statusCode, 403);
@@ -1773,7 +1773,7 @@ describe('Controllers', function () {
},
});
- request(nconf.get('url') + '/users', {}, function (err, res, body) {
+ request(`${nconf.get('url')}/users`, {}, function (err, res, body) {
plugins.loadedHooks['filter:router.page'] = [];
assert.ifError(err);
assert.equal(res.statusCode, 403);
@@ -1794,7 +1794,7 @@ describe('Controllers', function () {
},
});
- request(nconf.get('url') + '/users', {}, function (err, res, body) {
+ request(`${nconf.get('url')}/users`, {}, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1814,7 +1814,7 @@ describe('Controllers', function () {
},
});
- request(nconf.get('url') + '/api/users', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/users`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(res.headers['x-redirect'], '/api/popular');
@@ -1832,7 +1832,7 @@ describe('Controllers', function () {
},
});
- request(nconf.get('url') + '/users', function (err, res, body) {
+ request(`${nconf.get('url')}/users`, function (err, res, body) {
plugins.loadedHooks['filter:router.page'] = [];
assert.ifError(err);
assert.equal(res.statusCode, 500);
@@ -1844,7 +1844,7 @@ describe('Controllers', function () {
describe('timeago locales', function () {
it('should load timeago locale', function (done) {
- request(nconf.get('url') + '/assets/src/modules/timeago/locales/jquery.timeago.af.js', function (err, res, body) {
+ request(`${nconf.get('url')}/assets/src/modules/timeago/locales/jquery.timeago.af.js`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body.includes('"gelede"'));
@@ -1853,7 +1853,7 @@ describe('Controllers', function () {
});
it('should return not found if NodeBB language exists but timeago locale does not exist', function (done) {
- request(nconf.get('url') + '/assets/src/modules/timeago/locales/jquery.timeago.ms.js', function (err, res, body) {
+ request(`${nconf.get('url')}/assets/src/modules/timeago/locales/jquery.timeago.ms.js`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -1861,7 +1861,7 @@ describe('Controllers', function () {
});
it('should return not found if NodeBB language does not exist', function (done) {
- request(nconf.get('url') + '/assets/src/modules/timeago/locales/jquery.timeago.muggle.js', function (err, res, body) {
+ request(`${nconf.get('url')}/assets/src/modules/timeago/locales/jquery.timeago.muggle.js`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -1880,7 +1880,7 @@ describe('Controllers', function () {
});
it('should return 404 if cid is not a number', function (done) {
- request(nconf.get('url') + '/api/category/fail', function (err, res) {
+ request(`${nconf.get('url')}/api/category/fail`, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -1888,7 +1888,7 @@ describe('Controllers', function () {
});
it('should return 404 if topic index is not a number', function (done) {
- request(nconf.get('url') + '/api/category/' + category.slug + '/invalidtopicindex', function (err, res) {
+ request(`${nconf.get('url')}/api/category/${category.slug}/invalidtopicindex`, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -1896,7 +1896,7 @@ describe('Controllers', function () {
});
it('should 404 if category does not exist', function (done) {
- request(nconf.get('url') + '/api/category/123123', function (err, res) {
+ request(`${nconf.get('url')}/api/category/123123`, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -1908,7 +1908,7 @@ describe('Controllers', function () {
assert.ifError(err);
categories.setCategoryField(category.cid, 'disabled', 1, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/category/' + category.slug, function (err, res) {
+ request(`${nconf.get('url')}/api/category/${category.slug}`, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -1922,7 +1922,7 @@ describe('Controllers', function () {
assert.ifError(err);
privileges.categories.rescind(['groups:read'], category.cid, 'guests', function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/category/' + category.slug, function (err, res) {
+ request(`${nconf.get('url')}/api/category/${category.slug}`, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 401);
done();
@@ -1932,7 +1932,7 @@ describe('Controllers', function () {
});
it('should redirect if topic index is negative', function (done) {
- request(nconf.get('url') + '/api/category/' + category.slug + '/-10', function (err, res) {
+ request(`${nconf.get('url')}/api/category/${category.slug}/-10`, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.ok(res.headers['x-redirect']);
@@ -1943,7 +1943,7 @@ describe('Controllers', function () {
it('should 404 if page is not found', function (done) {
user.setSetting(fooUid, 'usePagination', 1, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/category/' + category.slug + '?page=100', { jar: jar, json: true }, function (err, res) {
+ request(`${nconf.get('url')}/api/category/${category.slug}?page=100`, { jar: jar, json: true }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -1952,7 +1952,7 @@ describe('Controllers', function () {
});
it('should load page 1 if req.query.page is not sent', function (done) {
- request(nconf.get('url') + '/api/category/' + category.slug, { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/category/${category.slug}`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body.pagination.currentPage, 1);
@@ -1977,7 +1977,7 @@ describe('Controllers', function () {
topics.reply({ uid: fooUid, content: 'topic 2 reply', tid: data.topicData.tid }, next);
},
function (postData, next) {
- request(nconf.get('url') + '/api/category/' + category.slug + '?sort=most_posts', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/category/${category.slug}?sort=most_posts`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body.topics[0].title, 'topic 2');
@@ -2010,7 +2010,7 @@ describe('Controllers', function () {
topics.post({ uid: fooUid, cid: category.cid, title: 'topic 3', content: 'topic 3 OP', tags: ['java', 'cpp', 'best'] }, next);
},
function (data, next) {
- request(nconf.get('url') + '/api/category/' + category.slug + '?tag=node&author=foo', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/category/${category.slug}?tag=node&author=foo`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body.topics[0].title, 'topic 2');
@@ -2018,7 +2018,7 @@ describe('Controllers', function () {
});
},
function (next) {
- request(nconf.get('url') + '/api/category/' + category.slug + '?tag[]=java&tag[]=cpp', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/category/${category.slug}?tag[]=java&tag[]=cpp`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body.topics[0].title, 'topic 3');
@@ -2043,7 +2043,7 @@ describe('Controllers', function () {
function (_category, next) {
category = _category;
cid = category.cid;
- request(nconf.get('url') + '/api/category/' + category.slug, { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/category/${category.slug}`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(res.headers['x-redirect'], 'https://nodebb.org');
@@ -2055,7 +2055,7 @@ describe('Controllers', function () {
categories.setCategoryField(cid, 'link', '/recent', next);
},
function (next) {
- request(nconf.get('url') + '/api/category/' + category.slug, { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/category/${category.slug}`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(res.headers['x-redirect'], '/recent');
@@ -2090,7 +2090,7 @@ describe('Controllers', function () {
topics.post({ uid: fooUid, cid: childCategory2.cid, title: 'topic 1', content: 'topic 1 OP' }, next);
},
function (data, next) {
- request(nconf.get('url') + '/api/category/' + parentCategory.slug, { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/category/${parentCategory.slug}`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body.children[1].posts[0].content, 'topic 1 OP');
@@ -2112,7 +2112,7 @@ describe('Controllers', function () {
function (category, next) {
var titles = [];
for (var i = 0; i < 30; i++) {
- titles.push('topic title ' + i);
+ titles.push(`topic title ${i}`);
}
async.waterfall([
@@ -2125,7 +2125,7 @@ describe('Controllers', function () {
user.getSettings(fooUid, next);
},
function (settings, next) {
- request(nconf.get('url') + '/api/category/' + category.slug, { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/category/${category.slug}`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body.topics.length, settings.topicsPerPage);
@@ -2152,7 +2152,7 @@ describe('Controllers', function () {
});
it('should load unread page', function (done) {
- request(nconf.get('url') + '/api/unread', { jar: jar }, function (err, res) {
+ request(`${nconf.get('url')}/api/unread`, { jar: jar }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
done();
@@ -2160,7 +2160,7 @@ describe('Controllers', function () {
});
it('should 404 if filter is invalid', function (done) {
- request(nconf.get('url') + '/api/unread/doesnotexist', { jar: jar }, function (err, res) {
+ request(`${nconf.get('url')}/api/unread/doesnotexist`, { jar: jar }, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -2168,7 +2168,7 @@ describe('Controllers', function () {
});
it('should return total unread count', function (done) {
- request(nconf.get('url') + '/api/unread/total?filter=new', { jar: jar }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/unread/total?filter=new`, { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(body, 0);
@@ -2177,7 +2177,7 @@ describe('Controllers', function () {
});
it('should redirect if page is out of bounds', function (done) {
- request(nconf.get('url') + '/api/unread?page=-1', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/unread?page=-1`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(res.headers['x-redirect'], '/unread?page=1');
@@ -2189,7 +2189,7 @@ describe('Controllers', function () {
describe('admin middlewares', function () {
it('should redirect to login', function (done) {
- request(nconf.get('url') + '//api/admin/advanced/database', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}//api/admin/advanced/database`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 401);
done();
@@ -2197,7 +2197,7 @@ describe('Controllers', function () {
});
it('should redirect to login', function (done) {
- request(nconf.get('url') + '//admin/advanced/database', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}//admin/advanced/database`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body.includes('Login to your account'));
@@ -2216,7 +2216,7 @@ describe('Controllers', function () {
jar = _jar;
request({
- url: nconf.get('url') + '/api/config',
+ url: `${nconf.get('url')}/api/config`,
json: true,
jar: jar,
}, function (err, response, body) {
@@ -2228,12 +2228,12 @@ describe('Controllers', function () {
});
it('should load the composer route', function (done) {
- request(nconf.get('url') + '/api/compose', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/compose`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body.title);
assert(body.template);
- assert.equal(body.url, nconf.get('relative_path') + '/compose');
+ assert.equal(body.url, `${nconf.get('relative_path')}/compose`);
done();
});
});
@@ -2249,12 +2249,12 @@ describe('Controllers', function () {
method: hookMethod,
});
- request(nconf.get('url') + '/api/compose', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/compose`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body.title);
assert.strictEqual(body.template.name, '');
- assert.strictEqual(body.url, nconf.get('relative_path') + '/compose');
+ assert.strictEqual(body.url, `${nconf.get('relative_path')}/compose`);
plugins.hooks.unregister('myTestPlugin', 'filter:composer.build', hookMethod);
done();
@@ -2271,7 +2271,7 @@ describe('Controllers', function () {
method: hookMethod,
});
- request(nconf.get('url') + '/api/compose', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/compose`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
@@ -2282,7 +2282,7 @@ describe('Controllers', function () {
it('should error with invalid data', function (done) {
- request.post(nconf.get('url') + '/compose', {
+ request.post(`${nconf.get('url')}/compose`, {
form: {
content: 'a new reply',
},
@@ -2293,7 +2293,7 @@ describe('Controllers', function () {
}, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 400);
- request.post(nconf.get('url') + '/compose', {
+ request.post(`${nconf.get('url')}/compose`, {
form: {
tid: tid,
},
@@ -2315,7 +2315,7 @@ describe('Controllers', function () {
title: 'no js is good',
content: 'a topic with noscript',
};
- request.post(nconf.get('url') + '/compose', {
+ request.post(`${nconf.get('url')}/compose`, {
form: data,
jar: jar,
headers: {
@@ -2324,7 +2324,7 @@ describe('Controllers', function () {
}, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 302);
- request.post(nconf.get('url') + '/compose', {
+ request.post(`${nconf.get('url')}/compose`, {
form: {
tid: tid,
content: 'a new reply',
diff --git a/test/coverPhoto.js b/test/coverPhoto.js
index 1f3cfc27e9..d70690076f 100644
--- a/test/coverPhoto.js
+++ b/test/coverPhoto.js
@@ -11,14 +11,14 @@ describe('coverPhoto', function () {
it('should get default group cover', function (done) {
meta.config['groups:defaultCovers'] = '/assets/image1.png, /assets/image2.png';
var result = coverPhoto.getDefaultGroupCover('registered-users');
- assert.equal(result, nconf.get('relative_path') + '/assets/image2.png');
+ assert.equal(result, `${nconf.get('relative_path')}/assets/image2.png`);
done();
});
it('should get default default profile cover', function (done) {
meta.config['profile:defaultCovers'] = ' /assets/image1.png, /assets/image2.png ';
var result = coverPhoto.getDefaultProfileCover(1);
- assert.equal(result, nconf.get('relative_path') + '/assets/image2.png');
+ assert.equal(result, `${nconf.get('relative_path')}/assets/image2.png`);
done();
});
});
diff --git a/test/database/sorted.js b/test/database/sorted.js
index 2670e7e791..71bc9cd8bd 100644
--- a/test/database/sorted.js
+++ b/test/database/sorted.js
@@ -339,9 +339,9 @@ describe('Sorted Set methods', function () {
for (let i = 0; i < 400; i++) {
/* eslint-disable no-await-in-loop */
const bulkAdd = [];
- keys.push('testzset' + i);
+ keys.push(`testzset${i}`);
for (let k = 0; k < 100; k++) {
- bulkAdd.push(['testzset' + i, 1000000 + k + (i * 100), k + (i * 100)]);
+ bulkAdd.push([`testzset${i}`, 1000000 + k + (i * 100), k + (i * 100)]);
}
await db.sortedSetAddBulk(bulkAdd);
}
diff --git a/test/defer-logger.js b/test/defer-logger.js
index a3e5c91716..e6cdf1b721 100644
--- a/test/defer-logger.js
+++ b/test/defer-logger.js
@@ -32,6 +32,6 @@ after(function () {
console.log('\n\n');
winstonLogged.forEach(function (args) {
- console.log(args[0] + ' ' + args[1]);
+ console.log(`${args[0]} ${args[1]}`);
});
});
diff --git a/test/emailer.js b/test/emailer.js
index ed446a1029..689156102a 100644
--- a/test/emailer.js
+++ b/test/emailer.js
@@ -53,7 +53,7 @@ describe('emailer', function () {
method: function (data, next) {
assert(data);
assert.equal(data.to, email);
- assert.equal(data.subject, '[NodeBB] ' + params.subject);
+ assert.equal(data.subject, `[NodeBB] ${params.subject}`);
next(error);
},
diff --git a/test/feeds.js b/test/feeds.js
index 6f540c1c71..bbfdc6da79 100644
--- a/test/feeds.js
+++ b/test/feeds.js
@@ -49,17 +49,17 @@ describe('feeds', function () {
it('should 404', function (done) {
var feedUrls = [
- nconf.get('url') + '/topic/' + tid + '.rss',
- nconf.get('url') + '/category/' + cid + '.rss',
- nconf.get('url') + '/topics.rss',
- nconf.get('url') + '/recent.rss',
- nconf.get('url') + '/top.rss',
- nconf.get('url') + '/popular.rss',
- nconf.get('url') + '/popular/day.rss',
- nconf.get('url') + '/recentposts.rss',
- nconf.get('url') + '/category/' + cid + '/recentposts.rss',
- nconf.get('url') + '/user/foo/topics.rss',
- nconf.get('url') + '/tags/nodebb.rss',
+ `${nconf.get('url')}/topic/${tid}.rss`,
+ `${nconf.get('url')}/category/${cid}.rss`,
+ `${nconf.get('url')}/topics.rss`,
+ `${nconf.get('url')}/recent.rss`,
+ `${nconf.get('url')}/top.rss`,
+ `${nconf.get('url')}/popular.rss`,
+ `${nconf.get('url')}/popular/day.rss`,
+ `${nconf.get('url')}/recentposts.rss`,
+ `${nconf.get('url')}/category/${cid}/recentposts.rss`,
+ `${nconf.get('url')}/user/foo/topics.rss`,
+ `${nconf.get('url')}/tags/nodebb.rss`,
];
async.eachSeries(feedUrls, function (url, next) {
request(url, function (err, res) {
@@ -75,7 +75,7 @@ describe('feeds', function () {
});
it('should 404 if topic does not exist', function (done) {
- request(nconf.get('url') + '/topic/' + 1000 + '.rss', function (err, res) {
+ request(`${nconf.get('url')}/topic/${1000}.rss`, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -83,7 +83,7 @@ describe('feeds', function () {
});
it('should 404 if category id is not a number', function (done) {
- request(nconf.get('url') + '/category/invalid.rss', function (err, res) {
+ request(`${nconf.get('url')}/category/invalid.rss`, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -93,7 +93,7 @@ describe('feeds', function () {
it('should redirect if we do not have read privilege', function (done) {
privileges.categories.rescind(['groups:topics:read'], cid, 'guests', function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/topic/' + tid + '.rss', function (err, res, body) {
+ request(`${nconf.get('url')}/topic/${tid}.rss`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -104,7 +104,7 @@ describe('feeds', function () {
});
it('should 404 if user is not found', function (done) {
- request(nconf.get('url') + '/user/doesnotexist/topics.rss', function (err, res) {
+ request(`${nconf.get('url')}/user/doesnotexist/topics.rss`, function (err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
done();
@@ -114,7 +114,7 @@ describe('feeds', function () {
it('should redirect if we do not have read privilege', function (done) {
privileges.categories.rescind(['groups:read'], cid, 'guests', function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/category/' + cid + '.rss', function (err, res, body) {
+ request(`${nconf.get('url')}/category/${cid}.rss`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -136,7 +136,7 @@ describe('feeds', function () {
});
it('should load feed if its not private', function (done) {
- request(nconf.get('url') + '/category/' + cid + '.rss', { }, function (err, res, body) {
+ request(`${nconf.get('url')}/category/${cid}.rss`, { }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -150,10 +150,10 @@ describe('feeds', function () {
assert.ifError(err);
async.parallel({
test1: function (next) {
- request(nconf.get('url') + '/category/' + cid + '.rss?uid=' + fooUid, { }, next);
+ request(`${nconf.get('url')}/category/${cid}.rss?uid=${fooUid}`, { }, next);
},
test2: function (next) {
- request(nconf.get('url') + '/category/' + cid + '.rss?token=sometoken', { }, next);
+ request(`${nconf.get('url')}/category/${cid}.rss?token=sometoken`, { }, next);
},
}, function (err, results) {
assert.ifError(err);
@@ -167,7 +167,7 @@ describe('feeds', function () {
});
it('should not allow access if token is wrong', function (done) {
- request(nconf.get('url') + '/category/' + cid + '.rss?uid=' + fooUid + '&token=sometoken', { }, function (err, res, body) {
+ request(`${nconf.get('url')}/category/${cid}.rss?uid=${fooUid}&token=sometoken`, { }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body.includes('Login to your account'));
@@ -176,10 +176,10 @@ describe('feeds', function () {
});
it('should allow access if token is correct', function (done) {
- request(nconf.get('url') + '/api/category/' + cid, { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/category/${cid}`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
rssToken = body.rssFeedUrl.split('token')[1].slice(1);
- request(nconf.get('url') + '/category/' + cid + '.rss?uid=' + fooUid + '&token=' + rssToken, { }, function (err, res, body) {
+ request(`${nconf.get('url')}/category/${cid}.rss?uid=${fooUid}&token=${rssToken}`, { }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body.startsWith(' {
- await Groups.join('cid:' + category.cid + ':privileges:moderate', uid3);
+ await Groups.join(`cid:${category.cid}:privileges:moderate`, uid3);
await Flags.update(1, uid3, {
assignee: uid3,
@@ -438,7 +438,7 @@ describe('Flags', function () {
assignee = await db.getObjectField('flag:1', 'assignee');
assert.strictEqual(uid3, parseInt(assignee, 10));
- await Groups.leave('cid:' + category.cid + ':privileges:moderate', uid3);
+ await Groups.leave(`cid:${category.cid}:privileges:moderate`, uid3);
});
it('should do nothing when you attempt to set a bogus state', async () => {
@@ -462,14 +462,14 @@ describe('Flags', function () {
await sleep(2000);
let userNotifs = await User.notifications.getAll(adminUid);
- assert(userNotifs.includes('flag:post:' + result.postData.pid));
+ assert(userNotifs.includes(`flag:post:${result.postData.pid}`));
await Flags.update(flagId, adminUid, {
state: 'resolved',
});
userNotifs = await User.notifications.getAll(adminUid);
- assert(!userNotifs.includes('flag:post:' + result.postData.pid));
+ assert(!userNotifs.includes(`flag:post:${result.postData.pid}`));
});
});
@@ -658,7 +658,7 @@ describe('Flags', function () {
it('should retrieve a list of notes, from newest to oldest', function (done) {
Flags.getNotes(1, function (err, notes) {
assert.ifError(err);
- assert(notes[0].datetime > notes[1].datetime, notes[0].datetime + '-' + notes[1].datetime);
+ assert(notes[0].datetime > notes[1].datetime, `${notes[0].datetime}-${notes[1].datetime}`);
assert.strictEqual('this is the second note', notes[0].content);
done();
});
diff --git a/test/groups.js b/test/groups.js
index 3543499b97..b24521c34f 100644
--- a/test/groups.js
+++ b/test/groups.js
@@ -692,7 +692,7 @@ describe('Groups', function () {
assert.ifError(err);
User.getUserData(uid, function (err, data) {
assert.ifError(err);
- assert.equal(data.groupTitle, '["' + groupName + '"]');
+ assert.equal(data.groupTitle, `["${groupName}"]`);
assert.deepEqual(data.groupTitleArray, [groupName]);
done();
});
diff --git a/test/helpers/index.js b/test/helpers/index.js
index 38239aaee0..a85d2e9992 100644
--- a/test/helpers/index.js
+++ b/test/helpers/index.js
@@ -14,7 +14,7 @@ helpers.loginUser = function (username, password, callback) {
var jar = request.jar();
request({
- url: nconf.get('url') + '/api/config',
+ url: `${nconf.get('url')}/api/config`,
json: true,
jar: jar,
}, function (err, res, body) {
@@ -22,7 +22,7 @@ helpers.loginUser = function (username, password, callback) {
return callback(err || new Error('[[error:invalid-response]]'));
}
- request.post(nconf.get('url') + '/login', {
+ request.post(`${nconf.get('url')}/login`, {
form: {
username: username,
password: password,
@@ -44,7 +44,7 @@ helpers.loginUser = function (username, password, callback) {
helpers.logoutUser = function (jar, callback) {
request({
- url: nconf.get('url') + '/api/config',
+ url: `${nconf.get('url')}/api/config`,
json: true,
jar: jar,
}, function (err, response, body) {
@@ -52,7 +52,7 @@ helpers.logoutUser = function (jar, callback) {
return callback(err, response, body);
}
- request.post(nconf.get('url') + '/logout', {
+ request.post(`${nconf.get('url')}/logout`, {
form: {},
json: true,
jar: jar,
@@ -71,7 +71,7 @@ helpers.connectSocketIO = function (res, callback) {
cookies = cookies.filter(c => /express.sid=[^;]+;/.test(c));
const cookie = cookies[0];
var socket = io(nconf.get('base_url'), {
- path: nconf.get('relative_path') + '/socket.io',
+ path: `${nconf.get('relative_path')}/socket.io`,
extraHeaders: {
Origin: nconf.get('url'),
Cookie: cookie,
@@ -117,7 +117,7 @@ helpers.uploadFile = function (uploadEndPoint, filePath, body, jar, csrf_token,
helpers.registerUser = function (data, callback) {
var jar = request.jar();
request({
- url: nconf.get('url') + '/api/config',
+ url: `${nconf.get('url')}/api/config`,
json: true,
jar: jar,
}, function (err, response, body) {
@@ -125,7 +125,7 @@ helpers.registerUser = function (data, callback) {
return callback(err);
}
- request.post(nconf.get('url') + '/register', {
+ request.post(`${nconf.get('url')}/register`, {
form: data,
json: true,
jar: jar,
diff --git a/test/locale-detect.js b/test/locale-detect.js
index 5f865bbd7d..29b55ca1f5 100644
--- a/test/locale-detect.js
+++ b/test/locale-detect.js
@@ -11,7 +11,7 @@ describe('Language detection', function () {
it('should detect the language for a guest', function (done) {
meta.configs.set('autoDetectLang', 1, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/config', {
+ request(`${nconf.get('url')}/api/config`, {
headers: {
'Accept-Language': 'de-DE,de;q=0.5',
},
@@ -29,7 +29,7 @@ describe('Language detection', function () {
it('should do nothing when disabled', function (done) {
meta.configs.set('autoDetectLang', 0, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/config', {
+ request(`${nconf.get('url')}/api/config`, {
headers: {
'Accept-Language': 'de-DE,de;q=0.5',
},
diff --git a/test/messaging.js b/test/messaging.js
index 3ebe798a98..78b85e0598 100644
--- a/test/messaging.js
+++ b/test/messaging.js
@@ -406,8 +406,8 @@ describe('Messaging Library', function () {
assert(data.unread[0]);
var notification = data.unread[0];
assert.equal(notification.bodyShort, '[[notifications:new_message_from, foo]]');
- assert.equal(notification.nid, 'chat_' + fooUid + '_' + roomId);
- assert.equal(notification.path, nconf.get('relative_path') + '/chats/' + roomId);
+ assert.equal(notification.nid, `chat_${fooUid}_${roomId}`);
+ assert.equal(notification.path, `${nconf.get('relative_path')}/chats/${roomId}`);
done();
});
}, 1500);
@@ -533,7 +533,7 @@ describe('Messaging Library', function () {
});
it('should return true if user is dnd', function (done) {
- db.setObjectField('user:' + herpUid, 'status', 'dnd', function (err) {
+ db.setObjectField(`user:${herpUid}`, 'status', 'dnd', function (err) {
assert.ifError(err);
socketModules.chats.isDnD({ uid: fooUid }, herpUid, function (err, isDnD) {
assert.ifError(err);
@@ -669,7 +669,7 @@ describe('Messaging Library', function () {
it('should mark the message as deleted', function (done) {
socketModules.chats.delete({ uid: fooUid }, { messageId: mid, roomId: roomId }, function (err) {
assert.ifError(err);
- db.getObjectField('message:' + mid, 'deleted', function (err, value) {
+ db.getObjectField(`message:${mid}`, 'deleted', function (err, value) {
assert.ifError(err);
assert.strictEqual(1, parseInt(value, 10));
done();
@@ -712,7 +712,7 @@ describe('Messaging Library', function () {
it('should restore the message', function (done) {
socketModules.chats.restore({ uid: fooUid }, { messageId: mid, roomId: roomId }, function (err) {
assert.ifError(err);
- db.getObjectField('message:' + mid, 'deleted', function (err, value) {
+ db.getObjectField(`message:${mid}`, 'deleted', function (err, value) {
assert.ifError(err);
assert.strictEqual(0, parseInt(value, 10));
done();
@@ -763,7 +763,7 @@ describe('Messaging Library', function () {
describe('controller', function () {
it('should 404 if chat is disabled', function (done) {
meta.config.disableChat = 1;
- request(nconf.get('url') + '/user/baz/chats', function (err, response) {
+ request(`${nconf.get('url')}/user/baz/chats`, function (err, response) {
assert.ifError(err);
assert.equal(response.statusCode, 404);
done();
@@ -772,7 +772,7 @@ describe('Messaging Library', function () {
it('should 500 for guest with no privilege error', function (done) {
meta.config.disableChat = 0;
- request(nconf.get('url') + '/api/user/baz/chats', { json: true }, function (err, response, body) {
+ request(`${nconf.get('url')}/api/user/baz/chats`, { json: true }, function (err, response, body) {
assert.ifError(err);
assert.equal(response.statusCode, 500);
assert.equal(body.error, '[[error:no-privileges]]');
@@ -781,7 +781,7 @@ describe('Messaging Library', function () {
});
it('should 404 for non-existent user', function (done) {
- request(nconf.get('url') + '/user/doesntexist/chats', function (err, response) {
+ request(`${nconf.get('url')}/user/doesntexist/chats`, function (err, response) {
assert.ifError(err);
assert.equal(response.statusCode, 404);
done();
@@ -800,7 +800,7 @@ describe('Messaging Library', function () {
});
it('should return chats page data', function (done) {
- request(nconf.get('url') + '/api/user/herp/chats', { json: true, jar: jar }, function (err, response, body) {
+ request(`${nconf.get('url')}/api/user/herp/chats`, { json: true, jar: jar }, function (err, response, body) {
assert.ifError(err);
assert.equal(response.statusCode, 200);
assert(Array.isArray(body.rooms));
@@ -811,7 +811,7 @@ describe('Messaging Library', function () {
});
it('should return room data', function (done) {
- request(nconf.get('url') + '/api/user/herp/chats/' + roomId, { json: true, jar: jar }, function (err, response, body) {
+ request(`${nconf.get('url')}/api/user/herp/chats/${roomId}`, { json: true, jar: jar }, function (err, response, body) {
assert.ifError(err);
assert.equal(response.statusCode, 200);
assert.equal(body.roomId, roomId);
@@ -821,7 +821,7 @@ describe('Messaging Library', function () {
});
it('should redirect to chats page', function (done) {
- request(nconf.get('url') + '/api/chats', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/chats`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.equal(res.headers['x-redirect'], '/user/herp/chats');
@@ -833,7 +833,7 @@ describe('Messaging Library', function () {
it('should return 404 if user is not in room', function (done) {
helpers.loginUser('baz', 'quuxquux', function (err, jar) {
assert.ifError(err);
- request(nconf.get('url') + '/api/user/baz/chats/' + roomId, { json: true, jar: jar }, function (err, response) {
+ request(`${nconf.get('url')}/api/user/baz/chats/${roomId}`, { json: true, jar: jar }, function (err, response) {
assert.ifError(err);
assert.equal(response.statusCode, 404);
done();
diff --git a/test/meta.js b/test/meta.js
index 1946a94f16..1818f866da 100644
--- a/test/meta.js
+++ b/test/meta.js
@@ -491,7 +491,7 @@ describe('meta', function () {
describe('Access-Control-Allow-Origin', function () {
it('Access-Control-Allow-Origin header should be empty', function (done) {
var jar = request.jar();
- request.get(nconf.get('url') + '/api/search?term=bug', {
+ request.get(`${nconf.get('url')}/api/search?term=bug`, {
form: {},
json: true,
jar: jar,
@@ -506,7 +506,7 @@ describe('meta', function () {
var jar = request.jar();
var oldValue = meta.config['access-control-allow-origin'];
meta.config['access-control-allow-origin'] = 'test.com, mydomain.com';
- request.get(nconf.get('url') + '/api/search?term=bug', {
+ request.get(`${nconf.get('url')}/api/search?term=bug`, {
form: {
},
json: true,
@@ -526,7 +526,7 @@ describe('meta', function () {
var jar = request.jar();
var oldValue = meta.config['access-control-allow-origin'];
meta.config['access-control-allow-origin'] = 'test.com, mydomain.com';
- request.get(nconf.get('url') + '/api/search?term=bug', {
+ request.get(`${nconf.get('url')}/api/search?term=bug`, {
form: {
},
json: true,
@@ -546,7 +546,7 @@ describe('meta', function () {
var jar = request.jar();
var oldValue = meta.config['access-control-allow-origin-regex'];
meta.config['access-control-allow-origin-regex'] = 'match\\.this\\..+\\.domain.com, mydomain\\.com';
- request.get(nconf.get('url') + '/api/search?term=bug', {
+ request.get(`${nconf.get('url')}/api/search?term=bug`, {
form: {
},
json: true,
@@ -566,7 +566,7 @@ describe('meta', function () {
var jar = request.jar();
var oldValue = meta.config['access-control-allow-origin-regex'];
meta.config['access-control-allow-origin-regex'] = 'match\\.this\\..+\\.domain.com, mydomain\\.com';
- request.get(nconf.get('url') + '/api/search?term=bug', {
+ request.get(`${nconf.get('url')}/api/search?term=bug`, {
form: {
},
json: true,
@@ -586,7 +586,7 @@ describe('meta', function () {
var jar = request.jar();
var oldValue = meta.config['access-control-allow-origin-regex'];
meta.config['access-control-allow-origin-regex'] = '[match\\.this\\..+\\.domain.com, mydomain\\.com';
- request.get(nconf.get('url') + '/api/search?term=bug', {
+ request.get(`${nconf.get('url')}/api/search?term=bug`, {
form: {
},
json: true,
diff --git a/test/mocks/databasemock.js b/test/mocks/databasemock.js
index c5a9a5545b..841cd75000 100644
--- a/test/mocks/databasemock.js
+++ b/test/mocks/databasemock.js
@@ -41,7 +41,7 @@ nconf.set('relative_path', relativePath);
nconf.set('upload_path', path.join(nconf.get('base_dir'), nconf.get('upload_path')));
nconf.set('upload_url', '/assets/uploads');
nconf.set('url_parsed', urlObject);
-nconf.set('base_url', urlObject.protocol + '//' + urlObject.host);
+nconf.set('base_url', `${urlObject.protocol}//${urlObject.host}`);
nconf.set('secure', urlObject.protocol === 'https:');
nconf.set('use_port', !!urlObject.port);
nconf.set('port', urlObject.port || nconf.get('port') || (nconf.get('PORT_ENV_VAR') ? nconf.get(nconf.get('PORT_ENV_VAR')) : false) || 4567);
@@ -113,7 +113,7 @@ if (testDbConfig.database === productionDbConfig.database &&
nconf.set(dbType, testDbConfig);
winston.info('database config %s', dbType, testDbConfig);
-winston.info('environment ' + global.env);
+winston.info(`environment ${global.env}`);
const db = require('../../src/database');
@@ -125,7 +125,6 @@ before(async function () {
// Parse out the relative_url and other goodies from the configured URL
const urlObject = url.parse(nconf.get('url'));
-
nconf.set('core_templates_path', path.join(__dirname, '../../src/views'));
nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-persona/templates'));
nconf.set('theme_config', path.join(nconf.get('themes_path'), 'nodebb-theme-persona', 'theme.json'));
diff --git a/test/notifications.js b/test/notifications.js
index 2b147394de..292db1ee01 100644
--- a/test/notifications.js
+++ b/test/notifications.js
@@ -46,7 +46,7 @@ describe('Notifications', function () {
notification = _notification;
assert.ifError(err);
assert(notification);
- db.exists('notifications:' + notification.nid, function (err, exists) {
+ db.exists(`notifications:${notification.nid}`, function (err, exists) {
assert.ifError(err);
assert(exists);
db.isSortedSetMember('notifications', notification.nid, function (err, isMember) {
@@ -108,7 +108,7 @@ describe('Notifications', function () {
notifications.push(notification, [uid], function (err) {
assert.ifError(err);
setTimeout(function () {
- db.isSortedSetMember('uid:' + uid + ':notifications:unread', notification.nid, function (err, isMember) {
+ db.isSortedSetMember(`uid:${uid}:notifications:unread`, notification.nid, function (err, isMember) {
assert.ifError(err);
assert(isMember);
done();
@@ -121,7 +121,7 @@ describe('Notifications', function () {
notifications.pushGroup(notification, 'registered-users', function (err) {
assert.ifError(err);
setTimeout(function () {
- db.isSortedSetMember('uid:' + uid + ':notifications:unread', notification.nid, function (err, isMember) {
+ db.isSortedSetMember(`uid:${uid}:notifications:unread`, notification.nid, function (err, isMember) {
assert.ifError(err);
assert(isMember);
done();
@@ -134,7 +134,7 @@ describe('Notifications', function () {
notifications.pushGroups(notification, ['registered-users', 'administrators'], function (err) {
assert.ifError(err);
setTimeout(function () {
- db.isSortedSetMember('uid:' + uid + ':notifications:unread', notification.nid, function (err, isMember) {
+ db.isSortedSetMember(`uid:${uid}:notifications:unread`, notification.nid, function (err, isMember) {
assert.ifError(err);
assert(isMember);
done();
@@ -156,10 +156,10 @@ describe('Notifications', function () {
it('should mark a notification read', function (done) {
socketNotifications.markRead({ uid: uid }, notification.nid, function (err) {
assert.ifError(err);
- db.isSortedSetMember('uid:' + uid + ':notifications:unread', notification.nid, function (err, isMember) {
+ db.isSortedSetMember(`uid:${uid}:notifications:unread`, notification.nid, function (err, isMember) {
assert.ifError(err);
assert.equal(isMember, false);
- db.isSortedSetMember('uid:' + uid + ':notifications:read', notification.nid, function (err, isMember) {
+ db.isSortedSetMember(`uid:${uid}:notifications:read`, notification.nid, function (err, isMember) {
assert.ifError(err);
assert.equal(isMember, true);
done();
@@ -188,10 +188,10 @@ describe('Notifications', function () {
it('should mark a notification unread', function (done) {
socketNotifications.markUnread({ uid: uid }, notification.nid, function (err) {
assert.ifError(err);
- db.isSortedSetMember('uid:' + uid + ':notifications:unread', notification.nid, function (err, isMember) {
+ db.isSortedSetMember(`uid:${uid}:notifications:unread`, notification.nid, function (err, isMember) {
assert.ifError(err);
assert.equal(isMember, true);
- db.isSortedSetMember('uid:' + uid + ':notifications:read', notification.nid, function (err, isMember) {
+ db.isSortedSetMember(`uid:${uid}:notifications:read`, notification.nid, function (err, isMember) {
assert.ifError(err);
assert.equal(isMember, false);
socketNotifications.getCount({ uid: uid }, null, function (err, count) {
@@ -207,10 +207,10 @@ describe('Notifications', function () {
it('should mark all notifications read', function (done) {
socketNotifications.markAllRead({ uid: uid }, null, function (err) {
assert.ifError(err);
- db.isSortedSetMember('uid:' + uid + ':notifications:unread', notification.nid, function (err, isMember) {
+ db.isSortedSetMember(`uid:${uid}:notifications:unread`, notification.nid, function (err, isMember) {
assert.ifError(err);
assert.equal(isMember, false);
- db.isSortedSetMember('uid:' + uid + ':notifications:read', notification.nid, function (err, isMember) {
+ db.isSortedSetMember(`uid:${uid}:notifications:read`, notification.nid, function (err, isMember) {
assert.ifError(err);
assert.equal(isMember, true);
done();
@@ -286,7 +286,7 @@ describe('Notifications', function () {
},
function (notifications, next) {
assert.equal(notifications.unread.length, 1, 'there should be 1 unread notification');
- assert.equal(nconf.get('relative_path') + '/post/' + pid, notifications.unread[0].path, 'the notification should link to the first unread post');
+ assert.equal(`${nconf.get('relative_path')}/post/${pid}`, notifications.unread[0].path, 'the notification should link to the first unread post');
next();
},
], function (err) {
@@ -300,7 +300,7 @@ describe('Notifications', function () {
assert.ifError(err);
assert.equal(data[0].bodyShort, 'bodyShort');
assert.equal(data[0].nid, 'notification_id');
- assert.equal(data[0].path, nconf.get('relative_path') + '/notification/path');
+ assert.equal(data[0].path, `${nconf.get('relative_path')}/notification/path`);
done();
});
});
@@ -450,7 +450,7 @@ describe('Notifications', function () {
user.notifications.getAll(uid, '', function (err, data) {
meta.config.welcomeNotification = '';
assert.ifError(err);
- assert(data.includes('welcome_' + uid), data);
+ assert(data.includes(`welcome_${uid}`), data);
done();
});
}, 2000);
diff --git a/test/plugins.js b/test/plugins.js
index 6af4dc774f..61e8c77652 100644
--- a/test/plugins.js
+++ b/test/plugins.js
@@ -13,7 +13,7 @@ var plugins = require('../src/plugins');
describe('Plugins', function () {
it('should load plugin data', function (done) {
var pluginId = 'nodebb-plugin-markdown';
- plugins.loadPlugin(path.join(nconf.get('base_dir'), 'node_modules/' + pluginId), function (err) {
+ plugins.loadPlugin(path.join(nconf.get('base_dir'), `node_modules/${pluginId}`), function (err) {
assert.ifError(err);
assert(plugins.libraries[pluginId]);
assert(plugins.loadedHooks['static:app.load']);
@@ -256,7 +256,7 @@ describe('Plugins', function () {
describe('static assets', function () {
it('should 404 if resource does not exist', function (done) {
- request.get(nconf.get('url') + '/plugins/doesnotexist/should404.tpl', function (err, res, body) {
+ request.get(`${nconf.get('url')}/plugins/doesnotexist/should404.tpl`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
assert(body);
@@ -265,7 +265,7 @@ describe('Plugins', function () {
});
it('should 404 if resource does not exist', function (done) {
- request.get(nconf.get('url') + '/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/should404.tpl', function (err, res, body) {
+ request.get(`${nconf.get('url')}/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/should404.tpl`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 404);
assert(body);
@@ -274,7 +274,7 @@ describe('Plugins', function () {
});
it('should get resource', function (done) {
- request.get(nconf.get('url') + '/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/dbsearch.tpl', function (err, res, body) {
+ request.get(`${nconf.get('url')}/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/dbsearch.tpl`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
diff --git a/test/posts.js b/test/posts.js
index 9c32d90c89..2cd1f6ffaf 100644
--- a/test/posts.js
+++ b/test/posts.js
@@ -76,7 +76,7 @@ describe('Post\'s', function () {
it('should update category teaser properly', async function () {
const util = require('util');
const getCategoriesAsync = util.promisify(async function getCategories(callback) {
- request(nconf.get('url') + '/api/categories', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/categories`, { json: true }, function (err, res, body) {
callback(err, body);
});
});
@@ -112,11 +112,11 @@ describe('Post\'s', function () {
const pid1 = postResult.postData.pid;
const pid2 = postData.pid;
- assert.deepStrictEqual(await db.sortedSetScores('tid:' + postResult.topicData.tid + ':posters', [oldUid, newUid]), [2, null]);
+ assert.deepStrictEqual(await db.sortedSetScores(`tid:${postResult.topicData.tid}:posters`, [oldUid, newUid]), [2, null]);
await posts.changeOwner([pid1, pid2], newUid);
- assert.deepStrictEqual(await db.sortedSetScores('tid:' + postResult.topicData.tid + ':posters', [oldUid, newUid]), [0, 2]);
+ assert.deepStrictEqual(await db.sortedSetScores(`tid:${postResult.topicData.tid}:posters`, [oldUid, newUid]), [0, 2]);
assert.deepStrictEqual(await posts.isOwner([pid1, pid2], oldUid), [false, false]);
assert.deepStrictEqual(await posts.isOwner([pid1, pid2], newUid), [true, true]);
@@ -282,7 +282,7 @@ describe('Post\'s', function () {
describe('bookmarking', function () {
it('should bookmark a post', function (done) {
- socketPosts.bookmark({ uid: voterUid }, { pid: postData.pid, room_id: 'topic_' + postData.tid }, function (err, data) {
+ socketPosts.bookmark({ uid: voterUid }, { pid: postData.pid, room_id: `topic_${postData.tid}` }, function (err, data) {
assert.ifError(err);
assert.equal(data.isBookmarked, true);
posts.hasBookmarked(postData.pid, voterUid, function (err, hasBookmarked) {
@@ -294,7 +294,7 @@ describe('Post\'s', function () {
});
it('should unbookmark a post', function (done) {
- socketPosts.unbookmark({ uid: voterUid }, { pid: postData.pid, room_id: 'topic_' + postData.tid }, function (err, data) {
+ socketPosts.unbookmark({ uid: voterUid }, { pid: postData.pid, room_id: `topic_${postData.tid}` }, function (err, data) {
assert.ifError(err);
assert.equal(data.isBookmarked, false);
posts.hasBookmarked([postData.pid], voterUid, function (err, hasBookmarked) {
@@ -394,7 +394,7 @@ describe('Post\'s', function () {
assert.ifError(err);
var jar = _jar;
- request(nconf.get('url') + '/api/topic/' + tid, { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/topic/${tid}`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(body.posts[1].content, '[[topic:post_is_deleted]]');
privileges.categories.give(['groups:posts:view_deleted'], cid, 'Global Moderators', next);
@@ -448,7 +448,7 @@ describe('Post\'s', function () {
createTopicWithReply(function (topicPostData, replyData) {
socketPosts.purgePosts({ uid: voterUid }, { pids: [replyData.pid, topicPostData.postData.pid], tid: topicPostData.topicData.tid }, function (err) {
assert.ifError(err);
- posts.exists('post:' + replyData.pid, function (err, exists) {
+ posts.exists(`post:${replyData.pid}`, function (err, exists) {
assert.ifError(err);
assert.equal(exists, false);
topics.exists(topicPostData.topicData.tid, function (err, exists) {
@@ -505,7 +505,7 @@ describe('Post\'s', function () {
it('should error if title is too short', function (done) {
socketPosts.edit({ uid: voterUid }, { pid: pid, content: 'edited post content', title: 'a' }, function (err) {
- assert.equal(err.message, '[[error:title-too-short, ' + meta.config.minimumTitleLength + ']]');
+ assert.equal(err.message, `[[error:title-too-short, ${meta.config.minimumTitleLength}]]`);
done();
});
});
@@ -513,7 +513,7 @@ describe('Post\'s', function () {
it('should error if title is too long', function (done) {
var longTitle = new Array(meta.config.maximumTitleLength + 2).join('a');
socketPosts.edit({ uid: voterUid }, { pid: pid, content: 'edited post content', title: longTitle }, function (err) {
- assert.equal(err.message, '[[error:title-too-long, ' + meta.config.maximumTitleLength + ']]');
+ assert.equal(err.message, `[[error:title-too-long, ${meta.config.maximumTitleLength}]]`);
done();
});
});
@@ -522,7 +522,7 @@ describe('Post\'s', function () {
var oldValue = meta.config.minimumTagsPerTopic;
meta.config.minimumTagsPerTopic = 1;
socketPosts.edit({ uid: voterUid }, { pid: pid, content: 'edited post content', tags: [] }, function (err) {
- assert.equal(err.message, '[[error:not-enough-tags, ' + meta.config.minimumTagsPerTopic + ']]');
+ assert.equal(err.message, `[[error:not-enough-tags, ${meta.config.minimumTagsPerTopic}]]`);
meta.config.minimumTagsPerTopic = oldValue;
done();
});
@@ -531,17 +531,17 @@ describe('Post\'s', function () {
it('should error with too many tags', function (done) {
var tags = [];
for (var i = 0; i < meta.config.maximumTagsPerTopic + 1; i += 1) {
- tags.push('tag' + i);
+ tags.push(`tag${i}`);
}
socketPosts.edit({ uid: voterUid }, { pid: pid, content: 'edited post content', tags: tags }, function (err) {
- assert.equal(err.message, '[[error:too-many-tags, ' + meta.config.maximumTagsPerTopic + ']]');
+ assert.equal(err.message, `[[error:too-many-tags, ${meta.config.maximumTagsPerTopic}]]`);
done();
});
});
it('should error if content is too short', function (done) {
socketPosts.edit({ uid: voterUid }, { pid: pid, content: 'e' }, function (err) {
- assert.equal(err.message, '[[error:content-too-short, ' + meta.config.minimumPostLength + ']]');
+ assert.equal(err.message, `[[error:content-too-short, ${meta.config.minimumPostLength}]]`);
done();
});
});
@@ -549,7 +549,7 @@ describe('Post\'s', function () {
it('should error if content is too long', function (done) {
var longContent = new Array(meta.config.maximumPostLength + 2).join('a');
socketPosts.edit({ uid: voterUid }, { pid: pid, content: longContent }, function (err) {
- assert.equal(err.message, '[[error:content-too-long, ' + meta.config.maximumPostLength + ']]');
+ assert.equal(err.message, `[[error:content-too-long, ${meta.config.maximumPostLength}]]`);
done();
});
});
@@ -566,7 +566,7 @@ describe('Post\'s', function () {
assert.strictEqual(data.editor, voterUid);
assert.strictEqual(data.topic.title, 'edited title');
assert.strictEqual(data.topic.tags[0].value, 'edited');
- const res = await db.getObject('post:' + pid);
+ const res = await db.getObject(`post:${pid}`);
assert(!res.hasOwnProperty('bookmarks'));
});
@@ -845,7 +845,7 @@ describe('Post\'s', function () {
var nconf = require('nconf');
var content = 'test youtube';
var parsedContent = posts.relativeToAbsolute(content, posts.urlRegex);
- assert.equal(parsedContent, 'test youtube');
+ assert.equal(parsedContent, `test youtube`);
done();
});
@@ -854,7 +854,7 @@ describe('Post\'s', function () {
var content = 'test youtube some test
';
var parsedContent = posts.relativeToAbsolute(content, posts.urlRegex);
parsedContent = posts.relativeToAbsolute(parsedContent, posts.imgRegex);
- assert.equal(parsedContent, 'test youtube some test
');
+ assert.equal(parsedContent, `test youtube some test
`);
done();
});
});
@@ -1097,7 +1097,7 @@ describe('Post\'s', function () {
helpers.loginUser('globalmod', 'globalmodpwd', function (err, _jar) {
jar = _jar;
assert.ifError(err);
- request(nconf.get('url') + '/api/post-queue', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/post-queue`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(body.posts[0].type, 'topic');
assert.equal(body.posts[0].data.content, 'queued topic content');
@@ -1118,7 +1118,7 @@ describe('Post\'s', function () {
it('should edit post in queue', function (done) {
socketPosts.editQueuedContent({ uid: globalModUid }, { id: queueId, content: 'newContent' }, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/post-queue', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/post-queue`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(body.posts[1].type, 'reply');
assert.equal(body.posts[1].data.content, 'newContent');
@@ -1130,7 +1130,7 @@ describe('Post\'s', function () {
it('should edit topic title in queue', function (done) {
socketPosts.editQueuedContent({ uid: globalModUid }, { id: topicQueueId, title: 'new topic title' }, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/post-queue', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/post-queue`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(body.posts[0].type, 'topic');
assert.equal(body.posts[0].data.title, 'new topic title');
@@ -1142,7 +1142,7 @@ describe('Post\'s', function () {
it('should edit topic category in queue', function (done) {
socketPosts.editQueuedContent({ uid: globalModUid }, { id: topicQueueId, cid: 2 }, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/post-queue', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/post-queue`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(body.posts[0].type, 'topic');
assert.equal(body.posts[0].data.cid, 2);
@@ -1232,7 +1232,7 @@ describe('Post\'s', function () {
posts.uploads.sync(pid, function (err) {
assert.ifError(err);
- db.sortedSetCard('post:' + pid + ':uploads', function (err, length) {
+ db.sortedSetCard(`post:${pid}:uploads`, function (err, length) {
assert.ifError(err);
assert.strictEqual(length, 2);
done();
@@ -1252,7 +1252,7 @@ describe('Post\'s', function () {
async.apply(posts.uploads.sync, pid),
], function (err) {
assert.ifError(err);
- db.sortedSetCard('post:' + pid + ':uploads', function (err, length) {
+ db.sortedSetCard(`post:${pid}:uploads`, function (err, length) {
assert.ifError(err);
assert.strictEqual(1, length);
done();
@@ -1323,7 +1323,7 @@ describe('Post\'s', function () {
async.waterfall([
async.apply(posts.uploads.associate, pid, ['test.bmp']),
function (next) {
- db.getSortedSetRange('upload:' + md5('test.bmp') + ':pids', 0, -1, next);
+ db.getSortedSetRange(`upload:${md5('test.bmp')}:pids`, 0, -1, next);
},
], function (err, pids) {
assert.ifError(err);
@@ -1426,7 +1426,7 @@ describe('Post\'s', function () {
});
it('should automatically sync uploads on topic create and reply', function (done) {
- db.sortedSetsCard(['post:' + topic.topicData.mainPid + ':uploads', 'post:' + reply.pid + ':uploads'], function (err, lengths) {
+ db.sortedSetsCard([`post:${topic.topicData.mainPid}:uploads`, `post:${reply.pid}:uploads`], function (err, lengths) {
assert.ifError(err);
assert.strictEqual(1, lengths[0]);
assert.strictEqual(1, lengths[1]);
diff --git a/test/search.js b/test/search.js
index f9af50157c..6c2c690674 100644
--- a/test/search.js
+++ b/test/search.js
@@ -106,7 +106,7 @@ describe('Search', function () {
it('should search term in titles and posts', function (done) {
var meta = require('../src/meta');
- var qs = '/api/search?term=cucumber&in=titlesposts&categories[]=' + cid1 + '&by=phoebe&replies=1&repliesFilter=atleast&sortBy=timestamp&sortDirection=desc&showAs=posts';
+ var qs = `/api/search?term=cucumber&in=titlesposts&categories[]=${cid1}&by=phoebe&replies=1&repliesFilter=atleast&sortBy=timestamp&sortDirection=desc&showAs=posts`;
privileges.global.give(['groups:search:content'], 'guests', function (err) {
assert.ifError(err);
request({
diff --git a/test/socket.io.js b/test/socket.io.js
index 3c3241d599..679dec1ba2 100644
--- a/test/socket.io.js
+++ b/test/socket.io.js
@@ -55,13 +55,13 @@ describe('socket.io', function () {
it('should connect and auth properly', function (done) {
request.get({
- url: nconf.get('url') + '/api/config',
+ url: `${nconf.get('url')}/api/config`,
jar: cookies,
json: true,
}, function (err, res, body) {
assert.ifError(err);
- request.post(nconf.get('url') + '/login', {
+ request.post(`${nconf.get('url')}/login`, {
jar: cookies,
form: {
username: 'admin',
diff --git a/test/template-helpers.js b/test/template-helpers.js
index fb1044bf3b..c48d436c64 100644
--- a/test/template-helpers.js
+++ b/test/template-helpers.js
@@ -102,7 +102,7 @@ describe('helpers', function () {
],
};
var html = helpers.generateChildrenCategories(category);
- assert.equal(html, '
children');
+ assert.equal(html, `
children`);
done();
});
@@ -155,42 +155,42 @@ describe('helpers', function () {
it('should render thumb as topic image', function (done) {
var topicObj = { thumb: '/uploads/1.png', user: { username: 'baris' } };
var html = helpers.renderTopicImage(topicObj);
- assert.equal(html, '
');
+ assert.equal(html, `
`);
done();
});
it('should render user picture as topic image', function (done) {
var topicObj = { thumb: '', user: { uid: 1, username: 'baris', picture: '/uploads/2.png' } };
var html = helpers.renderTopicImage(topicObj);
- assert.equal(html, '
');
+ assert.equal(html, `
`);
done();
});
it('should render digest avatar', function (done) {
var block = { teaser: { user: { username: 'baris', picture: '/uploads/1.png' } } };
var html = helpers.renderDigestAvatar(block);
- assert.equal(html, '
');
+ assert.equal(html, `
`);
done();
});
it('should render digest avatar', function (done) {
var block = { teaser: { user: { username: 'baris', 'icon:text': 'B', 'icon:bgColor': '#ff000' } } };
var html = helpers.renderDigestAvatar(block);
- assert.equal(html, '' + block.teaser.user['icon:text'] + '
');
+ assert.equal(html, `${block.teaser.user['icon:text']}
`);
done();
});
it('should render digest avatar', function (done) {
var block = { user: { username: 'baris', picture: '/uploads/1.png' } };
var html = helpers.renderDigestAvatar(block);
- assert.equal(html, '
');
+ assert.equal(html, `
`);
done();
});
it('should render digest avatar', function (done) {
var block = { user: { username: 'baris', 'icon:text': 'B', 'icon:bgColor': '#ff000' } };
var html = helpers.renderDigestAvatar(block);
- assert.equal(html, '' + block.user['icon:text'] + '
');
+ assert.equal(html, `${block.user['icon:text']}
`);
done();
});
diff --git a/test/topics.js b/test/topics.js
index 3cbca7be5d..b38e672ff7 100644
--- a/test/topics.js
+++ b/test/topics.js
@@ -123,7 +123,7 @@ describe('Topic\'s', function () {
name: 'Test Category',
description: 'Test category created by testing script',
});
- const result = await requestType('post', nconf.get('url') + '/api/v3/topics', {
+ const result = await requestType('post', `${nconf.get('url')}/api/v3/topics`, {
form: {
title: 'just a title',
cid: categoryObj.cid,
@@ -142,7 +142,7 @@ describe('Topic\'s', function () {
await privileges.categories.give(['groups:topics:create'], categoryObj.cid, 'guests');
await privileges.categories.give(['groups:topics:reply'], categoryObj.cid, 'guests');
- const result = await requestType('post', nconf.get('url') + '/api/v3/topics', {
+ const result = await requestType('post', `${nconf.get('url')}/api/v3/topics`, {
form: {
title: 'just a title',
cid: categoryObj.cid,
@@ -155,7 +155,7 @@ describe('Topic\'s', function () {
assert.strictEqual(result.body.response.title, 'just a title');
assert.strictEqual(result.body.response.user.username, '[[global:guest]]');
- const replyResult = await requestType('post', nconf.get('url') + '/api/v3/topics/' + result.body.response.tid, {
+ const replyResult = await requestType('post', `${nconf.get('url')}/api/v3/topics/${result.body.response.tid}`, {
form: {
content: 'a reply by guest',
},
@@ -330,13 +330,13 @@ describe('Topic\'s', function () {
tid = result.topicData.tid;
for (let i = 0; i < 30; i++) {
// eslint-disable-next-line no-await-in-loop
- await topics.reply({ uid: adminUid, content: 'topic reply ' + (i + 1), tid: tid });
+ await topics.reply({ uid: adminUid, content: `topic reply ${i + 1}`, tid: tid });
}
});
it('should get a topic with posts and other data', async function () {
const topicData = await topics.getTopicData(tid);
- const data = await topics.getTopicWithPosts(topicData, 'tid:' + tid + ':posts', topic.userId, 0, -1, false);
+ const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, 0, -1, false);
assert(data);
assert.equal(data.category.cid, topic.categoryId);
assert.equal(data.unreplied, false);
@@ -347,7 +347,7 @@ describe('Topic\'s', function () {
it('should return first 3 posts including main post', async function () {
const topicData = await topics.getTopicData(tid);
- const data = await topics.getTopicWithPosts(topicData, 'tid:' + tid + ':posts', topic.userId, 0, 2, false);
+ const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, 0, 2, false);
assert.strictEqual(data.posts.length, 3);
assert.strictEqual(data.posts[0].content, 'main post');
assert.strictEqual(data.posts[1].content, 'topic reply 1');
@@ -360,7 +360,7 @@ describe('Topic\'s', function () {
it('should return 3 posts from 1 to 3 excluding main post', async function () {
const topicData = await topics.getTopicData(tid);
const start = 1;
- const data = await topics.getTopicWithPosts(topicData, 'tid:' + tid + ':posts', topic.userId, start, 3, false);
+ const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, start, 3, false);
assert.strictEqual(data.posts.length, 3);
assert.strictEqual(data.posts[0].content, 'topic reply 1');
assert.strictEqual(data.posts[1].content, 'topic reply 2');
@@ -372,7 +372,7 @@ describe('Topic\'s', function () {
it('should return main post and last 2 posts', async function () {
const topicData = await topics.getTopicData(tid);
- const data = await topics.getTopicWithPosts(topicData, 'tid:' + tid + ':posts', topic.userId, 0, 2, true);
+ const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, 0, 2, true);
assert.strictEqual(data.posts.length, 3);
assert.strictEqual(data.posts[0].content, 'main post');
assert.strictEqual(data.posts[1].content, 'topic reply 30');
@@ -385,7 +385,7 @@ describe('Topic\'s', function () {
it('should return last 3 posts and not main post', async function () {
const topicData = await topics.getTopicData(tid);
const start = 1;
- const data = await topics.getTopicWithPosts(topicData, 'tid:' + tid + ':posts', topic.userId, start, 3, true);
+ const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, start, 3, true);
assert.strictEqual(data.posts.length, 3);
assert.strictEqual(data.posts[0].content, 'topic reply 30');
assert.strictEqual(data.posts[1].content, 'topic reply 29');
@@ -398,7 +398,7 @@ describe('Topic\'s', function () {
it('should return posts 29 to 27 posts and not main post', async function () {
const topicData = await topics.getTopicData(tid);
const start = 2;
- const data = await topics.getTopicWithPosts(topicData, 'tid:' + tid + ':posts', topic.userId, start, 4, true);
+ const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, start, 4, true);
assert.strictEqual(data.posts.length, 3);
assert.strictEqual(data.posts[0].content, 'topic reply 29');
assert.strictEqual(data.posts[1].content, 'topic reply 28');
@@ -411,7 +411,7 @@ describe('Topic\'s', function () {
it('should return 3 posts in reverse', async function () {
const topicData = await topics.getTopicData(tid);
const start = 28;
- const data = await topics.getTopicWithPosts(topicData, 'tid:' + tid + ':posts', topic.userId, start, 30, true);
+ const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, start, 30, true);
assert.strictEqual(data.posts.length, 3);
assert.strictEqual(data.posts[0].content, 'topic reply 3');
assert.strictEqual(data.posts[1].content, 'topic reply 2');
@@ -423,7 +423,7 @@ describe('Topic\'s', function () {
it('should get all posts with main post at the start', async function () {
const topicData = await topics.getTopicData(tid);
- const data = await topics.getTopicWithPosts(topicData, 'tid:' + tid + ':posts', topic.userId, 0, -1, false);
+ const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, 0, -1, false);
assert.strictEqual(data.posts.length, 31);
assert.strictEqual(data.posts[0].content, 'main post');
assert.strictEqual(data.posts[1].content, 'topic reply 1');
@@ -435,7 +435,7 @@ describe('Topic\'s', function () {
it('should get all posts in reverse with main post at the start followed by reply 30', async function () {
const topicData = await topics.getTopicData(tid);
- const data = await topics.getTopicWithPosts(topicData, 'tid:' + tid + ':posts', topic.userId, 0, -1, true);
+ const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, 0, -1, true);
assert.strictEqual(data.posts.length, 31);
assert.strictEqual(data.posts[0].content, 'main post');
assert.strictEqual(data.posts[1].content, 'topic reply 30');
@@ -604,28 +604,28 @@ describe('Topic\'s', function () {
},
scores1: function (next) {
db.sortedSetsScore([
- 'cid:' + cid1 + ':tids',
- 'cid:' + cid1 + ':tids:lastposttime',
- 'cid:' + cid1 + ':tids:posts',
+ `cid:${cid1}:tids`,
+ `cid:${cid1}:tids:lastposttime`,
+ `cid:${cid1}:tids:posts`,
], tid1, next);
},
scores2: function (next) {
db.sortedSetsScore([
- 'cid:' + cid2 + ':tids',
- 'cid:' + cid2 + ':tids:lastposttime',
- 'cid:' + cid2 + ':tids:posts',
+ `cid:${cid2}:tids`,
+ `cid:${cid2}:tids:lastposttime`,
+ `cid:${cid2}:tids:posts`,
], tid2, next);
},
posts1: function (next) {
- db.getSortedSetRangeWithScores('tid:' + tid1 + ':posts', 0, -1, next);
+ db.getSortedSetRangeWithScores(`tid:${tid1}:posts`, 0, -1, next);
},
posts2: function (next) {
- db.getSortedSetRangeWithScores('tid:' + tid2 + ':posts', 0, -1, next);
+ db.getSortedSetRangeWithScores(`tid:${tid2}:posts`, 0, -1, next);
},
}, next);
},
function (results, next) {
- var assertMsg = JSON.stringify(results.posts1) + '\n' + JSON.stringify(results.posts2);
+ var assertMsg = `${JSON.stringify(results.posts1)}\n${JSON.stringify(results.posts2)}`;
assert.equal(results.topicData[0].postcount, results.scores1[2], assertMsg);
assert.equal(results.topicData[1].postcount, results.scores2[2], assertMsg);
assert.equal(results.topicData[0].lastposttime, post1.timestamp, assertMsg);
@@ -672,7 +672,7 @@ describe('Topic\'s', function () {
checkCidSets(movedPost, postData, next);
},
function (next) {
- db.isMemberOfSortedSets(['cid:' + cid1 + ':pids', 'cid:' + cid2 + ':pids'], movedPost.pid, next);
+ db.isMemberOfSortedSets([`cid:${cid1}:pids`, `cid:${cid2}:pids`], movedPost.pid, next);
},
function (isMember, next) {
assert.deepEqual(isMember, [true, false]);
@@ -687,7 +687,7 @@ describe('Topic\'s', function () {
checkCidSets(previousPost, topic2LastReply, next);
},
function (next) {
- db.isMemberOfSortedSets(['cid:' + cid1 + ':pids', 'cid:' + cid2 + ':pids'], movedPost.pid, next);
+ db.isMemberOfSortedSets([`cid:${cid1}:pids`, `cid:${cid2}:pids`], movedPost.pid, next);
},
function (isMember, next) {
assert.deepEqual(isMember, [false, true]);
@@ -736,7 +736,7 @@ describe('Topic\'s', function () {
it('should purge the topic', function (done) {
socketTopics.purge({ uid: adminUid }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) {
assert.ifError(err);
- db.isSortedSetMember('uid:' + followerUid + ':followed_tids', newTopic.tid, function (err, isMember) {
+ db.isSortedSetMember(`uid:${followerUid}:followed_tids`, newTopic.tid, function (err, isMember) {
assert.ifError(err);
assert.strictEqual(false, isMember);
done();
@@ -827,7 +827,7 @@ describe('Topic\'s', function () {
it('should not do anything if topics are not pinned', function (done) {
socketTopics.orderPinnedTopics({ uid: adminUid }, [{ tid: tid3 }], function (err) {
assert.ifError(err);
- db.isSortedSetMember('cid:' + topic.categoryId + ':tids:pinned', tid3, function (err, isMember) {
+ db.isSortedSetMember(`cid:${topic.categoryId}:tids:pinned`, tid3, function (err, isMember) {
assert.ifError(err);
assert(!isMember);
done();
@@ -836,13 +836,13 @@ describe('Topic\'s', function () {
});
it('should order pinned topics', function (done) {
- db.getSortedSetRevRange('cid:' + topic.categoryId + ':tids:pinned', 0, -1, function (err, pinnedTids) {
+ db.getSortedSetRevRange(`cid:${topic.categoryId}:tids:pinned`, 0, -1, function (err, pinnedTids) {
assert.ifError(err);
assert.equal(pinnedTids[0], tid2);
assert.equal(pinnedTids[1], tid1);
socketTopics.orderPinnedTopics({ uid: adminUid }, [{ tid: tid1, order: 1 }, { tid: tid2, order: 0 }], function (err) {
assert.ifError(err);
- db.getSortedSetRevRange('cid:' + topic.categoryId + ':tids:pinned', 0, -1, function (err, pinnedTids) {
+ db.getSortedSetRevRange(`cid:${topic.categoryId}:tids:pinned`, 0, -1, function (err, pinnedTids) {
assert.ifError(err);
assert.equal(pinnedTids[0], tid1);
assert.equal(pinnedTids[1], tid2);
@@ -971,7 +971,7 @@ describe('Topic\'s', function () {
var topicPids;
var originalBookmark = 6;
function postReply(next) {
- topics.reply({ uid: topic.userId, content: 'test post ' + replies.length, tid: newTopic.tid }, function (err, result) {
+ topics.reply({ uid: topic.userId, content: `test post ${replies.length}`, tid: newTopic.tid }, function (err, result) {
assert.equal(err, null, 'was created with error');
assert.ok(result);
replies.push(result);
@@ -1084,11 +1084,11 @@ describe('Topic\'s', function () {
await posts.upvote(result.postData.pid, adminUid);
await posts.upvote(reply1.pid, adminUid);
assert.strictEqual(await db.sortedSetScore('topics:votes', result.topicData.tid), 1);
- assert.strictEqual(await db.sortedSetScore('cid:' + categoryObj.cid + ':tids:votes', result.topicData.tid), 1);
+ assert.strictEqual(await db.sortedSetScore(`cid:${categoryObj.cid}:tids:votes`, result.topicData.tid), 1);
const newTopic = await topics.createTopicFromPosts(adminUid, 'Fork test, vote update', [reply1.pid, reply2.pid], result.topicData.tid);
assert.strictEqual(await db.sortedSetScore('topics:votes', newTopic.tid), 1);
- assert.strictEqual(await db.sortedSetScore('cid:' + categoryObj.cid + ':tids:votes', newTopic.tid), 1);
+ assert.strictEqual(await db.sortedSetScore(`cid:${categoryObj.cid}:tids:votes`, newTopic.tid), 1);
assert.strictEqual(await topics.getTopicField(newTopic.tid, 'upvotes'), 1);
});
});
@@ -1112,7 +1112,7 @@ describe('Topic\'s', function () {
});
it('should load topic', function (done) {
- request(nconf.get('url') + '/topic/' + topicData.slug, function (err, response, body) {
+ request(`${nconf.get('url')}/topic/${topicData.slug}`, function (err, response, body) {
assert.ifError(err);
assert.equal(response.statusCode, 200);
assert(body);
@@ -1121,7 +1121,7 @@ describe('Topic\'s', function () {
});
it('should load topic api data', function (done) {
- request(nconf.get('url') + '/api/topic/' + topicData.slug, { json: true }, function (err, response, body) {
+ request(`${nconf.get('url')}/api/topic/${topicData.slug}`, { json: true }, function (err, response, body) {
assert.ifError(err);
assert.equal(response.statusCode, 200);
assert.strictEqual(body._header.tags.meta.find(t => t.name === 'description').content, 'topic content');
@@ -1131,7 +1131,7 @@ describe('Topic\'s', function () {
});
it('should 404 if post index is invalid', function (done) {
- request(nconf.get('url') + '/topic/' + topicData.slug + '/derp', function (err, response) {
+ request(`${nconf.get('url')}/topic/${topicData.slug}/derp`, function (err, response) {
assert.ifError(err);
assert.equal(response.statusCode, 404);
done();
@@ -1139,7 +1139,7 @@ describe('Topic\'s', function () {
});
it('should 404 if topic does not exist', function (done) {
- request(nconf.get('url') + '/topic/123123/does-not-exist', function (err, response) {
+ request(`${nconf.get('url')}/topic/123123/does-not-exist`, function (err, response) {
assert.ifError(err);
assert.equal(response.statusCode, 404);
done();
@@ -1150,7 +1150,7 @@ describe('Topic\'s', function () {
var privileges = require('../src/privileges');
privileges.categories.rescind(['groups:topics:read'], topicData.cid, 'guests', function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/topic/' + topicData.slug, function (err, response, body) {
+ request(`${nconf.get('url')}/api/topic/${topicData.slug}`, function (err, response, body) {
assert.ifError(err);
assert.equal(response.statusCode, 401);
assert(body);
@@ -1160,7 +1160,7 @@ describe('Topic\'s', function () {
});
it('should redirect to correct topic if slug is missing', function (done) {
- request(nconf.get('url') + '/topic/' + topicData.tid + '/herpderp/1?page=2', function (err, response, body) {
+ request(`${nconf.get('url')}/topic/${topicData.tid}/herpderp/1?page=2`, function (err, response, body) {
assert.ifError(err);
assert.equal(response.statusCode, 200);
assert(body);
@@ -1169,11 +1169,11 @@ describe('Topic\'s', function () {
});
it('should redirect if post index is out of range', function (done) {
- request(nconf.get('url') + '/api/topic/' + topicData.slug + '/-1', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/topic/${topicData.slug}/-1`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
- assert.equal(res.headers['x-redirect'], '/topic/' + topicData.tid + '/topic-for-controller-test');
- assert.equal(body, '/topic/' + topicData.tid + '/topic-for-controller-test');
+ assert.equal(res.headers['x-redirect'], `/topic/${topicData.tid}/topic-for-controller-test`);
+ assert.equal(body, `/topic/${topicData.tid}/topic-for-controller-test`);
done();
});
});
@@ -1181,7 +1181,7 @@ describe('Topic\'s', function () {
it('should 404 if page is out of bounds', function (done) {
var meta = require('../src/meta');
meta.config.usePagination = 1;
- request(nconf.get('url') + '/topic/' + topicData.slug + '?page=100', function (err, response) {
+ request(`${nconf.get('url')}/topic/${topicData.slug}?page=100`, function (err, response) {
assert.ifError(err);
assert.equal(response.statusCode, 404);
done();
@@ -1189,7 +1189,7 @@ describe('Topic\'s', function () {
});
it('should mark topic read', function (done) {
- request(nconf.get('url') + '/topic/' + topicData.slug, {
+ request(`${nconf.get('url')}/topic/${topicData.slug}`, {
jar: adminJar,
}, function (err, res) {
assert.ifError(err);
@@ -1203,7 +1203,7 @@ describe('Topic\'s', function () {
});
it('should 404 if tid is not a number', function (done) {
- request(nconf.get('url') + '/api/topic/teaser/nan', { json: true }, function (err, response) {
+ request(`${nconf.get('url')}/api/topic/teaser/nan`, { json: true }, function (err, response) {
assert.ifError(err);
assert.equal(response.statusCode, 404);
done();
@@ -1211,7 +1211,7 @@ describe('Topic\'s', function () {
});
it('should 403 if cant read', function (done) {
- request(nconf.get('url') + '/api/topic/teaser/' + 123123, { json: true }, function (err, response, body) {
+ request(`${nconf.get('url')}/api/topic/teaser/${123123}`, { json: true }, function (err, response, body) {
assert.ifError(err);
assert.equal(response.statusCode, 403);
assert.equal(body, '[[error:no-privileges]]');
@@ -1221,7 +1221,7 @@ describe('Topic\'s', function () {
});
it('should load topic teaser', function (done) {
- request(nconf.get('url') + '/api/topic/teaser/' + topicData.tid, { json: true }, function (err, response, body) {
+ request(`${nconf.get('url')}/api/topic/teaser/${topicData.tid}`, { json: true }, function (err, response, body) {
assert.ifError(err);
assert.equal(response.statusCode, 200);
assert(body);
@@ -1236,7 +1236,7 @@ describe('Topic\'s', function () {
it('should 404 if tid is not a number', function (done) {
- request(nconf.get('url') + '/api/topic/pagination/nan', { json: true }, function (err, response) {
+ request(`${nconf.get('url')}/api/topic/pagination/nan`, { json: true }, function (err, response) {
assert.ifError(err);
assert.equal(response.statusCode, 404);
done();
@@ -1244,7 +1244,7 @@ describe('Topic\'s', function () {
});
it('should 404 if tid does not exist', function (done) {
- request(nconf.get('url') + '/api/topic/pagination/1231231', { json: true }, function (err, response) {
+ request(`${nconf.get('url')}/api/topic/pagination/1231231`, { json: true }, function (err, response) {
assert.ifError(err);
assert.equal(response.statusCode, 404);
done();
@@ -1252,7 +1252,7 @@ describe('Topic\'s', function () {
});
it('should load pagination', function (done) {
- request(nconf.get('url') + '/api/topic/pagination/' + topicData.tid, { json: true }, function (err, response, body) {
+ request(`${nconf.get('url')}/api/topic/pagination/${topicData.tid}`, { json: true }, function (err, response, body) {
assert.ifError(err);
assert.equal(response.statusCode, 200);
assert(body);
@@ -1344,7 +1344,7 @@ describe('Topic\'s', function () {
});
it('should load more from custom set', function (done) {
- socketTopics.loadMoreFromSet({ uid: adminUid }, { set: 'uid:' + adminUid + ':topics', after: 0, count: 10 }, function (err, data) {
+ socketTopics.loadMoreFromSet({ uid: adminUid }, { set: `uid:${adminUid}:topics`, after: 0, count: 10 }, function (err, data) {
assert.ifError(err);
assert(data);
assert(Array.isArray(data.topics));
@@ -1985,7 +1985,7 @@ describe('Topic\'s', function () {
} catch (_err) {
err = _err;
}
- assert.equal(err.message, '[[error:not-enough-tags, ' + meta.config.minimumTagsPerTopic + ']]');
+ assert.equal(err.message, `[[error:not-enough-tags, ${meta.config.minimumTagsPerTopic}]]`);
meta.config.minimumTagsPerTopic = oldValue;
});
@@ -1998,7 +1998,7 @@ describe('Topic\'s', function () {
} catch (_err) {
err = _err;
}
- assert.equal(err.message, '[[error:too-many-tags, ' + meta.config.maximumTagsPerTopic + ']]');
+ assert.equal(err.message, `[[error:too-many-tags, ${meta.config.maximumTagsPerTopic}]]`);
meta.config.maximumTagsPerTopic = oldValue;
});
@@ -2011,8 +2011,8 @@ describe('Topic\'s', function () {
} catch (_err) {
err = _err;
}
- assert.equal(err.message, '[[error:not-enough-tags, ' + minTags + ']]');
- await db.deleteObjectField('category:' + topic.categoryId, 'minTags');
+ assert.equal(err.message, `[[error:not-enough-tags, ${minTags}]]`);
+ await db.deleteObjectField(`category:${topic.categoryId}`, 'minTags');
});
it('should respect maxTags per category', async () => {
@@ -2024,8 +2024,8 @@ describe('Topic\'s', function () {
} catch (_err) {
err = _err;
}
- assert.equal(err.message, '[[error:too-many-tags, ' + maxTags + ']]');
- await db.deleteObjectField('category:' + topic.categoryId, 'maxTags');
+ assert.equal(err.message, `[[error:too-many-tags, ${maxTags}]]`);
+ await db.deleteObjectField(`category:${topic.categoryId}`, 'maxTags');
});
it('should create and delete category tags properly', async () => {
@@ -2387,7 +2387,7 @@ describe('Topic\'s', function () {
async function getTopic(tid) {
const topicData = await topics.getTopicData(tid);
- return await topics.getTopicWithPosts(topicData, 'tid:' + topicData.tid + ':posts', adminUid, 0, 19, false);
+ return await topics.getTopicWithPosts(topicData, `tid:${topicData.tid}:posts`, adminUid, 0, 19, false);
}
before(function (done) {
@@ -2449,7 +2449,7 @@ describe('Topic\'s', function () {
});
it('should return properly for merged topic', function (done) {
- request(nconf.get('url') + '/api/topic/' + topic2Data.slug, { jar: adminJar, json: true }, function (err, response, body) {
+ request(`${nconf.get('url')}/api/topic/${topic2Data.slug}`, { jar: adminJar, json: true }, function (err, response, body) {
assert.ifError(err);
assert.equal(response.statusCode, 200);
assert(body);
diff --git a/test/translator.js b/test/translator.js
index 7f765ac060..c5eafdf08a 100644
--- a/test/translator.js
+++ b/test/translator.js
@@ -150,7 +150,7 @@ describe('new Translator(language)', function () {
var translator = Translator.create('en-GB');
var title = 'Test 1\\, 2\\, 3 %2 salmon';
- var key = '[[topic:composer.replying_to, ' + title + ']]';
+ var key = `[[topic:composer.replying_to, ${title}]]`;
return translator.translate(key).then(function (translated) {
assert.strictEqual(translated, 'Replying to Test 1, 2, 3 %2 salmon');
});
@@ -160,7 +160,7 @@ describe('new Translator(language)', function () {
var translator = Translator.create('en-GB');
var title = '3 % salmon';
- var key = '[[topic:composer.replying_to, ' + title + ']]';
+ var key = `[[topic:composer.replying_to, ${title}]]`;
return translator.translate(key).then(function (translated) {
assert.strictEqual(translated, 'Replying to 3 % salmon');
});
diff --git a/test/uploads.js b/test/uploads.js
index 5bf81efd6d..2ef454e482 100644
--- a/test/uploads.js
+++ b/test/uploads.js
@@ -72,7 +72,7 @@ describe('Upload Controllers', function () {
});
it('should upload an image to a post', function (done) {
- helpers.uploadFile(nconf.get('url') + '/api/post/upload', path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/post/upload`, path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body && body.status && body.response && body.response.images);
@@ -83,7 +83,7 @@ describe('Upload Controllers', function () {
});
it('should upload an image to a post and then delete the upload', function (done) {
- helpers.uploadFile(nconf.get('url') + '/api/post/upload', path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/post/upload`, path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200);
assert(body && body.status && body.response && body.response.images);
@@ -92,7 +92,7 @@ describe('Upload Controllers', function () {
var name = body.response.images[0].url.replace(nconf.get('relative_path') + nconf.get('upload_url'), '');
socketUser.deleteUpload({ uid: regularUid }, { uid: regularUid, name: name }, function (err) {
assert.ifError(err);
- db.getSortedSetRange('uid:' + regularUid + ':uploads', 0, -1, function (err, uploads) {
+ db.getSortedSetRange(`uid:${regularUid}:uploads`, 0, -1, function (err, uploads) {
assert.ifError(err);
assert.equal(uploads.includes(name), false);
done();
@@ -119,7 +119,7 @@ describe('Upload Controllers', function () {
var oldValue = meta.config.resizeImageWidth;
meta.config.resizeImageWidth = 10;
meta.config.resizeImageWidthThreshold = 10;
- helpers.uploadFile(nconf.get('url') + '/api/post/upload', path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/post/upload`, path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body && body.status && body.response && body.response.images);
@@ -136,7 +136,7 @@ describe('Upload Controllers', function () {
it('should upload a file to a post', function (done) {
var oldValue = meta.config.allowedFileExtensions;
meta.config.allowedFileExtensions = 'png,jpg,bmp,html';
- helpers.uploadFile(nconf.get('url') + '/api/post/upload', path.join(__dirname, '../test/files/503.html'), {}, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/post/upload`, path.join(__dirname, '../test/files/503.html'), {}, jar, csrf_token, function (err, res, body) {
meta.config.allowedFileExtensions = oldValue;
assert.ifError(err);
assert.strictEqual(res.statusCode, 200);
@@ -148,7 +148,7 @@ describe('Upload Controllers', function () {
});
it('should fail to upload image to post if image dimensions are too big', function (done) {
- helpers.uploadFile(nconf.get('url') + '/api/post/upload', path.join(__dirname, '../test/files/toobig.jpg'), {}, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/post/upload`, path.join(__dirname, '../test/files/toobig.jpg'), {}, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.strictEqual(res.statusCode, 500);
assert(body && body.status && body.status.message);
@@ -158,7 +158,7 @@ describe('Upload Controllers', function () {
});
it('should fail to upload image to post if image is broken', function (done) {
- helpers.uploadFile(nconf.get('url') + '/api/post/upload', path.join(__dirname, '../test/files/brokenimage.png'), {}, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/post/upload`, path.join(__dirname, '../test/files/brokenimage.png'), {}, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.strictEqual(res.statusCode, 500);
assert(body && body.status && body.status.message);
@@ -285,7 +285,7 @@ describe('Upload Controllers', function () {
helpers.loginUser('uploader', 'barbar', next);
},
function (jar, csrf_token, next) {
- helpers.uploadFile(nconf.get('url') + '/api/post/upload', path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, next);
+ helpers.uploadFile(`${nconf.get('url')}/api/post/upload`, path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, next);
},
function (res, body, next) {
assert(body && body.status && body.response && body.response.images);
@@ -321,17 +321,17 @@ describe('Upload Controllers', function () {
});
it('should upload site logo', function (done) {
- helpers.uploadFile(nconf.get('url') + '/api/admin/uploadlogo', path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/admin/uploadlogo`, path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(Array.isArray(body));
- assert.equal(body[0].url, nconf.get('relative_path') + '/assets/uploads/system/site-logo.png');
+ assert.equal(body[0].url, `${nconf.get('relative_path')}/assets/uploads/system/site-logo.png`);
done();
});
});
it('should fail to upload invalid file type', function (done) {
- helpers.uploadFile(nconf.get('url') + '/api/admin/category/uploadpicture', path.join(__dirname, '../test/files/503.html'), { params: JSON.stringify({ cid: cid }) }, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/admin/category/uploadpicture`, path.join(__dirname, '../test/files/503.html'), { params: JSON.stringify({ cid: cid }) }, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.equal(body.error, '[[error:invalid-image-type, image/png, image/jpeg, image/pjpeg, image/jpg, image/gif, image/svg+xml]]');
done();
@@ -339,7 +339,7 @@ describe('Upload Controllers', function () {
});
it('should fail to upload category image with invalid json params', function (done) {
- helpers.uploadFile(nconf.get('url') + '/api/admin/category/uploadpicture', path.join(__dirname, '../test/files/test.png'), { params: 'invalid json' }, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/admin/category/uploadpicture`, path.join(__dirname, '../test/files/test.png'), { params: 'invalid json' }, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.equal(body.error, '[[error:invalid-json]]');
done();
@@ -347,35 +347,35 @@ describe('Upload Controllers', function () {
});
it('should upload category image', function (done) {
- helpers.uploadFile(nconf.get('url') + '/api/admin/category/uploadpicture', path.join(__dirname, '../test/files/test.png'), { params: JSON.stringify({ cid: cid }) }, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/admin/category/uploadpicture`, path.join(__dirname, '../test/files/test.png'), { params: JSON.stringify({ cid: cid }) }, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(Array.isArray(body));
- assert.equal(body[0].url, nconf.get('relative_path') + '/assets/uploads/category/category-1.png');
+ assert.equal(body[0].url, `${nconf.get('relative_path')}/assets/uploads/category/category-1.png`);
done();
});
});
it('should upload default avatar', function (done) {
- helpers.uploadFile(nconf.get('url') + '/api/admin/uploadDefaultAvatar', path.join(__dirname, '../test/files/test.png'), { }, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/admin/uploadDefaultAvatar`, path.join(__dirname, '../test/files/test.png'), { }, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
- assert.equal(body[0].url, nconf.get('relative_path') + '/assets/uploads/system/avatar-default.png');
+ assert.equal(body[0].url, `${nconf.get('relative_path')}/assets/uploads/system/avatar-default.png`);
done();
});
});
it('should upload og image', function (done) {
- helpers.uploadFile(nconf.get('url') + '/api/admin/uploadOgImage', path.join(__dirname, '../test/files/test.png'), { }, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/admin/uploadOgImage`, path.join(__dirname, '../test/files/test.png'), { }, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
- assert.equal(body[0].url, nconf.get('relative_path') + '/assets/uploads/system/og-image.png');
+ assert.equal(body[0].url, `${nconf.get('relative_path')}/assets/uploads/system/og-image.png`);
done();
});
});
it('should upload favicon', function (done) {
- helpers.uploadFile(nconf.get('url') + '/api/admin/uploadfavicon', path.join(__dirname, '../test/files/favicon.ico'), {}, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/admin/uploadfavicon`, path.join(__dirname, '../test/files/favicon.ico'), {}, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(Array.isArray(body));
@@ -386,13 +386,13 @@ describe('Upload Controllers', function () {
it('should upload touch icon', function (done) {
var touchiconAssetPath = '/assets/uploads/system/touchicon-orig.png';
- helpers.uploadFile(nconf.get('url') + '/api/admin/uploadTouchIcon', path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, function (err, res, body) {
+ helpers.uploadFile(`${nconf.get('url')}/api/admin/uploadTouchIcon`, path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(Array.isArray(body));
assert.equal(body[0].url, touchiconAssetPath);
meta.config['brand:touchIcon'] = touchiconAssetPath;
- request(nconf.get('url') + '/apple-touch-icon', function (err, res, body) {
+ request(`${nconf.get('url')}/apple-touch-icon`, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -402,7 +402,7 @@ describe('Upload Controllers', function () {
});
it('should upload regular file', function (done) {
- helpers.uploadFile(nconf.get('url') + '/api/admin/upload/file', path.join(__dirname, '../test/files/test.png'), {
+ helpers.uploadFile(`${nconf.get('url')}/api/admin/upload/file`, path.join(__dirname, '../test/files/test.png'), {
params: JSON.stringify({
folder: 'system',
}),
@@ -417,7 +417,7 @@ describe('Upload Controllers', function () {
});
it('should fail to upload regular file in wrong directory', function (done) {
- helpers.uploadFile(nconf.get('url') + '/api/admin/upload/file', path.join(__dirname, '../test/files/test.png'), {
+ helpers.uploadFile(`${nconf.get('url')}/api/admin/upload/file`, path.join(__dirname, '../test/files/test.png'), {
params: JSON.stringify({
folder: '../../system',
}),
diff --git a/test/user.js b/test/user.js
index 6492e44847..41c2ba2b09 100644
--- a/test/user.js
+++ b/test/user.js
@@ -165,7 +165,7 @@ describe('User', function () {
for (var i = 0; i < 10; i += 1) {
users.push({
username: 'Jane Doe',
- email: 'jane.doe' + i + '@example.com',
+ email: `jane.doe${i}@example.com`,
});
}
@@ -573,7 +573,7 @@ describe('User', function () {
});
it('.validate() should correctly identify an invalid code', function (done) {
- User.reset.validate(code + 'abcdef', function (err, valid) {
+ User.reset.validate(`${code}abcdef`, function (err, valid) {
assert.ifError(err);
assert.strictEqual(valid, false);
done();
@@ -598,7 +598,7 @@ describe('User', function () {
User.getUserData(uid, next);
},
password: function (next) {
- db.getObjectField('user:' + uid, 'password', next);
+ db.getObjectField(`user:${uid}`, 'password', next);
},
}, function (err, results) {
assert.ifError(err);
@@ -861,7 +861,7 @@ describe('User', function () {
assert.equal(result.userslug, 'updatedusername');
assert.equal(result.email, 'updatedEmail@me.com');
- db.getObject('user:' + uid, function (err, userData) {
+ db.getObject(`user:${uid}`, function (err, userData) {
assert.ifError(err);
Object.keys(data).forEach(function (key) {
if (key !== 'password') {
@@ -942,7 +942,7 @@ describe('User', function () {
it('should change username', function (done) {
socketUser.changeUsernameEmail({ uid: uid }, { uid: uid, username: 'updatedAgain', password: '123456' }, function (err) {
assert.ifError(err);
- db.getObjectField('user:' + uid, 'username', function (err, username) {
+ db.getObjectField(`user:${uid}`, 'username', function (err, username) {
assert.ifError(err);
assert.equal(username, 'updatedAgain');
done();
@@ -952,7 +952,7 @@ describe('User', function () {
it('should not let setting an empty username', async function () {
await socketUser.changeUsernameEmail({ uid: uid }, { uid: uid, username: '', password: '123456' });
- const username = await db.getObjectField('user:' + uid, 'username');
+ const username = await db.getObjectField(`user:${uid}`, 'username');
assert.strictEqual(username, 'updatedAgain');
});
@@ -961,7 +961,7 @@ describe('User', function () {
const longName = new Array(maxLength).fill('a').join('');
const uid = await User.create({ username: longName });
await socketUser.changeUsernameEmail({ uid: uid }, { uid: uid, username: longName, email: 'verylong@name.com' });
- const userData = await db.getObject('user:' + uid);
+ const userData = await db.getObject(`user:${uid}`);
assert.strictEqual(userData.username, longName);
assert.strictEqual(userData.email, 'verylong@name.com');
});
@@ -969,7 +969,7 @@ describe('User', function () {
it('should not update a user\'s username if it did not change', function (done) {
socketUser.changeUsernameEmail({ uid: uid }, { uid: uid, username: 'updatedAgain', password: '123456' }, function (err) {
assert.ifError(err);
- db.getSortedSetRevRange('user:' + uid + ':usernames', 0, -1, function (err, data) {
+ db.getSortedSetRevRange(`user:${uid}:usernames`, 0, -1, function (err, data) {
assert.ifError(err);
assert.equal(data.length, 2);
assert(data[0].startsWith('updatedAgain'));
@@ -995,7 +995,7 @@ describe('User', function () {
assert.ifError(err);
socketUser.changeUsernameEmail({ uid: uid }, { uid: uid, email: 'updatedAgain@me.com', password: '123456' }, function (err) {
assert.ifError(err);
- db.getObjectField('user:' + uid, 'email', function (err, email) {
+ db.getObjectField(`user:${uid}`, 'email', function (err, email) {
assert.ifError(err);
assert.equal(email, 'updatedAgain@me.com');
done();
@@ -1031,7 +1031,7 @@ describe('User', function () {
socketUser.updateCover({ uid: uid }, { uid: uid, imageData: imageData, position: position }, function (err, result) {
assert.ifError(err);
assert(result.url);
- db.getObjectFields('user:' + uid, ['cover:url', 'cover:position'], function (err, data) {
+ db.getObjectFields(`user:${uid}`, ['cover:url', 'cover:position'], function (err, data) {
assert.ifError(err);
assert.equal(data['cover:url'], result.url);
assert.equal(data['cover:position'], position);
@@ -1045,7 +1045,7 @@ describe('User', function () {
socketUser.uploadCroppedPicture({ uid: uid }, { uid: uid, imageData: imageData }, function (err, result) {
assert.ifError(err);
assert(result.url);
- db.getObjectFields('user:' + uid, ['uploadedpicture', 'picture'], function (err, data) {
+ db.getObjectFields(`user:${uid}`, ['uploadedpicture', 'picture'], function (err, data) {
assert.ifError(err);
assert.equal(result.url, data.uploadedpicture);
assert.equal(result.url, data.picture);
@@ -1057,7 +1057,7 @@ describe('User', function () {
it('should remove cover image', function (done) {
socketUser.removeCover({ uid: uid }, { uid: uid }, function (err) {
assert.ifError(err);
- db.getObjectField('user:' + uid, 'cover:url', function (err, url) {
+ db.getObjectField(`user:${uid}`, 'cover:url', function (err, url) {
assert.ifError(err);
assert.equal(url, null);
done();
@@ -1121,7 +1121,7 @@ describe('User', function () {
assert.ifError(err);
User.getUserField(uid, 'picture', function (err, picture) {
assert.ifError(err);
- assert.equal(picture, nconf.get('relative_path') + '/test');
+ assert.equal(picture, `${nconf.get('relative_path')}/test`);
done();
});
});
@@ -1248,7 +1248,7 @@ describe('User', function () {
});
it('should load profile page', function (done) {
- request(nconf.get('url') + '/api/user/updatedagain', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/updatedagain`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1257,7 +1257,7 @@ describe('User', function () {
});
it('should load settings page', function (done) {
- request(nconf.get('url') + '/api/user/updatedagain/settings', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/updatedagain/settings`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body.settings);
@@ -1268,7 +1268,7 @@ describe('User', function () {
});
it('should load edit page', function (done) {
- request(nconf.get('url') + '/api/user/updatedagain/edit', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/updatedagain/edit`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1277,7 +1277,7 @@ describe('User', function () {
});
it('should load edit/email page', function (done) {
- request(nconf.get('url') + '/api/user/updatedagain/edit/email', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/updatedagain/edit/email`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@@ -1293,7 +1293,7 @@ describe('User', function () {
assert.ifError(err);
groups.join('Test', uid, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/user/updatedagain/groups', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/updatedagain/groups`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(Array.isArray(body.groups));
@@ -1325,8 +1325,8 @@ describe('User', function () {
it('should get history from set', async function () {
const now = Date.now();
- await db.sortedSetAdd('user:' + testUserUid + ':usernames', now, 'derp:' + now);
- const data = await User.getHistory('user:' + testUserUid + ':usernames');
+ await db.sortedSetAdd(`user:${testUserUid}:usernames`, now, `derp:${now}`);
+ const data = await User.getHistory(`user:${testUserUid}:usernames`);
assert.equal(data[0].value, 'derp');
assert.equal(data[0].timestamp, now);
});
@@ -1439,7 +1439,7 @@ describe('User', function () {
var testUsers = ['daysub', 'offsub', 'nullsub', 'weeksub'];
async.each(testUsers, function (username, next) {
async.waterfall([
- async.apply(User.create, { username: username, email: username + '@example.com' }),
+ async.apply(User.create, { username: username, email: `${username}@example.com` }),
function (uid, next) {
if (username === 'nullsub') {
return setImmediate(next);
@@ -1556,12 +1556,12 @@ describe('User', function () {
request({
method: 'post',
- url: nconf.get('url') + '/email/unsubscribe/' + token,
+ url: `${nconf.get('url')}/email/unsubscribe/${token}`,
}, function (err, res) {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200);
- db.getObjectField('user:' + uid + ':settings', 'dailyDigestFreq', function (err, value) {
+ db.getObjectField(`user:${uid}:settings`, 'dailyDigestFreq', function (err, value) {
assert.ifError(err);
assert.strictEqual(value, 'off');
done();
@@ -1578,12 +1578,12 @@ describe('User', function () {
request({
method: 'post',
- url: nconf.get('url') + '/email/unsubscribe/' + token,
+ url: `${nconf.get('url')}/email/unsubscribe/${token}`,
}, function (err, res) {
assert.ifError(err);
assert.strictEqual(res.statusCode, 200);
- db.getObjectField('user:' + uid + ':settings', 'notificationType_test', function (err, value) {
+ db.getObjectField(`user:${uid}:settings`, 'notificationType_test', function (err, value) {
assert.ifError(err);
assert.strictEqual(value, 'notification');
done();
@@ -1598,7 +1598,7 @@ describe('User', function () {
request({
method: 'post',
- url: nconf.get('url') + '/email/unsubscribe/' + token,
+ url: `${nconf.get('url')}/email/unsubscribe/${token}`,
}, function (err, res) {
assert.ifError(err);
assert.strictEqual(res.statusCode, 404);
@@ -1614,7 +1614,7 @@ describe('User', function () {
request({
method: 'post',
- url: nconf.get('url') + '/email/unsubscribe/' + token,
+ url: `${nconf.get('url')}/email/unsubscribe/${token}`,
}, function (err, res) {
assert.ifError(err);
assert.strictEqual(res.statusCode, 404);
@@ -1625,7 +1625,7 @@ describe('User', function () {
it('should return errors on missing token', function (done) {
request({
method: 'post',
- url: nconf.get('url') + '/email/unsubscribe/',
+ url: `${nconf.get('url')}/email/unsubscribe/`,
}, function (err, res) {
assert.ifError(err);
assert.strictEqual(res.statusCode, 404);
@@ -1638,11 +1638,11 @@ describe('User', function () {
template: 'notification',
type: 'test',
uid: uid,
- }, nconf.get('secret') + 'aababacaba');
+ }, `${nconf.get('secret')}aababacaba`);
request({
method: 'post',
- url: nconf.get('url') + '/email/unsubscribe/' + token,
+ url: `${nconf.get('url')}/email/unsubscribe/${token}`,
}, function (err, res) {
assert.ifError(err);
assert.strictEqual(res.statusCode, 403);
@@ -1932,7 +1932,7 @@ describe('User', function () {
assert.ifError(err);
helpers.loginUser('admin', '123456', function (err, jar) {
assert.ifError(err);
- request(nconf.get('url') + '/api/admin/manage/registration', { jar: jar, json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/admin/manage/registration`, { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(body.users[0].username, 'rejectme');
assert.equal(body.users[0].email, '<script>alert("ok")<script>reject@me.com');
@@ -2066,7 +2066,7 @@ describe('User', function () {
jar = _jar;
request({
- url: nconf.get('url') + '/api/config',
+ url: `${nconf.get('url')}/api/config`,
json: true,
jar: jar,
}, function (err, response, body) {
@@ -2102,7 +2102,7 @@ describe('User', function () {
jar = _jar;
request({
- url: nconf.get('url') + '/api/config',
+ url: `${nconf.get('url')}/api/config`,
json: true,
jar: jar,
}, function (err, response, body) {
@@ -2168,7 +2168,7 @@ describe('User', function () {
meta.config.maximumInvites = 1;
const { res } = await helpers.invite({ emails: 'invite6@test.com', groupsToJoin: [] }, inviterUid, jar, csrf_token);
assert.strictEqual(res.statusCode, 403);
- assert.strictEqual(res.body.status.message, '[[error:invite-maximum-met, ' + 5 + ', ' + 1 + ']]');
+ assert.strictEqual(res.body.status.message, `[[error:invite-maximum-met, ${5}, ${1}]]`);
meta.config.maximumInvites = 10;
});
@@ -2202,7 +2202,7 @@ describe('User', function () {
jar = _jar;
request({
- url: nconf.get('url') + '/api/config',
+ url: `${nconf.get('url')}/api/config`,
json: true,
jar: jar,
}, function (err, response, body) {
@@ -2231,7 +2231,7 @@ describe('User', function () {
User.getInvites(inviterUid, function (err, data) {
assert.ifError(err);
Array.from(Array(6)).forEach((_, i) => {
- assert.notEqual(data.indexOf('invite' + (i + 1) + '@test.com'), -1);
+ assert.notEqual(data.indexOf(`invite${i + 1}@test.com`), -1);
});
done();
});
@@ -2246,7 +2246,7 @@ describe('User', function () {
var inviterData = data.filter(d => parseInt(d.uid, 10) === inviterUid)[0];
Array.from(Array(6)).forEach((_, i) => {
- assert.notEqual(inviterData.invitations.indexOf('invite' + (i + 1) + '@test.com'), -1);
+ assert.notEqual(inviterData.invitations.indexOf(`invite${i + 1}@test.com`), -1);
});
done();
@@ -2269,7 +2269,7 @@ describe('User', function () {
it('should verify installation with no errors', function (done) {
var email = 'invite1@test.com';
- db.getObjectField('invitation:email:' + email, 'token', function (err, token) {
+ db.getObjectField(`invitation:email:${email}`, 'token', function (err, token) {
assert.ifError(err);
User.verifyInvitation({ token: token, email: 'invite1@test.com' }, function (err) {
assert.ifError(err);
@@ -2289,7 +2289,7 @@ describe('User', function () {
var socketUser = require('../src/socket.io/user');
socketUser.deleteInvitation({ uid: adminUid }, { invitedBy: 'inviter', email: 'invite1@test.com' }, function (err) {
assert.ifError(err);
- db.isSetMember('invitation:uid:' + inviterUid, 'invite1@test.com', function (err, isMember) {
+ db.isSetMember(`invitation:uid:${inviterUid}`, 'invite1@test.com', function (err, isMember) {
assert.ifError(err);
assert.equal(isMember, false);
done();
@@ -2300,7 +2300,7 @@ describe('User', function () {
it('should delete invitation key', function (done) {
User.deleteInvitationKey('invite99@test.com', function (err) {
assert.ifError(err);
- db.isSetMember('invitation:uid:' + adminUid, 'invite99@test.com', function (err, isMember) {
+ db.isSetMember(`invitation:uid:${adminUid}`, 'invite99@test.com', function (err, isMember) {
assert.ifError(err);
assert.equal(isMember, false);
db.isSetMember('invitation:uids', adminUid, function (err, isMember) {
@@ -2315,7 +2315,7 @@ describe('User', function () {
it('should joined the groups from invitation after registration', async function () {
var email = 'invite5@test.com';
var groupsToJoin = [PUBLIC_GROUP, OWN_PRIVATE_GROUP];
- var token = await db.getObjectField('invitation:email:' + email, 'token');
+ var token = await db.getObjectField(`invitation:email:${email}`, 'token');
await new Promise(function (resolve, reject) {
helpers.registerUser({
@@ -2353,7 +2353,7 @@ describe('User', function () {
jar = _jar;
request({
- url: nconf.get('url') + '/api/config',
+ url: `${nconf.get('url')}/api/config`,
json: true,
jar: jar,
}, function (err, response, body) {
@@ -2417,7 +2417,7 @@ describe('User', function () {
assert.strictEqual(unverified, true);
await User.email.confirmByCode(code);
const [confirmed, isVerified] = await Promise.all([
- db.getObjectField('user:' + uid, 'email:confirmed'),
+ db.getObjectField(`user:${uid}`, 'email:confirmed'),
groups.isMember(uid, 'verified-users', uid),
]);
assert.strictEqual(parseInt(confirmed, 10), 1);
@@ -2435,7 +2435,7 @@ describe('User', function () {
assert.strictEqual(unverified, true);
await User.email.confirmByUid(uid);
const [confirmed, isVerified] = await Promise.all([
- db.getObjectField('user:' + uid, 'email:confirmed'),
+ db.getObjectField(`user:${uid}`, 'email:confirmed'),
groups.isMember(uid, 'verified-users', uid),
]);
assert.strictEqual(parseInt(confirmed, 10), 1);
@@ -2484,7 +2484,7 @@ describe('User', function () {
}, function (err, _uid) {
uid = _uid;
assert.ifError(err);
- request(nconf.get('url') + '/api/user/hiddenemail', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/user/hiddenemail`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(body.fullname, '');
assert.equal(body.email, '');
@@ -2502,10 +2502,10 @@ describe('User', function () {
cid: testCid,
}, function (err) {
assert.ifError(err);
- request(nconf.get('url') + '/api/recent', { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/recent`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert(!body.topics[0].user.hasOwnProperty('fullname'));
- request(nconf.get('url') + '/api/topic/' + body.topics[0].slug, { json: true }, function (err, res, body) {
+ request(`${nconf.get('url')}/api/topic/${body.topics[0].slug}`, { json: true }, function (err, res, body) {
assert.ifError(err);
assert(!body.posts[0].user.hasOwnProperty('fullname'));
done();
diff --git a/test/utils.js b/test/utils.js
index c91ba8c02d..486dbc3779 100644
--- a/test/utils.js
+++ b/test/utils.js
@@ -430,7 +430,7 @@ describe('Utility Methods', function () {
var index = hours.length - 1;
for (var i = currentHour, ii = currentHour - 24; i > ii; i -= 1) {
var hour = i < 0 ? 24 + i : i;
- assert.equal(hours[index], hour + ':00');
+ assert.equal(hours[index], `${hour}:00`);
index -= 1;
}
done();
@@ -443,7 +443,7 @@ describe('Utility Methods', function () {
var index = 0;
for (var x = 29; x >= 0; x -= 1) {
var tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x));
- assert.equal(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate(), days[index]);
+ assert.equal(`${months[tmpDate.getMonth()]} ${tmpDate.getDate()}`, days[index]);
index += 1;
}
done();