<commit_before>// Just leaving the credentials in there, only ever used to test so worst
// someone can do is make tests fail

// Couch currently doesnt support CORS, which means replications need to
// happen from the server the idb database is served from
var remote = {
  host: 'localhost:1234'
};

module('replication', {
  setup : function () {
    this.name = 'test_suite_db';
  }
});

asyncTest("Test basic pull replication", function() {

  var docs = [
    {_id: "0", integer: 0, string: '0'},
    {_id: "1", integer: 1, string: '1'},
    {_id: "2", integer: 2, string: '2'}
  ];

  var remoteUrl = 'http://' + remote.host + '/test_suite_db/';

  initTestDB(this.name, function(err, db) {
    initTestDB(remoteUrl, function(err, remote) {
      remote.bulkDocs({docs: docs}, {}, function(err, results) {
        db.replicate.from(remoteUrl, function(err, result) {
          ok(result.length === docs.length);
          start();
        });
      });
    });
  });
});<commit_msg>Added replication test for populated local database<commit_after>// Just leaving the credentials in there, only ever used to test so worst
// someone can do is make tests fail

// Couch currently doesnt support CORS, which means replications need to
// happen from the server the idb database is served from
var remote = {
  host: 'localhost:1234'
};

module('replication', {
  setup : function () {
    this.name = 'test_suite_db';
  }
});

asyncTest("Test basic pull replication", function() {

  var docs = [
    {_id: "0", integer: 0, string: '0'},
    {_id: "1", integer: 1, string: '1'},
    {_id: "2", integer: 2, string: '2'}
  ];

  var remoteUrl = 'http://' + remote.host + '/test_suite_db/';

  initTestDB(this.name, function(err, db) {
    initTestDB(remoteUrl, function(err, remote) {
      remote.bulkDocs({docs: docs}, {}, function(err, results) {
        db.replicate.from(remoteUrl, function(err, result) {
          ok(result.length === docs.length);
          start();
        });
      });
    });
  });
});

asyncTest("Local DB contains documents", function() {
  var docs = [
    {_id: "0", integer: 0, string: '0'},
    {_id: "1", integer: 1, string: '1'},
    {_id: "2", integer: 2, string: '2'}
  ];

  var remoteUrl = 'http://' + remote.host + '/test_suite_db/';

  initTestDB(this.name, function(err, db) {
    initTestDB(remoteUrl, function(err, remote) {
      remote.bulkDocs({docs: docs}, {}, function(err, _) {
        db.bulkDocs({docs: docs}, {}, function(err, _) {
          db.replicate.from(remoteUrl, function(err, _) {
            db.allDocs(function(err, result) {
              ok(result.rows.length === docs.length);
              start();
            });
          });
        });
      });
    });
  });
});
{'fraction_non_alphanumeric': 0.16934306569343066, 'fraction_numerical': 0.012773722627737226, 'mean_word_length': 2.8660084626234132, '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': '4408642', 'n_tokens_mistral': 918, 'n_tokens_neox': 878, 'n_words': 247}