         @giphy.getHelp.should.have.been.called.once
         @giphy.getHelp.should.have.been.calledWith state
 
+    describe '.handleResponse', ->
+      it 'sends a response when there is no error', ->
+        state = { }
+        uriCreator = @fakes.stub().returns sampleUri
+        @fakes.stub @giphy, 'sendResponse'
+        @giphy.handleResponse state, null, uriCreator
+        uriCreator.should.have.been.called.once
+        @giphy.sendResponse.should.have.been.called.once
+        @giphy.sendResponse.should.have.been.calledWith { uri: sampleUri }
+        should.exist state.uri
+        state.uri.should.eql sampleUri
+
+      it 'sends an error when the state is missing a valid uri', ->
+        state = { msg: @msg }
+        uriCreator = @fakes.stub().returns sampleUri
+        @fakes.stub @giphy, 'error'
+        @giphy.handleResponse state, 'error', uriCreator
+        uriCreator.should.not.have.been.called
+        @giphy.error.should.have.been.called.once
+        @giphy.error.should.have.been.calledWith state.msg, 'error'
+        should.not.exist state.uri
+
     describe '.sendResponse', ->
       beforeEach ->
         @fakes.stub @giphy, 'sendMessage'

        @giphy.getRandomResult [], callback
        callback.should.not.have.been.called

    describe '.getSearchUri', ->
      it 'searches using args', ->
        state = { args: 'testing' }

      it 'handles the response callback', ->
        state = { msg: 'msg', args: 'testing' }
        @fakes.stub @giphy.api, 'search', (options, callback) -> callback 'error', sampleCollectionResult
        @fakes.stub @giphy, 'handleResponse', (state, err, uriCreator) -> uriCreator()
        @fakes.stub @giphy, 'getRandomResult'
        @giphy.getSearchUri state
        @giphy.handleResponse.should.have.been.called.once
        @giphy.handleResponse.should.have.been.calledWith state, 'error', sinon.match.func
        @giphy.getRandomResult.should.have.been.called.once
        @giphy.getRandomResult.should.have.been.calledWith sampleCollectionResult.data, @giphy.getUriFromResult

      it 'calls getRandomUri for empty args', ->
        @fakes.stub @giphy, 'getRandomUri'
