<commit_before>'use strict';

require('should');
var box = require('../lib/provider-box/helpers/box');
var config = require('../config/configuration.js');

describe("Box API wrapper", function() {
  describe('getConnectUrl()', function() {
    it("should redirect to box.com", function(done) {
      var url = box.getConnectUrl();
      url.should.include('box.com');

      done();
    });
  });

  describe('getRefreshToken()', function() {
    it("should fail on invalid authorization_grant", function(done) {
      box.getRefreshToken('invalid', function(err, refreshToken) {
        err.should.not.eql(null);
        if(refreshToken) {
          throw new Error("No refreshToken should be returned");
        }

        done();
      });
    });
  });

  describe('getAccessToken()', function() {
    it("should fail on invalid refreshToken", function(done) {
      box.getAccessToken('invalid', function(err, accessToken) {
        err.should.not.eql(null);
        if(accessToken) {
          throw new Error("No refreshToken should be returned");
        }

        done();
      });
    });
    it("should return accessToken", function(done) {
      box.getAccessToken(config.test_refresh_token, function(err, accessToken) {
        if(err) {
          throw err;
        }

        accessToken.should.not.eql(null);
        
        done();
      });
    });
  });
});<commit_msg>Test for listFolder<commit_after>'use strict';

require('should');
var box = require('../lib/provider-box/helpers/box');
var config = require('../config/configuration.js');

describe("Box API wrapper", function() {
  var accessToken;

  describe('getConnectUrl()', function() {
    it("should redirect to box.com", function(done) {
      var url = box.getConnectUrl();
      url.should.include('box.com');

      done();
    });
  });

  describe('getRefreshToken()', function() {
    it("should fail on invalid authorization_grant", function(done) {
      box.getRefreshToken('invalid', function(err, refreshToken) {
        err.should.not.eql(null);
        if(refreshToken) {
          throw new Error("No refreshToken should be returned");
        }

        done();
      });
    });
  });

  describe('getAccessToken()', function() {
    it("should fail on invalid refreshToken", function(done) {
      box.getAccessToken('invalid', function(err, accessToken) {
        err.should.not.eql(null);
        if(accessToken) {
          throw new Error("No refreshToken should be returned");
        }

        done();
      });
    });
    it("should return accessToken", function(done) {
      box.getAccessToken(config.test_refresh_token, function(err, _accessToken) {
        if(err) {
          throw err;
        }

        _accessToken.should.not.eql(null);
        accessToken = _accessToken;

        done();
      });
    });
  });

  describe('listFolder()', function() {
    it("should list content in folder", function(done) {
      box.listFolder(0, accessToken, function(err, entries) {
        if(err) {
          throw err;
        }

        entries.length.should.be.above(0);

        done();
      });
    });
  });
});
{'fraction_non_alphanumeric': 0.15878594249201278, 'fraction_numerical': 0.0006389776357827476, 'mean_word_length': 2.598850574712644, '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': '5671221', 'n_tokens_mistral': 916, 'n_tokens_neox': 893, 'n_words': 181}