require(
    [
        'jquery',
        'Portlet/Manager',
        'Portlet/Portlet'
    ],
    function ($, PortletManager, Portlet) {
        'use strict';

        var Portlets  = null;

        describe('Portlet Manager', function () {

            beforeEach(function (done) {
                reloadFixtures(function () {
                    Portlets = new PortletManager($('#fixtures'));
                    Portlets.initialize();
                    done();
                });
            });


            describe('#get', function () {
                it('should throw an error if a portlet does not exist', function () {
                    expect(function () {
                        Portlets.get('foobarfoo');
                    }).to.throw(/Portlet "foobarfoo" not found!/);
                });

                it('should get a Portlet', function () {
                    var name    = 'SignInForm',
                        portlet = Portlets.get(name);

                    expect(portlet.getElement()).to.have.length(1);
                    expect(portlet.getConfig('name')).to.eql(name);
                });
            });

            describe('#add', function () {
                it('should not instance a portlet that already exist', function () {
                    var portlet = new Portlet($('#SuccessNotification'));

                    expect(function () {
                        Portlets.add(portlet);
                    }).to.throw(/already exists/);
                });

                it('should not instance instance a portlet that already exist', function (done) {
                    $('#fixtures').load('/test/fixtures/portlet-error.html', function () {

                        var name         = 'ErrorNotification',
                            $error       = $('#' + name),
                            portlet      = new Portlet($error),
                            errorPortlet = null;

                        Portlets.add(portlet);

                        errorPortlet = Portlets.get(name);

                        expect(errorPortlet).to.have.property('$element');
                        expect($error).to.eql(errorPortlet.getElement());
                        expect(errorPortlet.getElement()).to.have.length(1);
                        expect(errorPortlet.getConfig('name')).to.eql(name);

                        done();
                    });
                });
            });

        });
    }
);

@@ -1113,32 +1113,338 @@
              %7D);
+%0A%0A                it('should get portlet List if the param %22name%22 is empty', function () %7B%0A                    var portlet = Portlets.get();%0A%0A                    expect(portlet).to.have.property('SuccessNotification');%0A                    expect(portlet).to.have.property('SignInForm');%0A                %7D);
 %0A            %7D);
@@ -1769,16 +1769,55 @@
 .throw(/
+A Portlet called %22SuccessNotification%22 
 already 
@@ -1822,16 +1822,17 @@
 y exists
+!
 /);%0A    
@@ -2029,33 +2029,32 @@
 , function () %7B%0A
-%0A
                 
@@ -2428,37 +2428,39 @@
 tlet
-).to.have.property('$element'
+.getElement()).to.have.length(1
 );%0A 
@@ -2555,32 +2555,54 @@
          expect(
+$error.html()).to.eql(
 errorPortlet.get
@@ -2610,34 +2610,23 @@
 lement()
-).to.have.length(1
+.html()
 );%0A     

improve portlet manager tests