You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
8 years ago
|
'use strict';
|
||
|
|
||
|
var async = require('async');
|
||
|
var assert = require('assert');
|
||
|
|
||
|
var db = require('./mocks/databasemock');
|
||
|
var helpers = require('../public/src/modules/helpers');
|
||
|
|
||
|
describe('helpers', function () {
|
||
|
|
||
|
|
||
|
it('should return false if item doesn\'t exist', function (done) {
|
||
|
var flag = helpers.displayMenuItem({navigation: []}, 0);
|
||
|
assert(!flag);
|
||
|
done();
|
||
|
});
|
||
|
|
||
|
|
||
|
it('should return false if route is /users and privateUserInfo is on and user is not logged in', function (done) {
|
||
|
var flag = helpers.displayMenuItem({
|
||
|
navigation: [{route: '/users'}],
|
||
|
privateUserInfo: true,
|
||
|
config: {
|
||
|
loggedIn: false
|
||
|
}
|
||
|
}, 0);
|
||
|
assert(!flag);
|
||
|
done();
|
||
|
});
|
||
|
|
||
|
it('should return false if route is /tags and privateTagListing is on and user is not logged in', function (done) {
|
||
|
var flag = helpers.displayMenuItem({
|
||
|
navigation: [{route: '/tags'}],
|
||
|
privateTagListing: true,
|
||
|
config: {
|
||
|
loggedIn: false
|
||
|
}
|
||
|
}, 0);
|
||
|
assert(!flag);
|
||
|
done();
|
||
|
});
|
||
|
|
||
|
it('should stringify object', function (done) {
|
||
|
var str = helpers.stringify({a: 'herp < derp > and & quote "'});
|
||
|
assert.equal(str, '{"a":"herp < derp > and & quote \\""}');
|
||
|
done();
|
||
|
});
|
||
|
|
||
|
it('should escape html', function (done) {
|
||
|
var str = helpers.escape('gdkfhgk < some > and &');
|
||
|
assert.equal(str, 'gdkfhgk < some > and &');
|
||
|
done();
|
||
|
});
|
||
|
|
||
|
});
|