<commit_before>'use strict';

var chai = require('chai'),
    viewer = require('../lib/viewer.js');

chai.should();

describe('Viewer', function() {
  var bulkData = {
    "nodes": [
      {"id": "A"},
      {"id": "B"},
      {"id": "C"},
      {"id": "D"},
      {"id": "E"},
      {"id": "F"},
      {"id": "G"}
    ],
    "links": [
      {"source": "A", "target": "B"},
      {"source": "B", "target": "C"},
      {"source": "A", "target": "D"},
      {"source": "B", "target": "E"},
      {"source": "C", "target": "E"},
      {"source": "D", "target": "E"},
      {"source": "E", "target": "F"},
      {"source": "F", "target": "G"}]
  };
  var streamData = {"stream": [{"type": "node", "id": "H"}, {"type": "link", "source": "H", "target": "A"}]};
  describe('#setupLayout()', function() {
    before(function(done) {
      viewer.setupLayout({w: 960, h: 500});
      done();
    });
    it('should set the expected layout properties', function(done) {
      ['nodes', 'links', 'size', 'linkDistance', 'charge'].map(function(p) {
        viewer.layout.should.have.property(p);
      });
      done();
    });
  });
  describe('#insertInLayout()', function() {
    before(function(done) {
      viewer.setupLayout({w: 480, h: 250});
      viewer.insertInLayout(bulkData.nodes, bulkData.links);
      done();
    });
    it('should insert nodes in the layout', function(done) {
      var nodes = viewer.layout.nodes();
      bulkData.nodes.map(function(d) { return d.id; }).should.eql(nodes.map(function(d) { return d.id; }));
      done();
    });
    it('should insert link sources in the layout', function(done) {
      var links = viewer.layout.links();
      bulkData.links.map(function(d) { return d.source; }).should.eql(links.map(function(d) { return d.source.id; }));
      done();
    });
    it('should insert link targets in the layout', function(done) {
      var links = viewer.layout.links();
      bulkData.links.map(function(d) { return d.target; }).should.eql(links.map(function(d) { return d.target.id; }));
      done();
    });
    it('should set correct link properties', function(done) {
      var links = viewer.layout.links();
      ['index', 'weight', 'x', 'y', 'px', 'py'].map(function(p) {
        links.map(function(d) {
          d.source.should.have.property(p);
          d.target.should.have.property(p);
        });
      });
      done();
    });
  });
  describe('data formatting', function() {
    before(function(done) {
      // setup mock server
      done();
    });
    describe('#dataIn()', function() {<commit_msg>cleanup<commit_after>'use strict';

var chai = require('chai'),
    viewer = require('../lib/viewer.js');

chai.should();

describe('Viewer', function() {
  var bulkData = {
    "nodes": [
      {"id": "A"},
      {"id": "B"},
      {"id": "C"},
      {"id": "D"},
      {"id": "E"},
      {"id": "F"},
      {"id": "G"}
    ],
    "links": [
      {"source": "A", "target": "B"},
      {"source": "B", "target": "C"},
      {"source": "A", "target": "D"},
      {"source": "B", "target": "E"},
      {"source": "C", "target": "E"},
      {"source": "D", "target": "E"},
      {"source": "E", "target": "F"},
      {"source": "F", "target": "G"}]
  };
  var streamData = {"stream": [{"type": "node", "id": "H"}, {"type": "link", "source": "H", "target": "A"}]};
  describe('#setupLayout()', function() {
    before(function(done) {
      viewer.setupLayout({w: 960, h: 500});
      done();
    });
    it('should set the expected layout properties', function(done) {
      ['nodes', 'links', 'size', 'linkDistance', 'charge'].map(function(p) {
        viewer.layout.should.have.property(p);
      });
      done();
    });
  });
  describe('#insertInLayout()', function() {
    before(function(done) {
      viewer.setupLayout({w: 480, h: 250});
      viewer.insertInLayout(bulkData.nodes, bulkData.links);
      done();
    });
    it('should insert nodes in the layout', function(done) {
      var nodes = viewer.layout.nodes();
      bulkData.nodes.map(function(d) { return d.id; }).should.eql(nodes.map(function(d) { return d.id; }));
      done();
    });
    it('should insert link sources in the layout', function(done) {
      var links = viewer.layout.links();
      bulkData.links.map(function(d) { return d.source; }).should.eql(links.map(function(d) { return d.source.id; }));
      done();
    });
    it('should insert link targets in the layout', function(done) {
      var links = viewer.layout.links();
      bulkData.links.map(function(d) { return d.target; }).should.eql(links.map(function(d) { return d.target.id; }));
      done();
    });
    it('should set correct link properties', function(done) {
      var links = viewer.layout.links();
      ['index', 'weight', 'x', 'y', 'px', 'py'].map(function(p) {
        links.map(function(d) {
          d.source.should.have.property(p);
          d.target.should.have.property(p);
        });
      });
      done();
    });
  });
  describe('data formatting', function() {
    describe('#dataIn()', function() {
{'fraction_non_alphanumeric': 0.2354806739345887, 'fraction_numerical': 0.004757185332011893, 'mean_word_length': 2.8372623574144487, 'pattern_counts': {'":': 62, '<': 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': '7088351', 'n_tokens_mistral': 1705, 'n_tokens_neox': 1682, 'n_words': 369}