<commit_before>"use strict";

var chai = require("chai");
var expect = chai.expect;

var yaioc = require("../yaioc.js");


describe("yaioc test", function () {

    function TargetFunction(dependencyOne, dependencyTwo) {
        this.args = arguments;
        this.dependencyOne = dependencyOne;
        this.dependencyTwo = dependencyTwo;
    }

    var container;

    beforeEach(function () {
        container = yaioc.container();
    });

    describe("register and resolve", function () {

        it("should instantiate object with dependencies", function () {
            var dependencyOne = {};
            container.register("dependencyOne", dependencyOne);
            var dependencyTwo = {};
            container.register("dependencyTwo", dependencyTwo);

            container.register("TargetFunction", TargetFunction);

            var instance = container.get("TargetFunction");

            expect(instance.args.length).to.be.eql(2);
            expect(instance.dependencyOne).to.be.eql(dependencyOne);
            expect(instance.dependencyTwo).to.be.eql(dependencyTwo);
            expect(instance).to.be.instanceof(TargetFunction);
        });

    });

    describe("get", function () {

        it("should instanciate registered constructor function as dependency", function () {
            function Dependency() {}
            function Target(dependency) { this.dependency = dependency; }
            container.register(Dependency);
            container.register(Target);<commit_msg>added testcase for "throw if dependency cannot be resolved"<commit_after>"use strict";

var chai = require("chai");
var expect = chai.expect;

var yaioc = require("../yaioc.js");


describe("yaioc test", function () {

    function TargetFunction(dependencyOne, dependencyTwo) {
        this.args = arguments;
        this.dependencyOne = dependencyOne;
        this.dependencyTwo = dependencyTwo;
    }

    var container;

    beforeEach(function () {
        container = yaioc.container();
    });

    describe("register and resolve", function () {

        it("should instantiate object with dependencies", function () {
            var dependencyOne = {};
            container.register("dependencyOne", dependencyOne);
            var dependencyTwo = {};
            container.register("dependencyTwo", dependencyTwo);

            container.register("TargetFunction", TargetFunction);

            var instance = container.get("TargetFunction");

            expect(instance.args.length).to.be.eql(2);
            expect(instance.dependencyOne).to.be.eql(dependencyOne);
            expect(instance.dependencyTwo).to.be.eql(dependencyTwo);
            expect(instance).to.be.instanceof(TargetFunction);
        });

        it("should throw if dependency cannot be resolved" /*

         resolveDependencies: function (constructorFunction, name) {
         var dependencies = this.getDependencyNames(constructorFunction);
         return dependencies.map(function (dependencyName) {
         var dependency = this.get(dependencyName);

         if (!dependency) {
         throw new Error("Could not satisfy dependency '" + dependencyName + "' required by '" + name + "'");
         }

         return dependency;
         }, this);
         },

        */);

    });

    describe("get", function () {

        it("should instanciate registered constructor function as dependency", function () {
            function Dependency() {}
            function Target(dependency) { this.dependency = dependency; }
            container.register(Dependency);
            container.register(Target);
{'fraction_non_alphanumeric': 0.11862527716186252, 'fraction_numerical': 0.0005543237250554324, 'mean_word_length': 2.630784708249497, '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': '6458069', 'n_tokens_mistral': 907, 'n_tokens_neox': 845, 'n_words': 190}