title: Comparing function results against API in Chai?
body: <p>I'm quite new to JavaScript, and I've made a Node module which works, but I want to add some testing using Mocha and Chai.</p>
  
  <p>My node module returns the results of TVmaze API.  The module is called tvmaze-node and is available through NPM.</p>
  
  <p>For example, the following will return the results of <a href="http://api.tvmaze.com/search/shows?q=girls" rel="nofollow">http://api.tvmaze.com/search/shows?q=girls</a></p>
  
  <pre><code> pullRequest: function(url, donePulledRequest) {
      request(url, function(error, response, body){
        if(error || response.statusCode === 404 || body.length == 2) {
           donePulledRequest(error || 'No results');
        }
        else {
          donePulledRequest(null, JSON.parse(body));
        }
      });
    },
  
    search: function(show, doneShow){
      var url =  "http://api.tvmaze.com/search/shows?q=" + show;
      module.exports.pullRequest(url, doneShow)
    },
  </code></pre>
  
  <p>What I would like to do in Chai is to make sure that the results of <strong>search</strong> match the json returned from a URL.</p>
  
  <p>I've got the structure for Chai, but can't figure the logic out of the life of me.  For some reason I get the error:</p>
  
  <blockquote>
    <p>Uncaught AssertionError: expected [ Array(10) ] to deeply equal
    '[{"score":2.096719,"show":{......<em>the rest of the array shown at the URL above</em></p>
  </blockquote>
  
  <pre><code>describe('Show Search', function() {
    it("Returns all results for a given search", function(done) {
  tvmaze.search("Lost", function(error, response) {
    if(error){
      done(error);
    } else {
    request('http://api.tvmaze.com/search/shows?q=lost', function(error, resp, body){
      expect(response).to.eql(body);
        done();
      })
    }
  });
      done();
    });
  });
  </code></pre>