<commit_before>describe("server.js tests", function () {

  var DEV_SERVER_FIXTURES_ENDPOINT = "http://localhost:1337/fixtures";
  var DEV_SERVER_CLEAR_FIXTURES_ENDPOINT = "http://localhost:1337/clear";

  var toBluebird = bluebird.resolve;

  var makeFakePage = function(nextUrl) {
    return {
      _links: {
        next: { href: nextUrl },
      },
      _embedded: {
        records: []
      },
    }
  }

  var FAKE_COLLECTION_RESPONSE = makeFakePage('http://localhost:3000/accounts/gspbxqXqEUZkiCCEFFCN9Vu4FLucdjLLdLcsV6E82Qc1T7ehsTC/transactions?after=55834578944&limit=1&order=asc');

  var server;

  beforeEach(function () {
    server = new StellarSdk.Server({port: 1337});
    // sets the request the dev server should expect and the response it should send
    this.setFixtures = function (fixtures, done) {
      // instruct the dev server to except the correct request
      return axios.post(DEV_SERVER_FIXTURES_ENDPOINT, fixtures);
    }
  });

  afterEach(function (done) {
    return toBluebird(axios.post(DEV_SERVER_CLEAR_FIXTURES_ENDPOINT))
      .then(function () { done() });
  })

  describe('Server._sendResourceRequest', function () {

    describe("requests all ledgers", function () {
      describe("without options", function () {

        beforeEach(function (done) {
          // instruct the dev server to except the correct request
          return this.setFixtures({
            request: "/ledgers",
            response: {status: 200, body: FAKE_COLLECTION_RESPONSE}
          }).then(function () { done() });
        });

        it("requests the correct endpoint", function (done) {
          server.ledgers()
            .call()
            .then(function () {
              done();
            })
            .catch(function (err) {
              done(err);
            })
        })
      })

      describe("with options", function () {
        beforeEach(function (done) {
          var url = "/ledgers?limit=1&after=b&order=asc"
          // instruct the dev server to except the correct request
          return this.setFixtures({
            request: url,
            response: {status: 200, body: makeFakePage('http://localhost:1337' + url)}
          }).then(function () { done(); });
        });

        // This should not be passing
        it("requests the correct endpoint", function () {
          return server.ledgers({limit: 1, after: "b", order: "asc"})
          // return server.ledgers()
          //   .limit("1")
          //   .after("b")
          //   .order("asc")
          //   .call();
        });

        it("can call .next() on the result to retrieve the next page", function () {
          return server
            .ledgers()
            .limit("1")
            .after("b")
            .order("asc")
            .call()<commit_msg>Fixed a test.  However, test may be broken.<commit_after>describe("server.js tests", function () {

  var DEV_SERVER_FIXTURES_ENDPOINT = "http://localhost:1337/fixtures";
  var DEV_SERVER_CLEAR_FIXTURES_ENDPOINT = "http://localhost:1337/clear";

  var toBluebird = bluebird.resolve;

  var makeFakePage = function(nextUrl) {
    return {
      _links: {
        next: { href: nextUrl },
      },
      _embedded: {
        records: []
      },
    }
  }

  var FAKE_COLLECTION_RESPONSE = makeFakePage('http://localhost:3000/accounts/gspbxqXqEUZkiCCEFFCN9Vu4FLucdjLLdLcsV6E82Qc1T7ehsTC/transactions?after=55834578944&limit=1&order=asc');

  var server;

  beforeEach(function () {
    server = new StellarSdk.Server({port: 1337});
    // sets the request the dev server should expect and the response it should send
    this.setFixtures = function (fixtures, done) {
      // instruct the dev server to except the correct request
      return axios.post(DEV_SERVER_FIXTURES_ENDPOINT, fixtures);
    }
  });

  afterEach(function (done) {
    return toBluebird(axios.post(DEV_SERVER_CLEAR_FIXTURES_ENDPOINT))
      .then(function () { done() });
  })

  describe('Server._sendResourceRequest', function () {

    describe("requests all ledgers", function () {
      describe("without options", function () {

        beforeEach(function (done) {
          // instruct the dev server to except the correct request
          return this.setFixtures({
            request: "/ledgers",
            response: {status: 200, body: FAKE_COLLECTION_RESPONSE}
          }).then(function () { done() });
        });

        it("requests the correct endpoint", function (done) {
          server.ledgers()
            .call()
            .then(function () {
              done();
            })
            .catch(function (err) {
              done(err);
            })
        })
      })

      describe("with options", function () {
        beforeEach(function (done) {
          var url = "/ledgers?limit=1&after=b&order=asc"
          // instruct the dev server to except the correct request
          return this.setFixtures({
            request: url,
            response: {status: 200, body: makeFakePage('http://localhost:1337' + url)}
          }).then(function () { done(); });
        });

        // This should not be passing
        it("requests the correct endpoint", function () {
          return server.ledgers()
            .limit("1")
            .after("b")
            .order("asc")
            .call();
        });

        it("can call .next() on the result to retrieve the next page", function () {
          return server
            .ledgers()
            .limit("1")
            .after("b")
            .order("asc")
            .call()
{'fraction_non_alphanumeric': 0.12888729103001978, 'fraction_numerical': 0.017436634909221642, 'mean_word_length': 2.1364148816234496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1648830', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1583, 'n_words': 365}