<commit_before>"use strict";

let chai = require("chai"),
    expect = chai.expect,
    radis = require("../index.js"),
    Module = require("../src/Module.js"),
    Injector = require("../src/Injector.js");

chai.should();

describe("Core", function () {
    describe("#module()", function () {

        it("should return the module", function () {
            let module = radis.module("module", []);
            module.should.be.an.instanceof(Module);
            module.getName().should.be.equal("module");
        });
    });
});

describe("Module", function () {
    describe("#bootstrap()", function () {
        this.timeout(1000);
        it("should be called", function () {
            let module = radis.module("module", []);
            module.bootstrap();
        });
    });


    describe("#service()", function () {
        this.timeout(1000);
        it("should be injected", function () {

            class Service1 {
            }
            class Service2 {
            }
            class Service3 {
            }

            let module = radis.module("module", [])
                .service("s1", Service1)
                .service("s2", Service2)
                .service("s3", Service3)
                .run(function (s1, s2, s3) {
                    s1.should.be.an.instanceof(Service1);
                    s2.should.be.an.instanceof(Service2);
                    s3.should.be.an.instanceof(Service3);
                });
            module.bootstrap();
        });
    });

    describe("#factory()", function () {
        this.timeout(1000);
        it("should be injected", function () {
            let module = radis.module("module", []);

            class Service1 {
            }
            class Service2 {
            }
            class Service3 {
            }

            module.factory("service1", () => new Service1());
            module.factory("service2", () => new Service2());
            module.factory("service3", () => new Service3());
            module.run(function (service1, service2, service3) {
                service1.should.be.an.instanceof(Service1);
                service2.should.be.an.instanceof(Service2);
                service3.should.be.an.instanceof(Service3);
            });
            module.bootstrap();
        });
    });

    describe("#provider()", function () {
        this.timeout(1000);
        it("should be injected", function () {
            let module = radis.module("module", []);

            function Service1Provider() {
                this.$get = () => "s1";
            }

            function Service2Provider() {
                this.$get = () => "s2";
            }

            function Service3Provider() {
                this.$get = () => "s3";
            }

            module.provider("service1", Service1Provider);
            module.provider("service2", Service2Provider);
            module.provider("service3", Service3Provider);
            module.run(function (service1, service2, service3) {
                service1.should.be.equal("s1");
                service2.should.be.equal("s2");
                service3.should.be.equal("s3");
            });
            module.bootstrap();
        });
    });

    describe("#config()", function () {

        it("should call config with the provider", function () {
            let module = radis.module("module", []);

            class Service1Provider {
                setString(string) {
                    this.string = string;
                }

                $get() {
                    return this.string;
                }
            }

            module.provider("service1", Service1Provider);

            module.config(function (service1Provider) {
                service1Provider.setString("value");
            });

            module.run(function (service1) {
                service1.should.be.equal("value");
            });

            module.bootstrap();
        });
    });
});

describe("Injector", function () {

    it("the injector should be injected at runtine", function () {
        radis.module("module", [])
            .run(($injector) => {
                $injector.should.be.an.instanceof(Injector);
            })
            .bootstrap();

    });

    it("the injector should be injected at config time", function () {
        radis.module("module", [])
            .config(($injector) => {
                $injector.should.be.an.instanceof(Injector);
            })
            .bootstrap();

    });


    it("The injector should work with multiline declaration function", function () {
        radis.module("module", [])
            .factory("s1", () => "s1")
            .factory("s2", () => "s2")
            .factory("s3", () => "s3")
            .run((s1,
                  s2,
                  s3) => {
                s1.should.be.equal("s1");
                s2.should.be.equal("s2");
                s3.should.be.equal("s3");
            })
            .bootstrap();
    });

    describe("getService", function () {

        let module;

        beforeEach(function () {
            module = radis.module("module", [])
                .factory("s1", () => "s1")
                .factory("s2", () => "s2");
        });

        it("Should return the right service", function () {
            module.run(($injector) => {
                $injector.getService("s1").should.be.equal("s1");
                $injector.getService("s2").should.be.equal("s2");
            })
                .bootstrap();
        });

        it("Should throw if service does not exist", function () {
            module.run(($injector) => {
                expect(() => $injector.getService("s3")).to.throw(Error);
            })
                .bootstrap();
        });
    });

    describe("lift", function () {
        let module;
        let $injector;

        beforeEach(function () {
            module = radis.module("module", [])
                .factory("s1", () => "s1")
                .factory("s2", () => "s2")
                .run(['$injector', (s) => $injector = s])
                .bootstrap();<commit_msg>Fix lint error<commit_after>"use strict";

let chai = require("chai"),
    expect = chai.expect,
    radis = require("../index.js"),
    Module = require("../src/Module.js"),
    Injector = require("../src/Injector.js");

chai.should();

describe("Core", function () {
    describe("#module()", function () {

        it("should return the module", function () {
            let module = radis.module("module", []);
            module.should.be.an.instanceof(Module);
            module.getName().should.be.equal("module");
        });
    });
});

describe("Module", function () {
    describe("#bootstrap()", function () {
        this.timeout(1000);
        it("should be called", function () {
            let module = radis.module("module", []);
            module.bootstrap();
        });
    });


    describe("#service()", function () {
        this.timeout(1000);
        it("should be injected", function () {

            class Service1 {
            }
            class Service2 {
            }
            class Service3 {
            }

            let module = radis.module("module", [])
                .service("s1", Service1)
                .service("s2", Service2)
                .service("s3", Service3)
                .run(function (s1, s2, s3) {
                    s1.should.be.an.instanceof(Service1);
                    s2.should.be.an.instanceof(Service2);
                    s3.should.be.an.instanceof(Service3);
                });
            module.bootstrap();
        });
    });

    describe("#factory()", function () {
        this.timeout(1000);
        it("should be injected", function () {
            let module = radis.module("module", []);

            class Service1 {
            }
            class Service2 {
            }
            class Service3 {
            }

            module.factory("service1", () => new Service1());
            module.factory("service2", () => new Service2());
            module.factory("service3", () => new Service3());
            module.run(function (service1, service2, service3) {
                service1.should.be.an.instanceof(Service1);
                service2.should.be.an.instanceof(Service2);
                service3.should.be.an.instanceof(Service3);
            });
            module.bootstrap();
        });
    });

    describe("#provider()", function () {
        this.timeout(1000);
        it("should be injected", function () {
            let module = radis.module("module", []);

            function Service1Provider() {
                this.$get = () => "s1";
            }

            function Service2Provider() {
                this.$get = () => "s2";
            }

            function Service3Provider() {
                this.$get = () => "s3";
            }

            module.provider("service1", Service1Provider);
            module.provider("service2", Service2Provider);
            module.provider("service3", Service3Provider);
            module.run(function (service1, service2, service3) {
                service1.should.be.equal("s1");
                service2.should.be.equal("s2");
                service3.should.be.equal("s3");
            });
            module.bootstrap();
        });
    });

    describe("#config()", function () {

        it("should call config with the provider", function () {
            let module = radis.module("module", []);

            class Service1Provider {
                setString(string) {
                    this.string = string;
                }

                $get() {
                    return this.string;
                }
            }

            module.provider("service1", Service1Provider);

            module.config(function (service1Provider) {
                service1Provider.setString("value");
            });

            module.run(function (service1) {
                service1.should.be.equal("value");
            });

            module.bootstrap();
        });
    });
});

describe("Injector", function () {

    it("the injector should be injected at runtine", function () {
        radis.module("module", [])
            .run(($injector) => {
                $injector.should.be.an.instanceof(Injector);
            })
            .bootstrap();

    });

    it("the injector should be injected at config time", function () {
        radis.module("module", [])
            .config(($injector) => {
                $injector.should.be.an.instanceof(Injector);
            })
            .bootstrap();

    });


    it("The injector should work with multiline declaration function", function () {
        radis.module("module", [])
            .factory("s1", () => "s1")
            .factory("s2", () => "s2")
            .factory("s3", () => "s3")
            .run((s1,
                  s2,
                  s3) => {
                s1.should.be.equal("s1");
                s2.should.be.equal("s2");
                s3.should.be.equal("s3");
            })
            .bootstrap();
    });

    describe("getService", function () {

        let module;

        beforeEach(function () {
            module = radis.module("module", [])
                .factory("s1", () => "s1")
                .factory("s2", () => "s2");
        });

        it("Should return the right service", function () {
            module.run(($injector) => {
                $injector.getService("s1").should.be.equal("s1");
                $injector.getService("s2").should.be.equal("s2");
            })
                .bootstrap();
        });

        it("Should throw if service does not exist", function () {
            module.run(($injector) => {
                expect(() => $injector.getService("s3")).to.throw(Error);
            })
                .bootstrap();
        });
    });

    describe("lift", function () {
        let module;
        let $injector;

        beforeEach(function () {
            module = radis.module("module", [])
                .factory("s1", () => "s1")
                .factory("s2", () => "s2")
                .run(["$injector", (s) => $injector = s])
                .bootstrap();
{'fraction_non_alphanumeric': 0.1623785020011435, 'fraction_numerical': 0.017642734623866698, 'mean_word_length': 1.4800486125177232, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 43, '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': '7077256', 'n_tokens_mistral': 3391, 'n_tokens_neox': 3200, 'n_words': 541}