<commit_before>var tape = require("tape");
var jsdom = require("./jsdom");
var d3 = require("d3-selection");
var d3_graphviz = require("../");
var Worker = require("tiny-worker");

tape("dot() performs layout in a web worker in the background with text/javascript tag.", function(test) {

    var window = global.window = jsdom(
        `
            <script src="http://dummyhost/node_modules/viz.js/viz.js" type="text/javascript"></script>
            <div id="graph"></div>
            `,
    );
    var document = global.document = window.document;
    var Blob = global.Blob = function (jsarray) {
        return new Function(jsarray[0]);
    }
    var createObjectURL = window.URL.createObjectURL = function (js) {
        return js;
    }
    global.Worker = Worker;

    var graphviz = d3_graphviz.graphviz("#graph");

    graphviz
        .logEvents(true)
        .on("initEnd", function () {
            part1();
        });

    function handleError(err) {
        test.equal(
            err,
            "syntax error in line 1 near 'bad'\n",
            'A registered error handler catches syntax errors in the dot source thrown during layout'<commit_msg>Port dot-worker-through-text-javascript-tag-test.js to hpcc-js-wasm<commit_after>var tape = require("tape");
var jsdom = require("./jsdom");
var d3 = require("d3-selection");
var d3_graphviz = require("../");
var Worker = require("tiny-worker");

tape("dot() performs layout in a web worker in the background with text/javascript tag.", function(test) {

    var window = global.window = jsdom(
        `
            <script src="http://dummyhost/test/@hpcc-js/wasm/dist/wrapper.js" type="text/javascript"></script>
            <div id="graph"></div>
            `,
    );
    var document = global.document = window.document;
    var Blob = global.Blob = function (jsarray) {
        return new Function(jsarray[0]);
    }
    var createObjectURL = window.URL.createObjectURL = function (js) {
        return js;
    }
    global.Worker = Worker;

    var graphviz = d3_graphviz.graphviz("#graph");

    graphviz
        .logEvents(true)
        .on("initEnd", function () {
            part1();
        });

    function handleError(err) {
        test.equal(
            err,
            "syntax error in line 1 near 'bad'\n",
            'A registered error handler catches syntax errors in the dot source thrown during layout'
{'fraction_non_alphanumeric': 0.135, 'fraction_numerical': 0.005833333333333334, 'mean_word_length': 2.4746743849493487, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3396126', 'n_tokens_mistral': 718, 'n_tokens_neox': 700, 'n_words': 186}