<commit_before>import {assert} from 'chai';

var jsdom = require('jsdom');

import {Transformime} from '../src/transformime';
import {DefaultRenderer} from '../src/defaultrenderer';

/**
 * Dummy Renderer for spying on
 */
class DummyRenderer{
    constructor(mimetype) {
        this._mimetype = mimetype;
    }

    get mimetype() {
        return this._mimetype;
    }

    set mimetype(mimetype) {
       this._mimetype = mimetype;
    }

    transform(data, doc) {
        let pre = doc.createElement('pre');
        pre.textContent = data;
        return pre;
    }
}


describe('Transformime defaults', function() {
    before(function() {
        this.document = jsdom.jsdom();
    });
    describe('default constructor', function() {
        before(function(){
            this.t = new Transformime();
        });
        it('should have default renderers', function() {
            assert(Array.isArray(this.t.renderers));
        });
        it('should have the DefaultRenderer as the fallbackRenderer', function() {
            assert(this.t.fallbackRenderer instanceof DefaultRenderer);
        });
    });
});

describe('Transformime', function() {
    beforeEach(function() {
        this.dummyRenderer1 = new DummyRenderer("transformime/dummy1");
        this.dummyRenderer2 = new DummyRenderer("transformime/dummy2");
        this.dummyRenderer3 = new DummyRenderer("transformime/dummy3");
        this.renderers = [
            this.dummyRenderer1,
            this.dummyRenderer2,
            this.dummyRenderer3
        ];
        this.t = new Transformime(this.renderers);
        this.document = jsdom.jsdom();<commit_msg>import jsdom from jsdom<commit_after>import {assert} from 'chai';

import {jsdom} from 'jsdom';

import {Transformime} from '../src/transformime';
import {DefaultRenderer} from '../src/defaultrenderer';

/**
 * Dummy Renderer for spying on
 */
class DummyRenderer{
    constructor(mimetype) {
        this._mimetype = mimetype;
    }

    get mimetype() {
        return this._mimetype;
    }

    set mimetype(mimetype) {
       this._mimetype = mimetype;
    }

    transform(data, doc) {
        let pre = doc.createElement('pre');
        pre.textContent = data;
        return pre;
    }
}


describe('Transformime defaults', function() {
    before(function() {
        this.document = jsdom();
    });
    describe('default constructor', function() {
        before(function(){
            this.t = new Transformime();
        });
        it('should have default renderers', function() {
            assert(Array.isArray(this.t.renderers));
        });
        it('should have the DefaultRenderer as the fallbackRenderer', function() {
            assert(this.t.fallbackRenderer instanceof DefaultRenderer);
        });
    });
});

describe('Transformime', function() {
    beforeEach(function() {
        this.dummyRenderer1 = new DummyRenderer("transformime/dummy1");
        this.dummyRenderer2 = new DummyRenderer("transformime/dummy2");
        this.dummyRenderer3 = new DummyRenderer("transformime/dummy3");
        this.renderers = [
            this.dummyRenderer1,
            this.dummyRenderer2,
            this.dummyRenderer3
        ];
        this.t = new Transformime(this.renderers);
        this.document = jsdom();
{'fraction_non_alphanumeric': 0.12754946727549468, 'fraction_numerical': 0.005479452054794521, 'mean_word_length': 2.540948275862069, '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': '7524512', 'n_tokens_mistral': 929, 'n_tokens_neox': 908, 'n_words': 189}