
'use strict';
// var React;
var classNameGenerator = require('../src/ClassNameGenerator');
var expect = require("chai").expect;
// var ReactTestUtils;

describe('ClassNameGenerator', function() {
    var ClassNameConfig = {
        name: 'test-container',
        elements: [
            {
                name: 'element1',
                modifiers: {
                    hidden: true,
                    test: 'secondVal',
                },
            },
            {
                name: 'element2',
                modifiers: {
                    red: true,
                    secondMod: 2,
                },
            },
        ],
        modifiers: {
            hidden: true,
        },
    };
    it('ClassNameGenerator is an instance of Object', function() {
        expect(classNameGenerator.constructor.name).to.eql('Function');
    });

    it('ClassNameGenerator should return an Object', function() {
        expect(typeof classNameGenerator(ClassNameConfig)).to.eql('object');
    });

    it('ClassNameGenerator should create correct number of children elements', function() {
        var cssClassNameBlock = classNameGenerator(ClassNameConfig);
        expect(Object.getOwnPropertyNames(cssClassNameBlock).length).to.eql(2);
    });

    it('ClassNameGenerator should return correct block class with modifiers', function() {
        var classNameBlock = classNameGenerator(ClassNameConfig);
        expect(classNameBlock.name).to.eql('test-container hidden');
    });

    it('ClassNameGenerator returned block class should support toString() for getting name value', function() {
        var classNameBlock = classNameGenerator(ClassNameConfig);
        expect(classNameBlock.toString()).to.eql('test-container hidden');
    });

    it('ClassNameGenerator should return correct block elements classes with modifiers', function() {
        var classNameBlock = classNameGenerator(ClassNameConfig);
        expect(classNameBlock.element1.name).to.eql('element1 hidden test-secondVal');
    });


    it('ClassNameGenerator should be able to support BEM blocks naming for elements with modifiers', function() {
        var customClassNameGenerator = new classNameGenerator.Class({
            bemEnabled: true,
        });
        var bemBlock = customClassNameGenerator(ClassNameConfig);
        expect(bemBlock.element1.name).to.eql('test-container__element1 test-container__element1--hidden test-container__element1--test-secondVal');
    });
    it('ClassNameGenerator shoudl allow object dot notation', function() {
      var dotNotationConfig = {
        name: 'test-container',
        elements: [
            {
                name: 'my-element-one',
                elements: [{
                  name:'child-one'},
                {
                  name: 'child-two'},]
            },
            {
                name: 'my-element-two',
                alias: 'my-element-two-alias',
                elements: [{
                  name: 'child-one'},
                { name: 'child-two'},
                ]
            },
        ],
      };

        var classNameBlock = classNameGenerator(dotNotationConfig);
        expect(classNameBlock.element1.name).to.eql('element1 hidden test-secondVal');
    });


});

@@ -2502,10 +2502,10 @@
 shou
-d
 l
+d
  all
@@ -2526,16 +2526,47 @@
 notation
+ of elements and child elements
 ', funct
@@ -3108,19 +3108,16 @@
      %7D;%0A
-%0A  
       va
@@ -3172,34 +3172,32 @@
 nConfig);%0A      
-  
 expect(className
@@ -3206,62 +3206,107 @@
 ock.
-e
+myE
 lement
-1.name).to.eql('element1 hidden test-secondVal'
+One.childOne).to%0A        .eql(classNameBlock.elements%5B'myElementOne'%5D.elements%5B'childOne'%5D
 );%0A 

test updated