2013-11-14 20:17:33 -06:00
|
|
|
/*globals describe, beforeEach, afterEach, before, it*/
|
|
|
|
var should = require('should'),
|
|
|
|
sinon = require('sinon'),
|
|
|
|
_ = require("underscore"),
|
2013-11-27 21:45:01 -05:00
|
|
|
helpers = require('../../server/helpers'),
|
|
|
|
filters = require('../../server/filters'),
|
2013-11-14 20:17:33 -06:00
|
|
|
|
|
|
|
// Stuff we are testing
|
2013-11-29 16:26:56 +00:00
|
|
|
appProxy = require('../../server/plugins/proxy');
|
2013-11-27 21:45:01 -05:00
|
|
|
|
2013-11-14 20:17:33 -06:00
|
|
|
describe('App Proxy', function () {
|
|
|
|
|
|
|
|
var sandbox,
|
2013-11-29 16:26:56 +00:00
|
|
|
fakeApi;
|
2013-11-14 20:17:33 -06:00
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
sandbox = sinon.sandbox.create();
|
|
|
|
|
2013-11-29 16:26:56 +00:00
|
|
|
fakeApi = {
|
|
|
|
posts: {
|
|
|
|
browse: sandbox.stub(),
|
|
|
|
read: sandbox.stub(),
|
|
|
|
edit: sandbox.stub(),
|
|
|
|
add: sandbox.stub(),
|
|
|
|
destroy: sandbox.stub()
|
|
|
|
},
|
|
|
|
users: {
|
|
|
|
browse: sandbox.stub(),
|
|
|
|
read: sandbox.stub(),
|
|
|
|
edit: sandbox.stub()
|
|
|
|
},
|
|
|
|
tags: {
|
|
|
|
all: sandbox.stub()
|
|
|
|
},
|
|
|
|
notifications: {
|
|
|
|
destroy: sandbox.stub(),
|
|
|
|
add: sandbox.stub()
|
|
|
|
},
|
|
|
|
settings: {
|
|
|
|
browse: sandbox.stub(),
|
|
|
|
read: sandbox.stub(),
|
|
|
|
add: sandbox.stub()
|
2013-11-14 20:17:33 -06:00
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
sandbox.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('creates a ghost proxy', function () {
|
2013-11-29 16:26:56 +00:00
|
|
|
should.exist(appProxy.filters);
|
|
|
|
appProxy.filters.register.should.equal(filters.registerFilter);
|
|
|
|
appProxy.filters.unregister.should.equal(filters.unregisterFilter);
|
2013-11-14 20:17:33 -06:00
|
|
|
|
2013-11-29 16:26:56 +00:00
|
|
|
should.exist(appProxy.helpers);
|
|
|
|
appProxy.helpers.register.should.equal(helpers.registerThemeHelper);
|
|
|
|
appProxy.helpers.registerAsync.should.equal(helpers.registerAsyncThemeHelper);
|
2013-11-14 20:17:33 -06:00
|
|
|
|
2013-11-29 16:26:56 +00:00
|
|
|
should.exist(appProxy.api);
|
2013-11-14 20:17:33 -06:00
|
|
|
|
2013-11-29 16:26:56 +00:00
|
|
|
should.exist(appProxy.api.posts);
|
|
|
|
should.not.exist(appProxy.api.posts.edit);
|
|
|
|
should.not.exist(appProxy.api.posts.add);
|
|
|
|
should.not.exist(appProxy.api.posts.destroy);
|
2013-11-14 20:17:33 -06:00
|
|
|
|
2013-11-29 16:26:56 +00:00
|
|
|
should.not.exist(appProxy.api.users);
|
2013-11-14 20:17:33 -06:00
|
|
|
|
2013-11-29 16:26:56 +00:00
|
|
|
should.exist(appProxy.api.tags);
|
2013-11-14 20:17:33 -06:00
|
|
|
|
2013-11-29 16:26:56 +00:00
|
|
|
should.exist(appProxy.api.notifications);
|
|
|
|
should.not.exist(appProxy.api.notifications.destroy);
|
2013-11-14 20:17:33 -06:00
|
|
|
|
2013-11-29 16:26:56 +00:00
|
|
|
should.exist(appProxy.api.settings);
|
|
|
|
should.not.exist(appProxy.api.settings.browse);
|
|
|
|
should.not.exist(appProxy.api.settings.add);
|
2013-11-14 20:17:33 -06:00
|
|
|
|
|
|
|
});
|
|
|
|
});
|