<commit_before>// Load in dependencies
var expect = require('chai').expect;
var FakePinboard = require('./utils/fake-pinboard');
var Pinboard = require('../');

// Define test utilities
var pinboardUtils = {
  init: function (params) {
    before(function createClient () {
      this.client = new Pinboard(params);
    });
    after(function cleanup () {
      delete this.client;
    });
  },
  execSync: function (fn) {
    before(function execSyncFn () {
      this.result = fn.call(this);
    });
    after(function cleanup () {
      delete this.result;
    });
  },
  execRequest: function (fn) {
    before(function execRequestFn (done) {
      var that = this;
      fn.call(this, function handleResponse (err, res, body) {
        that.err = err;
        that.res = res;
        that.body = body;
        done();
      });
    });
    after(function cleanup () {
      delete this.err;
      delete this.res;
      delete this.body;
    });
  }
};

// Start our tests
describe('An HTTP pinboard.js user', function () {
  pinboardUtils.init({
    auth: {
      type: 'http',
      username: 'todd',
      password: 'password'
    }
  });

  describe('building a URL', function () {
    pinboardUtils.execSync(function buildUrl () {
      return this.client.buildUrl({
        pathname: '/posts/get',
        query: {
          tag: 'hello'
        }
      });
    });

    it('receives a valid URL', function () {
      expect(this.result).to.equal('https://todd:password@api.pinboard.in/v1/posts/get?tag=hello');
    });
  });
});

describe('An API pinboard.js user', function () {
  pinboardUtils.init({
    auth: {
      type: 'token',
      username: 'todd',
      token: 'password'
    }
  });

  describe('building a URL', function () {
    pinboardUtils.execSync(function buildUrl () {
      return this.client.buildUrl({
        pathname: '/posts/get',
        query: {
          tag: 'hello'
        }
      });
    });

    it('receives a valid URL', function () {
      var expectedUrl = 'https://api.pinboard.in/v1/posts/get?auth_token=<PASSWORD>&tag=hello';
      expect(this.result).to.equal(expectedUrl);
    });
  });
});

describe('A pinboard.js user', function () {
  FakePinboard.run();
  pinboardUtils.init({
    // test-credentials = {type, username, token}
    // TODO: Require in a common location
    auth: require('./test-credentials'),
    // TODO: Define in a common location
    url: {
      protocol: 'http:',
      hostname: 'localhost',
      port: 9001,
      pathname: '/v1'
    }
  });

  describe('requesting an update page', function () {
    pinboardUtils.execRequest(function buildUrl (done) {
      this.client.postsUpdate({format: 'json'}, done);
    });

    it('receives a valid response', function () {
      // TODO: Use eight-track to force response value
      expect(this.err).to.equal(null);
      expect(this.res.statusCode).to.equal(200);
      // expect(this.body).to.equal(200);
    });
  });
});<commit_msg>Added fallback to get Travis CI passing<commit_after>// Load in dependencies
var expect = require('chai').expect;
var FakePinboard = require('./utils/fake-pinboard');
var Pinboard = require('../');

// Define test utilities
var pinboardUtils = {
  init: function (params) {
    before(function createClient () {
      this.client = new Pinboard(params);
    });
    after(function cleanup () {
      delete this.client;
    });
  },
  execSync: function (fn) {
    before(function execSyncFn () {
      this.result = fn.call(this);
    });
    after(function cleanup () {
      delete this.result;
    });
  },
  execRequest: function (fn) {
    before(function execRequestFn (done) {
      var that = this;
      fn.call(this, function handleResponse (err, res, body) {
        that.err = err;
        that.res = res;
        that.body = body;
        done();
      });
    });
    after(function cleanup () {
      delete this.err;
      delete this.res;
      delete this.body;
    });
  }
};

// Start our tests
describe('An HTTP pinboard.js user', function () {
  pinboardUtils.init({
    auth: {
      type: 'http',
      username: 'todd',
      password: 'password'
    }
  });

  describe('building a URL', function () {
    pinboardUtils.execSync(function buildUrl () {
      return this.client.buildUrl({
        pathname: '/posts/get',
        query: {
          tag: 'hello'
        }
      });
    });

    it('receives a valid URL', function () {
      expect(this.result).to.equal('https://todd:password@api.pinboard.in/v1/posts/get?tag=hello');
    });
  });
});

describe('An API pinboard.js user', function () {
  pinboardUtils.init({
    auth: {
      type: 'token',
      username: 'todd',
      token: 'password'
    }
  });

  describe('building a URL', function () {
    pinboardUtils.execSync(function buildUrl () {
      return this.client.buildUrl({
        pathname: '/posts/get',
        query: {
          tag: 'hello'
        }
      });
    });

    it('receives a valid URL', function () {
      var expectedUrl = 'https://api.pinboard.in/v1/posts/get?auth_token=<PASSWORD>%3Apassword&tag=hello';
      expect(this.result).to.equal(expectedUrl);
    });
  });
});

var credentials;
try {
  // test-credentials = {type, username, token}
  credentials = require('./test-credentials');
} catch (err) {
  console.error('Error while loading `test/test-credentials.json`. ' +
      'Assuming we want to use `nine-track` fixtures, using default credentials. ' +
      'If not, please see Testing section in `README.md`', err);
  credentials = {
    type: 'token',
    username: 'testuser',
    token: 'abcdef'
  };
}
describe('A pinboard.js user', function () {
  FakePinboard.run();
  pinboardUtils.init({
    auth: credentials,
    // TODO: Define in a common location
    url: {
      protocol: 'http:',
      hostname: 'localhost',
      port: 9001,
      pathname: '/v1'
    }
  });

  describe('requesting an update page', function () {
    pinboardUtils.execRequest(function buildUrl (done) {
      this.client.postsUpdate({format: 'json'}, done);
    });

    it('receives a valid response', function () {
      // TODO: Use eight-track to force response value
      expect(this.err).to.equal(null);
      expect(this.res.statusCode).to.equal(200);
      // expect(this.body).to.equal(200);
    });
  });
});
{'fraction_non_alphanumeric': 0.1600633914421553, 'fraction_numerical': 0.00427892234548336, 'mean_word_length': 2.492529053680133, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1267863', 'n_tokens_mistral': 1996, 'n_tokens_neox': 1955, 'n_words': 437}