<commit_before>
var assert = require('assert')
var graphDiff = require('./index')

var nodes = {
  1: [],
  2: [1],
  3: [2],
  4: [2],
  5: [4],
  6: [3, 5],
  7: [6],
  8: [5],
  9: [8],
  10: [7, 9],
  11: [10],
  12: [11],
  13: [10],
  14: [13],
  15: [12, 14],
  16: [15]
}

/* the graph:

    4-5-8-9    11-12
   /   \   \  /     \
1-2-3---6-7-10-13-14-15-16

*/

var readParents = function(id, cb) {
  cb(null, nodes[id])
}

var tests = [
  {from: 8, to: 9, expected: [9]},
  {from: 7, to: 9, expected: [9, 8]},
  {from: 6, to: 7, expected: [7]},
  {from: 5, to: 7, expected: [7, 6, 3]},
  {from: 4, to: 7, expected: [7, 6, 3, 5]},
  {from: 1, to: 7, expected: [7, 6, 3, 2, 5, 4]},
  {from: 1, to: 9, expected: [9, 8, 5, 4, 2]},
  {from: 9, to: 16, expected: [16,15,12,11,10,7,6,3,14,13]},
  {from: 1, to: 16, expected: [16,15,12,11,10,7,6,3,2,5,4,9,8,14,13]}
]

describe('graph-difference', function() {
  tests.forEach(function(each, i) {
    it('should run test ' + i, function(done) {
      graphDiff(each.from, each.to, readParents, function(err, res) {
        assert.deepEqual(res, each.expected)
        done()
      })
    })
  })
})
<commit_msg>improve tests<commit_after>
var assert = require('assert')
var graphDiff = require('./index')

var nodes = {
  1: [],
  2: [1],
  3: [2],
  4: [2],
  5: [4],
  6: [3, 5],
  7: [6],
  8: [5],
  9: [8],
  10: [7, 9],
  11: [10],
  12: [11],
  13: [10],
  14: [13],
  15: [12, 14],
  16: [15]
}

/* the graph:

    4-5-8-9    11-12
   /   \   \  /     \
1-2-3---6-7-10-13-14-15-16

*/

var readParents = function(id, cb) {
  cb(null, nodes[id])
}

var tests = [
  {from: 8, to: 9, expected: [9]},
  {from: 7, to: 9, expected: [9, 8]},
  {from: 6, to: 7, expected: [7]},
  {from: 5, to: 7, expected: [7, 6, 3]},
  {from: 4, to: 7, expected: [7, 6, 3, 5]},
  {from: 1, to: 7, expected: [7, 6, 3, 2, 5, 4]},
  {from: 1, to: 9, expected: [9, 8, 5, 4, 2]},
  {from: 9, to: 16, expected: [16,15,12,11,10,7,6,3,14,13]},
  {from: 1, to: 16, expected: [16,15,12,11,10,7,6,3,2,5,4,9,8,14,13]}
]

describe('graph-difference', function() {
  tests.forEach(function(each, i) {
    it('diff from ' + each.from + ' to ' + each.to + ' test(' + i + ')', function(done) {
      graphDiff(each.from, each.to, readParents, function(err, res) {
        assert.deepEqual(res, each.expected)
        done()
      })
    })
  })
})

{'fraction_non_alphanumeric': 0.25717905405405406, 'fraction_numerical': 0.12837837837837837, 'mean_word_length': 2.6223241590214066, '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': '2151987', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1132, 'n_words': 288}