<commit_before>"use strict";

var assert = require("@sinonjs/referee").assert;
require("jsdom-global")();
var samsam = require("./samsam");

describe("isElement", function() {
    it("returns true if DOM element node", function() {
        var element = document.createElement("div");
        var checkElement = samsam.isElement(element);
        assert.isTrue(checkElement);
    });

    it("returns false if DOM text node", function() {
        var element = document.createTextNode("Hello");
        var checkElement = samsam.isElement(element);
        assert.isFalse(checkElement);
    });

    it("returns false if node like object", function() {
        var nodeLike = { nodeType: 1 };
        var checkElement = samsam.isElement(nodeLike);
        assert.isFalse(checkElement);
    });

    it("returns false if number", function() {
        var checkElement = samsam.isElement(42);
        assert.isFalse(checkElement);
    });

    it("returns false if object", function() {
        var checkElement = samsam.isElement({});
        assert.isFalse(checkElement);
    });
});<commit_msg>Improve isolation of is-element.test.js<commit_after>"use strict";

var assert = require("@sinonjs/referee").assert;

// in order for `is-element.js` to correctly detect the DOM being set up
// in the previous line, we need to reload it, as other tests will have
// loaded `is-element.js`, most likely without a DOM in place
function requireWithDOM(file) {
    require("jsdom-global")();

    delete require.cache[require.resolve(file)];

    return require("./is-element");
}

describe("isElement", function() {
    var isElement;

    before(function() {
        isElement = requireWithDOM("./is-element");
    });

    it("returns true if DOM element node", function() {
        var element = document.createElement("div");
        var checkElement = isElement(element);
        assert.isTrue(checkElement);
    });

    it("returns false if DOM text node", function() {
        var element = document.createTextNode("Hello");
        var checkElement = isElement(element);
        assert.isFalse(checkElement);
    });

    it("returns false if node like object", function() {
        var nodeLike = { nodeType: 1 };
        var checkElement = isElement(nodeLike);
        assert.isFalse(checkElement);
    });

    it("returns false if number", function() {
        var checkElement = isElement(42);
        assert.isFalse(checkElement);
    });

    it("returns false if object", function() {
        var checkElement = isElement({});
        assert.isFalse(checkElement);
    });
});
{'fraction_non_alphanumeric': 0.1381044487427466, 'fraction_numerical': 0.0023210831721470018, 'mean_word_length': 3.111287758346582, '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': '4000773', 'n_tokens_mistral': 722, 'n_tokens_neox': 708, 'n_words': 190}