var expect = require('chai').expect;
var Config = require('../lib/Config');
var Controller = require('./RC');
var HazelcastClient = require('../lib/HazelcastClient');
var Q = require('q');
describe('HazelcastClient', function() {
    this.timeout(4000);
    var cluster;
    var client;

    before(function() {
        return Controller.createCluster(null, null).then(function(res) {
            cluster = res;
            return Controller.startMember(cluster.id);
        }).then(function (member) {
            return HazelcastClient.newHazelcastClient();
        }).then(function(res) {
            client = res;
        });
    });

    after(function() {
        client.shutdown();
        return Controller.shutdownCluster(cluster.id);
    });

    it('getDistributedObject returns empty array when there is no distributed object', function() {
        return client.getDistributedObjects().then(function(distributedObjects) {
            return Q.all([
                expect(distributedObjects).to.be.an('array'),
                expect(distributedObjects).to.be.empty
            ]);
        });
    });

    it('getLocalEndpoint returns correct info', function() {
        var info = client.getLocalEndpoint();
        expect(info.localAddress.host).to.equal(client.clusterService.getOwnerConnection().socket.localAddress);
        expect(info.localAddress.port).to.equal(client.clusterService.getOwnerConnection().socket.localPort);
        expect(info.uuid).to.equal(client.clusterService.uuid);
        expect(info.type).to.equal('NodeJS');
    });

    describe('create many maps', function() {
        before(function(done) {
            var map0 = client.getMap('map0');
            var map1 = client.getMap('map1');
            var map2 = client.getMap('map2');
            var map3 = client.getMap('map3');
            var map4 = client.getMap('map4');

            done();
        });

        it('getDistributedObjects returns an array of distributed objects', function() {
            this.timeout(100000);
            var equalChecker = function(expected, actual) {
                return expect(actual).to.eq(expected);
            };
            return client.getDistributedObjects().then(function(distributedObjects) {
                var objects = {};
                distributedObjects.forEach(function(distObject) {
                    objects[distObject.getName()] = 'exist';
                });
                return Q.all([
                    expect(objects).to.have.property('map0'),
                    expect(objects).to.have.property('map1'),
                    expect(objects).to.have.property('map2'),
                    expect(objects).to.have.property('map3'),
                    expect(objects).to.have.property('map4')
                ]);
            });
        });
    });
});

@@ -1977,32 +1977,36 @@
 ects', function(
+done
 ) %7B%0A            
@@ -2009,160 +2009,36 @@
     
-this.t
+setT
 imeout(
-100000);%0A            var equalChecker = function(expected, actual) %7B%0A                return expect(actual).to.eq(expected);%0A            %7D;%0A
+function() %7B%0A    
     
@@ -2131,24 +2131,28 @@
             
+    
 var objects 
@@ -2173,16 +2173,20 @@
         
+   
+ 
 distribu
@@ -2223,24 +2223,28 @@
 stObject) %7B%0A
+    
             
@@ -2312,42 +2312,15 @@
     
-%7D);%0A                return Q.all(%5B
+    %7D);
 %0A   
@@ -2376,17 +2376,17 @@
 ('map0')
-,
+;
 %0A       
@@ -2438,17 +2438,17 @@
 ('map1')
-,
+;
 %0A       
@@ -2500,17 +2500,17 @@
 ('map2')
-,
+;
 %0A       
@@ -2562,17 +2562,17 @@
 ('map3')
-,
+;
 %0A       
@@ -2624,17 +2624,19 @@
 ('map4')
-%0A
+;%0A 
         
@@ -2635,33 +2635,60 @@
                 
-%5D
+   done();%0A                %7D
 );%0A            %7D
@@ -2679,32 +2679,37 @@
 );%0A            %7D
+, 500
 );%0A        %7D);%0A 

fix premature check in getDistributedObjects test