var assert = require('assert'),
  should = require('should'),
  Momentr = require('../../src/index');

describe('Unit', function() {
  describe('Main', function() {
    describe("Constructor", function() {
      it('standard success', function(done) {
        // arrange/act
        var instance = new Momentr();

        // assert
        should.exist(instance);

        return done();
      });
    });

    describe("Register", function() {
      it('standard success', function(done) {
        // arrange
        var instance = new Momentr();
        var classDef = class {

        };
        var key = "component";

        // act
        instance.register(key, classDef, "application");

        // assert
        should.exist(instance);
        instance.get(key).should.be.instanceof(classDef);

        return done();
      });
    });

    describe("Get", function() {
      it('standard success', function(done) {
        // arrange
        var instance = new Momentr();
        var classDef = class {

        };
        var key = "component";
        instance.register(key, classDef, "application");

        // act
        var retrievedInstance = instance.get(key);

        // assert
        should.exist(instance);
        retrievedInstance.should.be.instanceof(classDef);

        return done();
      });

      it('constructor arguments', function(done) {
        // arrange
        var instance = new Momentr();
        var arg1Value = 25,
          arg2Value = "yo",
          arg3Value = "man";
        var classDef = class {
          constructor(arg1, arg2, arg3) {
            this._arg1 = arg1;
            this._arg2 = arg2;
            this._arg3 = arg3;
          }

          get arg1() {
            return this._arg1;
          }
          get arg2() {
            return this._arg2;
          }
          get arg3() {
            return this._arg3;
          }
        };
        var key = "component";
        instance.register(key, classDef, "application");

        // act
        var retrievedInstance = instance.get(key,
          arg1Value, arg2Value, arg3Value);

        // assert
        retrievedInstance.arg1.should.equal(arg1Value);
        retrievedInstance.arg2.should.equal(arg2Value);
        retrievedInstance.arg3.should.equal(arg3Value);

        return done();
      });

    });

  });
});
