From 9367ba4f25dc2f6baa2be7ae60ca5d671e06147e Mon Sep 17 00:00:00 2001 From: Felix Hammerl Date: Wed, 12 Mar 2014 16:57:14 +0100 Subject: [PATCH] remove unused #check api --- src/js/dao/invitation-dao.js | 51 +---------------- test/new-unit/invitation-dao-test.js | 85 ---------------------------- 2 files changed, 2 insertions(+), 134 deletions(-) diff --git a/src/js/dao/invitation-dao.js b/src/js/dao/invitation-dao.js index 517a5ac..f7013de 100644 --- a/src/js/dao/invitation-dao.js +++ b/src/js/dao/invitation-dao.js @@ -35,7 +35,8 @@ define(function() { return; } - this._restDao.put({}, uri(options.recipient, options.sender), completed); + var uri = '/invitation/recipient/' + options.recipient + '/sender/' + options.sender; + this._restDao.put({}, uri, completed); function completed(error, res, status) { if (error) { @@ -57,53 +58,5 @@ define(function() { } }; - /** - * Checks if an invitation for the recipient by the sender is present in the invitation web service - * @param {String} options.recipient User ID of the recipient - * @param {String} options.sender User ID of the sender - * @param {Function} callback(error, status) Returns information about the invitation status, either an invitation is already on place (INVITE_PENDING), or not (INVITE_MISSING), or information if an error occurred. - */ - InvitationDAO.prototype.check = function(options, callback) { - if (typeof options !== 'object' || typeof options.recipient !== 'string' || typeof options.recipient !== 'string') { - callback({ - errMsg: 'erroneous usage of api: incorrect parameters!' - }); - return; - } - - this._restDao.get({ - uri: uri(options.recipient, options.sender), - type: 'text' - }, completed); - - function completed(error, res, status) { - // 404 is a meaningful return value from the web service - if (error && error.code !== 404) { - callback(error); - return; - } - - if (error && error.code === 404) { - callback(null, InvitationDAO.INVITE_MISSING); - return; - } else if (status === 200) { - callback(null, InvitationDAO.INVITE_PENDING); - return; - } - - callback({ - errMsg: 'unexpected invitation state' - }); - } - }; - - // - // Helper functions - // - - function uri(a, b) { - return '/invitation/recipient/' + a + '/sender/' + b; - } - return InvitationDAO; }); \ No newline at end of file diff --git a/test/new-unit/invitation-dao-test.js b/test/new-unit/invitation-dao-test.js index b496666..9982119 100644 --- a/test/new-unit/invitation-dao-test.js +++ b/test/new-unit/invitation-dao-test.js @@ -104,90 +104,5 @@ define(function(require) { } }); }); - - describe('check', function() { - it('should return pending invite', function(done) { - restDaoStub.get.yieldsAsync(null, undefined, 200); - - invitationDao.check({ - recipient: alice, - sender: bob - }, function(err, status) { - expect(err).to.not.exist; - expect(status).to.equal(InvitationDAO.INVITE_PENDING); - expect(restDaoStub.get.calledWith({ - uri: expectedUri, - type: 'text' - })).to.be.true; - done(); - }); - }); - - it('should return missing invite', function(done) { - restDaoStub.get.yieldsAsync({ - code: 404 - }); - - invitationDao.check({ - recipient: alice, - sender: bob - }, function(err, status) { - expect(err).to.not.exist; - expect(status).to.equal(InvitationDAO.INVITE_MISSING); - done(); - }); - }); - - it('should not work for http error', function(done) { - restDaoStub.get.yieldsAsync({ - code: 1337, - errMsg: 'jawollja.' - }); - - invitationDao.check({ - recipient: alice, - sender: bob - }, function(err, status) { - expect(err).to.exist; - expect(status).to.not.exist; - done(); - }); - }); - - it('should not work for unexpected response', function(done) { - restDaoStub.get.yieldsAsync(null, undefined, 1337); - - invitationDao.check({ - recipient: alice, - sender: bob - }, function(err, status) { - expect(err).to.exist; - expect(status).to.not.exist; - done(); - }); - }); - - it('should report erroneous usage', function() { - invitationDao.check({ - sender: bob - }, expectError); - - invitationDao.check({ - recipient: alice, - }, expectError); - - invitationDao.check({ - recipient: 123, - sender: 123 - }, expectError); - - invitationDao.check('asd', expectError); - - function expectError(err, status) { - expect(err).to.exist; - expect(status).to.not.exist; - } - }); - }); }); }); \ No newline at end of file