<commit_before>/// <reference types="jasmine" />

import networkViz from "../src/networkViz";
const n = require("../src/networkViz");

describe("Importing", function(){
    it("Should import as a function", () => {
        // Demonstrates require import path.
        expect(typeof n.default).toEqual("function");
        expect(typeof networkViz).toEqual("function");
    });
});

describe("Api", function() {
    // inject the HTML for the tests
    beforeEach(function() {
        const domHTML = '<div id="graph"></div>';

        document.body.insertAdjacentHTML(
            "afterbegin",
            domHTML,
        );
    });

    // remove the html after each test
    afterEach(function() {
        document.body.removeChild(document.getElementById("graph"));
    });

    it("Test creation of graph with default options", function() {
        expect(document.getElementsByTagName("svg").length).toEqual(0);
        expect(document.getElementsByClassName("svg-container").length).toBeFalsy();
        networkViz("graph");
        expect(document.getElementsByTagName("svg").length).toEqual(1);
        expect(document.getElementsByClassName("svg-container").length).toBeTruthy();
        expect((<SVGElement>document.getElementsByTagName("svg")[0]).getAttribute("viewBox").split(/\s+|,/)).toEqual(["0", "0", "900", "600"]);
    });

    it("Add a node", function(done) {
        const graph = networkViz("graph");
        graph.addNode({hash: "1", shortname: " "}, () => {
            expect(document.getElementsByTagName("path").length).toEqual(1);
            done();
        });
    });

    it("Add a triplet between two nodes", function(done) {
        const graph = networkViz("graph");
        const node1 = {hash: "1", shortname: "My Node!"};<commit_msg>added batch node test<commit_after>/// <reference types="jasmine" />

import networkViz from "../src/networkViz";
const n = require("../src/networkViz");

describe("Importing", function(){
    it("Should import as a function", () => {
        // Demonstrates require import path.
        expect(typeof n.default).toEqual("function");
        expect(typeof networkViz).toEqual("function");
    });
});

describe("Api", function() {
    // inject the HTML for the tests
    beforeEach(function() {
        const domHTML = '<div id="graph"></div>';

        document.body.insertAdjacentHTML(
            "afterbegin",
            domHTML,
        );
    });

    // remove the html after each test
    afterEach(function() {
        document.body.removeChild(document.getElementById("graph"));
    });

    it("Test creation of graph with default options", function() {
        expect(document.getElementsByTagName("svg").length).toEqual(0);
        expect(document.getElementsByClassName("svg-container").length).toBeFalsy();
        networkViz("graph");
        expect(document.getElementsByTagName("svg").length).toEqual(1);
        expect(document.getElementsByClassName("svg-container").length).toBeTruthy();
        expect((<SVGElement>document.getElementsByTagName("svg")[0]).getAttribute("viewBox").split(/\s+|,/)).toEqual(["0", "0", "900", "600"]);
    });

    it("Add a node", function(done) {
        const graph = networkViz("graph");
        graph.addNode({hash: "1", shortname: " "}, () => {
            expect(document.getElementsByTagName("path").length).toEqual(1);
            done();
        });
    });

    it("Add many nodes", function(done) {
        const graph = networkViz("graph");
        const node1 = {hash: "1", shortname: "<NAME>!"};
        const node2 = {hash: "2", shortname: "Another node!"};
        graph.addNode([node1, node2], () => {
            expect(document.getElementsByClassName("node").length).toEqual(2);
            done();
        });
    });

    it("Add a triplet between two nodes", function(done) {
        const graph = networkViz("graph");
        const node1 = {hash: "1", shortname: "<NAME>!"};
{'fraction_non_alphanumeric': 0.17762487257900103, 'fraction_numerical': 0.009429153924566768, 'mean_word_length': 3.0339157245632067, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 18, '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': '332195', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1113, 'n_words': 215}