<commit_before>'use strict';

require('should');

var update = require('../lib/update.js');
var config = require('../config/configuration.js');

describe("Testing the move event", function() {
  var fakeQueue = {
    addition: []
  };

  before(function(done) {
    var nock = require('nock');
    // mocking the refresh token request
    nock('https://api.box.com:443')
    .post('/oauth2/token', "grant_type=refresh_token&refresh_token=fake_token&client_secret=" + config.box.secret + "&client_id=" + config.box.api)
    .reply(200, {
      access_token: 'fake_<PASSWORD>'
    });

    // mocking the event call
    nock('https://api.box.com:443')
    .get('/2.0/events?stream_position=1')
    .reply(200, {
      "next_stream_position": "1",
      "entries": [{
        "event_type": "ITEM_MOVE",
        "source": {
          "type": "file",
          "id": "10"
          }
        },
        {"event_type": "ITEM_MOVE",
        "source": {
          "type": "folder",
          "id": "11"
        }
      }]
    });

    // mock the folder crawling
    nock('https://api.box.com:443')
    .get('/2.0/folders/11')
    .reply(200, {
      "item_collection": {
        "entries": [
          {
            "type": "file",
            "id": "1",
            "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc",
          },
          {
            "type": "file",
            "id": "2",
            "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc",
          }
        ],
      }
    });

    done();
  });

  it('should add one file to the addition list and crawl the moved folder', function(done) {
    update({refresh_token: '<PASSWORD>', next_stream_position: '1'}, null, fakeQueue, function(err, cursor, serviceData) {
      cursor.should.not.equal(null);
      serviceData.access_token.should.equal('fake_access');
      serviceData.next_stream_position.should.equal('1');
      fakeQueue.addition.should.have.lengthOf(3);
      fakeQueue.addition[0].id.should.equal('10');
      fakeQueue.addition[1].id.should.equal('1');
      fakeQueue.addition[2].id.should.equal('2');
      done(err);
    });
  });
});
<commit_msg>PR suggestions<commit_after>'use strict';

require('should');

var update = require('../lib/update.js');
var config = require('../config/configuration.js');

describe("Testing the move event", function() {
  var fakeQueue = {
    addition: []
  };

  before(function(done) {
    var nock = require('nock');
    // mocking the refresh token request
    nock('https://api.box.com:443')
    .post('/oauth2/token', "grant_type=refresh_token&refresh_token=fake_token&client_secret=" + config.box.secret + "&client_id=" + config.box.api)
    .reply(200, {
      access_token: '<PASSWORD>'
    });

    // mocking the event call
    nock('https://api.box.com:443')
    .get('/2.0/events?stream_position=1')
    .reply(200, {
      "next_stream_position": "1",
      "entries": [{
        "event_type": "ITEM_MOVE",
        "source": {
          "type": "file",
          "id": "10"
          }
        },
        {
        "event_type": "ITEM_MOVE",
        "source": {
          "type": "folder",
          "id": "11"
        }
      }]
    });

    // mock the folder crawling
    nock('https://api.box.com:443')
    .get('/2.0/folders/11')
    .reply(200, {
      "item_collection": {
        "entries": [
          {
            "type": "file",
            "id": "1",
            "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc",
          },
          {
            "type": "file",
            "id": "2",
            "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc",
          }
        ],
      }
    });

    done();
  });

  it('should add one file to the addition list and crawl the moved folder', function(done) {
    update({refresh_token: '<PASSWORD>', next_stream_position: '1'}, null, fakeQueue, function(err, cursor, serviceData) {
      cursor.should.not.equal(null);
      serviceData.access_token.should.equal('fake_access');
      serviceData.should.have.property('next_stream_position', '1');
      fakeQueue.addition.should.have.lengthOf(3);
      fakeQueue.addition.should.have.lengthOf(3);
      fakeQueue.addition[0].should.have.property('id', '10');
      fakeQueue.addition[1].should.have.property('id', '1');
      fakeQueue.addition[2].should.have.property('id', '2');
      done(err);
    });
  });
});

{'fraction_non_alphanumeric': 0.18008717595778848, 'fraction_numerical': 0.04289974764854324, 'mean_word_length': 2.3590138674884438, 'pattern_counts': {'":': 36, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 6, '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': '1602384', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1433, 'n_words': 230}