<commit_before>describe("client/src/manager/Manager", () => {
    const Config       = require('./../../../client/src/share/Config').Config;
    const SConfig      = require('./../../../server/src/share/Config').Config;
    const OLD_MODE     = Config.modeNodeJs;
    Config.modeNodeJs  = true;
    const Server       = require('./../../../server/src/server/Server').Server;
    const EVENTS       = require('./../../../client/src/share/Events').EVENTS;
    const SEVENTS      = require('./../../../server/src/server/Server').EVENTS;
    const Console      = require('./../../../client/src/share/Console');
    const SConsole     = require('./../../../server/src/share/Console');
    const THelper      = require('./../../../common/tests/Helper');
    const World        = require('./../../../client/src/view/World').World;
    const Manager      = require('./Manager');
    const emptyFn      = () => {};
    const waitEvent    = THelper.waitEvent;
    const wait         = THelper.wait;

    let error;
    let warn;
    let info;
    let serror;
    let swarn;
    let sinfo;
    let timeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;


    beforeEach(() => delete Config.Ips);
    beforeAll(() => {
        jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
        Config.plugIncluded.splice(Config.plugIncluded.indexOf('ips/Ips'));
        error = Console.error;
        warn  = Console.warn;
        info  = Console.info;
        Console.error = emptyFn;
        Console.warn  = emptyFn;
        Console.info  = emptyFn;

        serror = SConsole.error;
        swarn  = SConsole.warn;
        sinfo  = SConsole.info;
        SConsole.error = emptyFn;
        SConsole.warn  = emptyFn;
        SConsole.info  = emptyFn;
    });
    afterAll(()  => {
        SConsole.error = serror;
        SConsole.warn  = swarn;
        SConsole.info  = sinfo;

        Console.error = error;
        Console.warn  = warn;
        Console.info  = info;
        Config.modeNodeJs = OLD_MODE;
        Config.plugIncluded.push('ips/Ips');
        jasmine.DEFAULT_TIMEOUT_INTERVAL = timeout;
    });

    it("Checking manager creation", (done) => {
        const man = new Manager(false);
        expect(man.canvas).toBe(null);
        man.destroy(done);
    });
    it("Checking manager creation and it's properties", (done) => {
        const man = new Manager(false);
        expect(man.organisms.size).toBe(0);
        expect(Object.keys(man.positions).length).toBe(0);
        expect(man.codeRuns).toBe(0);
        expect(!!man.api.version).toBe(true);
        expect(man.api.visualize).toBe(undefined);
        expect(man.active).toBe(false);
        expect(man.clientId).toBe(null);
        expect(man.isDistributed()).toBe(false);
        expect(man.hasView).toBe(false);
        man.destroy(done);
    });
    it("Checking creation of two managers", (done) => {
        const man1 = new Manager(false);
        const man2 = new Manager(false);

        waitEvent(man1, EVENTS.DESTROY, () => man1.destroy(), () => {
            waitEvent(man2, EVENTS.DESTROY, () => man2.destroy(), done);
        });
    });
    it("Checking creation huge amount of managers", (done) => {
        const mans      = [];
        const amount    = 100;
        let   destroyed = 0;
        let   waitObj   = {done: false};

        for (let i = 0; i < amount; i++) {mans.push(new Manager(false))}
        for (let i = 0; i < amount; i++) {mans[i].destroy(() => ++destroyed === amount && (waitObj.done = true))}

        if (waitObj.done) {done(); return}
        wait(waitObj, () => done, 30000);
    });

    it("Checking running manager", (done) => {
        const man = new Manager(false);
        man.run(() => man.on(EVENTS.ITERATION, () => man.destroy(done)));
    });

    it("Checking RUN event", (done) => {
        const man = new Manager(false);
        waitEvent(man, EVENTS.RUN, () => man.run(), () => man.destroy(done));
    });
    it("Checking STOP event", (done) => {<commit_msg>one more test for Manager class #40<commit_after>describe("client/src/manager/Manager", () => {
    const Config       = require('./../../../client/src/share/Config').Config;
    const SConfig      = require('./../../../server/src/share/Config').Config;
    const OLD_MODE     = Config.modeNodeJs;
    Config.modeNodeJs  = true;
    const Server       = require('./../../../server/src/server/Server').Server;
    const EVENTS       = require('./../../../client/src/share/Events').EVENTS;
    const SEVENTS      = require('./../../../server/src/server/Server').EVENTS;
    const Console      = require('./../../../client/src/share/Console');
    const SConsole     = require('./../../../server/src/share/Console');
    const THelper      = require('./../../../common/tests/Helper');
    const World        = require('./../../../client/src/view/World').World;
    const Manager      = require('./Manager');
    const emptyFn      = () => {};
    const waitEvent    = THelper.waitEvent;
    const wait         = THelper.wait;

    let error;
    let warn;
    let info;
    let serror;
    let swarn;
    let sinfo;
    let timeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;


    beforeEach(() => delete Config.Ips);
    beforeAll(() => {
        jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
        Config.plugIncluded.splice(Config.plugIncluded.indexOf('ips/Ips'));
        error = Console.error;
        warn  = Console.warn;
        info  = Console.info;
        Console.error = emptyFn;
        Console.warn  = emptyFn;
        Console.info  = emptyFn;

        serror = SConsole.error;
        swarn  = SConsole.warn;
        sinfo  = SConsole.info;
        SConsole.error = emptyFn;
        SConsole.warn  = emptyFn;
        SConsole.info  = emptyFn;
    });
    afterAll(()  => {
        SConsole.error = serror;
        SConsole.warn  = swarn;
        SConsole.info  = sinfo;

        Console.error = error;
        Console.warn  = warn;
        Console.info  = info;
        Config.modeNodeJs = OLD_MODE;
        Config.plugIncluded.push('ips/Ips');
        jasmine.DEFAULT_TIMEOUT_INTERVAL = timeout;
    });

    it("Checking manager creation", (done) => {
        const man = new Manager(false);
        expect(man.canvas).toBe(null);
        man.destroy(done);
    });
    it("Checking manager creation and it's properties", (done) => {
        const man = new Manager(false);
        expect(man.organisms.size).toBe(0);
        expect(Object.keys(man.positions).length).toBe(0);
        expect(man.codeRuns).toBe(0);
        expect(!!man.api.version).toBe(true);
        expect(man.api.visualize).toBe(undefined);
        expect(man.active).toBe(false);
        expect(man.clientId).toBe(null);
        expect(man.isDistributed()).toBe(false);
        expect(man.hasView).toBe(false);
        man.destroy(done);
    });
    it("Checking creation of two managers", (done) => {
        const man1 = new Manager(false);
        const man2 = new Manager(false);

        waitEvent(man1, EVENTS.DESTROY, () => man1.destroy(), () => {
            waitEvent(man2, EVENTS.DESTROY, () => man2.destroy(), done);
        });
    });
    it("Checking creation huge amount of managers", (done) => {
        const mans      = [];
        const amount    = 100;
        let   destroyed = 0;
        let   waitObj   = {done: false};

        for (let i = 0; i < amount; i++) {mans.push(new Manager(false))}
        for (let i = 0; i < amount; i++) {mans[i].destroy(() => ++destroyed === amount && (waitObj.done = true))}

        if (waitObj.done) {done(); return}
        wait(waitObj, () => done, 30000);
    });

    it("Checking running manager", (done) => {
        const man = new Manager(false);
        man.run(() => man.on(EVENTS.ITERATION, () => man.destroy(done)));
    });
    it("Checking if manager runs main loop", (done) => {
        const man   = new Manager(false);
        let   count = 0;
        man.run(() => man.on(EVENTS.ITERATION, () => {
            ++count === 100 && man.destroy(done);
        }));
    });

    it("Checking RUN event", (done) => {
        const man = new Manager(false);
        waitEvent(man, EVENTS.RUN, () => man.run(), () => man.destroy(done));
    });
    it("Checking STOP event", (done) => {
{'fraction_non_alphanumeric': 0.17472527472527472, 'fraction_numerical': 0.006837606837606838, 'mean_word_length': 2.1263358778625956, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 48, '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': '6698174', 'n_tokens_mistral': 2534, 'n_tokens_neox': 2462, 'n_words': 493}