<commit_before>'use strict';
/* global $APPLICATION, $SERVICE, $ROUTER, $SERVICE*/
var expect = require('chai').expect,
    mPath = require('path');

describe('Requiring the nodgine should deliver a working object', function () {
    var nodgine = require('../../src/bootstrap.js');

    it('should be requireable as node module', function () {
        function doRequire() {
            var rNodgine = require('../../');

            expect(rNodgine).to.be.an('object');
            expect(rNodgine).to.equal(nodgine);
        }

        expect(doRequire).not.to.throw(doRequire);
    });

    it('should contain the four main objects', function () {
        expect(nodgine.$APPLICATION).to.be.an('object');
        expect(nodgine.$LOGGER).to.be.an('object');
        expect(nodgine.$ROUTER).to.be.an('object');
        expect(nodgine.$SERVICE).to.be.an('object');
    });

    it('should not globalize the four main objects without the call', function () {
        expect(global.$APPLICATION).to.be.undefined();
        expect(global.$LOGGER).to.be.undefined();
        expect(global.$ROUTER).to.be.undefined();
        expect(global.$SERVICE).to.be.undefined();
    });

    it('should globalize the four main objects on call', function () {
        nodgine.globalize();

        expect(global.$APPLICATION).to.be.an('object');
        expect(global.$LOGGER).to.be.an('object');
        expect(global.$ROUTER).to.be.an('object');
        expect(global.$SERVICE).to.be.an('object');

        expect(global.$APPLICATION).to.equal(nodgine.$APPLICATION);
        expect(global.$LOGGER).to.equal(nodgine.$LOGGER);
        expect(global.$ROUTER).to.equal(nodgine.$ROUTER);
        expect(global.$SERVICE).to.equal(nodgine.$SERVICE);
    });

    it('should throw an error when trying to load a file that does not exist', function () {
        function load() {
            nodgine.loadFromFile('iDontExist.json');
        }

        expect(load).to.throw();
    });

    it('should throw an error when loading a not valid json file', function () {
        function load() {
                nodgine.loadFromFile(mPath.resolve(__dirname, './loadfromfile/testservice.js'));
            }

            expect(load).to.throw();
    });

    it('should throw an error when passing the wrong parameter type to loadFromFile', function () {
        var data = [0, 1, 3.14, -5, [], {}, undefined, null];
        function load(value) {
            nodgine.loadFromFile(value);
        }

        data.forEach(function (value) {
            expect(load.bind(null, value)).to.throw();
        });
    });

    describe('Loading the testnodgine.json should result in a working server', function () {
        global.$APPLICATION = undefined;
        global.$LOGGER = undefined;
        global.$ROUTER = undefined;
        global.$SERVICE = undefined;

        it('should not throw an error loading the file', function () {
            function load() {
                nodgine.loadFromFile(mPath.resolve(__dirname, './loadfromfile/testnodgine.json'));
            }

            expect(load).not.to.throw();
        });

        it('should have globalized all main objects, because the option was on true', function () {<commit_msg>Added cleanup for bootstrap.spec<commit_after>'use strict';
/* global $APPLICATION, $SERVICE, $ROUTER, $SERVICE*/
var expect = require('chai').expect,
    mPath = require('path');

describe('Requiring the nodgine should deliver a working object', function () {
    var nodgine = require('../../src/bootstrap.js');

    it('should be requireable as node module', function () {
        function doRequire() {
            var rNodgine = require('../../');

            expect(rNodgine).to.be.an('object');
            expect(rNodgine).to.equal(nodgine);
        }

        expect(doRequire).not.to.throw(doRequire);
    });

    it('should contain the four main objects', function () {
        expect(nodgine.$APPLICATION).to.be.an('object');
        expect(nodgine.$LOGGER).to.be.an('object');
        expect(nodgine.$ROUTER).to.be.an('object');
        expect(nodgine.$SERVICE).to.be.an('object');
    });

    it('should not globalize the four main objects without the call', function () {
        expect(global.$APPLICATION).to.be.undefined();
        expect(global.$LOGGER).to.be.undefined();
        expect(global.$ROUTER).to.be.undefined();
        expect(global.$SERVICE).to.be.undefined();
    });

    it('should globalize the four main objects on call', function () {
        nodgine.globalize();

        expect(global.$APPLICATION).to.be.an('object');
        expect(global.$LOGGER).to.be.an('object');
        expect(global.$ROUTER).to.be.an('object');
        expect(global.$SERVICE).to.be.an('object');

        expect(global.$APPLICATION).to.equal(nodgine.$APPLICATION);
        expect(global.$LOGGER).to.equal(nodgine.$LOGGER);
        expect(global.$ROUTER).to.equal(nodgine.$ROUTER);
        expect(global.$SERVICE).to.equal(nodgine.$SERVICE);
    });

    it('should throw an error when trying to load a file that does not exist', function () {
        function load() {
            nodgine.loadFromFile('iDontExist.json');
        }

        expect(load).to.throw();
    });

    it('should throw an error when loading a not valid json file', function () {
        function load() {
                nodgine.loadFromFile(mPath.resolve(__dirname, './loadfromfile/testservice.js'));
            }

            expect(load).to.throw();
    });

    it('should throw an error when passing the wrong parameter type to loadFromFile', function () {
        var data = [0, 1, 3.14, -5, [], {}, undefined, null];
        function load(value) {
            nodgine.loadFromFile(value);
        }

        data.forEach(function (value) {
            expect(load.bind(null, value)).to.throw();
        });
    });

    describe('Loading the testnodgine.json should result in a working server', function () {
        global.$APPLICATION = undefined;
        global.$LOGGER = undefined;
        global.$ROUTER = undefined;
        global.$SERVICE = undefined;

        after(function () {
            nodgine.stopHTTP();
            nodgine.stopHTTPS();
        });

        it('should not throw an error loading the file', function () {
            function load() {
                nodgine.loadFromFile(mPath.resolve(__dirname, './loadfromfile/testnodgine.json'));
            }

            expect(load).not.to.throw();
        });

        it('should have globalized all main objects, because the option was on true', function () {
{'fraction_non_alphanumeric': 0.1553486952540821, 'fraction_numerical': 0.0018312223409125592, 'mean_word_length': 2.5085653104925054, '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': '1436846', 'n_tokens_mistral': 1917, 'n_tokens_neox': 1882, 'n_words': 390}