<commit_before>'use strict';

var tape = require('../lib/thaliTape');

var fs = require('fs');
var PouchDB = require('pouchdb');
var PouchDBGenerator = require('thali/NextGeneration/utils/pouchDBGenerator');
var leveldownMobile = require('leveldown-mobile');

var defaultDirectory = './db/';

if (! fs.existsSync(defaultDirectory)){
    fs.mkdirSync(defaultDirectory);
}

var test = tape({
  setup: function (t) {
    t.end();
  },
  teardown: function (t) {
    t.end();
  }
});

function compareFunctions(a, b) {
  if (a.toString() != b.toString()) {
    return false;
  }
  // this code is going to compare toString() of all functions in the prototype
  function getPrototypeKeys(obj) {
    var keys = [];
    for (var key in obj.prototype) {
      if (obj.prototype.hasOwnProperty(key)) {
        keys.push(key);
      }
    }
    return keys;
  }
  var keys = getPrototypeKeys(a).concat(getPrototypeKeys(b));
  for (var i = 0; i < keys.length; i ++) {
    var key = keys[i];
    if (
       !a.prototype.hasOwnProperty(key) ||
       !b.prototype.hasOwnProperty(key) ||
       a.prototype[key].toString() != b.prototype[key].toString()
    ) {
      return false;
    }
  }
  return true;
}

test('test defaultDirectory', function (t) {
  var LocalPouchDB = PouchDBGenerator(PouchDB, defaultDirectory);

  var db = LocalPouchDB('https://localhost:3000');
  t.equals(db.__opts.prefix, undefined);

  db = LocalPouchDB('http://localhost:3000');
  t.equals(db.__opts.prefix, undefined);<commit_msg>added check for prototype function<commit_after>'use strict';

var tape = require('../lib/thaliTape');

var fs = require('fs');
var PouchDB = require('pouchdb');
var PouchDBGenerator = require('thali/NextGeneration/utils/pouchDBGenerator');
var leveldownMobile = require('leveldown-mobile');

var defaultDirectory = './db/';

if (! fs.existsSync(defaultDirectory)){
    fs.mkdirSync(defaultDirectory);
}

var test = tape({
  setup: function (t) {
    t.end();
  },
  teardown: function (t) {
    t.end();
  }
});

function compareFunctions(a, b) {
  if (a.toString() != b.toString()) {
    return false;
  }
  // this code is going to compare toString() of all functions in the prototype
  function getPrototypeKeys(obj) {
    var keys = [];
    for (var key in obj.prototype) {
      if (obj.prototype.hasOwnProperty(key) && typeof obj.prototype[key] === 'function') {
        keys.push(key);
      }
    }
    return keys;
  }
  var keys = getPrototypeKeys(a).concat(getPrototypeKeys(b));
  for (var i = 0; i < keys.length; i ++) {
    var key = keys[i];
    if (
       !a.prototype.hasOwnProperty(key) ||
       !b.prototype.hasOwnProperty(key) ||
       a.prototype[key].toString() != b.prototype[key].toString()
    ) {
      return false;
    }
  }
  return true;
}

test('test defaultDirectory', function (t) {
  var LocalPouchDB = PouchDBGenerator(PouchDB, defaultDirectory);

  var db = LocalPouchDB('https://localhost:3000');
  t.equals(db.__opts.prefix, undefined);

  db = LocalPouchDB('http://localhost:3000');
  t.equals(db.__opts.prefix, undefined);
{'fraction_non_alphanumeric': 0.1598694942903752, 'fraction_numerical': 0.005872756933115824, 'mean_word_length': 3.4890190336749636, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5519700', 'n_tokens_mistral': 1011, 'n_tokens_neox': 1004, 'n_words': 222}