'use strict';

var RedisCommands = require('../js/service/redis-commands'),
    should         = require('should');

describe('RedisCommands', function () {

    // TODO: fix RedisCommands to fit these tests
    describe('To tree', function () {

        var redisCommands = new RedisCommands();

        it('Should convert basic keys to a tree', function () {
            var keys = [
                'abc:xyz',
                'abc:ijk',
                'lmn:opq'
            ];

            var tree = redisCommands.toTree(keys);

            tree.should.have.ownProperty('isLeaf');
            tree.should.have.ownProperty('children');

            tree.children.should.have.ownProperty('abc');
            tree.children.should.have.ownProperty('lmn');
            tree.isLeaf.should.not.be.ok;
        });

        it('Should mark some nodes as leaves', function () {
            var keys = [
                'abc',
                'abc:xyz',
                'abc:ijk',
                'abc:ijk:lmn',
                'lmn:opq'
            ];

            var tree = redisCommands.toTree(keys);

            tree.isLeaf.should.not.be.ok;
            tree.children.abc.isLeaf.should.be.ok;
            tree.children.abc.children.xyz.isLeaf.should.be.ok;
            tree.children.abc.children.ijk.isLeaf.should.be.ok;
            tree.children.abc.children.ijk.children.lmn.isLeaf.should.be.ok;
            tree.children.lmn.isLeaf.should.not.be.ok;
            tree.children.lmn.children.opq.isLeaf.should.be.ok;
        });

    });

});
@@ -569,22 +569,19 @@
 operty('
-isLeaf
+abc
 ');%0A    
@@ -618,23 +618,18 @@
 operty('
-childre
+lm
 n');%0A%0A  
@@ -639,32 +639,27 @@
        tree.
-children
+abc
 .should.have
@@ -664,35 +664,38 @@
 ve.ownProperty('
-abc
+isLeaf
 ');%0A            
@@ -699,24 +699,19 @@
    tree.
-children
+abc
 .should.
@@ -728,23 +728,29 @@
 operty('
-lm
+childre
 n');%0A
+%0A
         
@@ -750,32 +750,36 @@
            tree.
+abc.
 isLeaf.should.no
@@ -1109,59 +1109,8 @@
 ree.
-isLeaf.should.not.be.ok;%0A            tree.children.
 abc.
@@ -1143,33 +1143,24 @@
        tree.
-children.
 abc.children
@@ -1198,33 +1198,24 @@
        tree.
-children.
 abc.children
@@ -1257,25 +1257,16 @@
    tree.
-children.
 abc.chil
@@ -1321,33 +1321,24 @@
        tree.
-children.
 lmn.isLeaf.s
@@ -1371,25 +1371,16 @@
    tree.
-children.
 lmn.chil

Update redis commands toTree tests