import DefinitionBehaviour from '../';
import {definition} from 'focus-core';
const DOMAIN = {
	DO_TEXT: {
		style: "do_text",
		type: "text",
		component: "PapaSinge",
		validation: [{
			type: "function",
			value: function() {
				return false;
			}
		}]
	},
	DO_EMAIL: {
		style: "do_email",
		type: "email",
		component: "PapaMail",
		validation: [{
			type: "function",
			value: function() {
				return true;
			}
		}]
	},
	DO_NUMBER:{
		type: 'number'
	}
};

const entityMock = {
  contact: {
    firstName: {
      domain: "DO_TEXT",
      required: false
    },
    lastName: {
      domain: "DO_TEXT",
      required: true
    },
    age: {
      "domain": "DO_NUMBER",
      "required": false
    },
    email: {
      domain: "DO_EMAIL",
      required: false
    }
  }
};

// initialize the entity conf.
definition.domain.container.setAll(DOMAIN);
definition.entity.container.setEntityConfiguration(entityMock);

describe('The definition behaviour', () => {

    describe('when called with a wrong definition path', () => {
        it('shoud throw an error when the param is undefined',  () => {
            expect(() => DefinitionBehaviour()).to.throw(Error);
        });
        it('shoud throw an error when when the param is null',  () => {
            expect(() => DefinitionBehaviour(null)).to.throw(Error);
        });
        it('shoud throw an error when the param is an object',  () => {
            expect(() => DefinitionBehaviour({})).to.throw(Error);
        });
        it('shoud throw a number when the param is an object',  () => {
            expect(() => DefinitionBehaviour(1)).to.throw(Error);
        });
        it('shoud not throw an error when the param is a string and not the definition map',  () => {
            expect(() => DefinitionBehaviour('test')).to.throw(Error);
        });
        it('shoud not throw an error when the param is a string and in the definition map',  () => {
            expect(() => DefinitionBehaviour('contact')).to.not.throw(Error);
        });
	  });
	  describe('when called with a correct definition path', () => {
        it('should add a defintion property', () => {
		    class TestComponent extends React.Component {
                render() {
					return (
                        <div ref='myRef'>
                            {JSON.stringify(this.props)}
                        </div>
                    );
                }
            }
			const CompWithDef = DefinitionBehaviour('contact')(TestComponent);
            const renderedComponent = TestUtils.renderIntoDocument(<CompWithDef test='hello'/>);
			expect(renderedComponent.refs.wrappedComponent.props).to.have.property('definition');
        });
		it('should contains all the property given as definition', () => {
		    class TestComponent extends React.Component {
                render() {
					return (
                        <div ref='myRef'>
                            {JSON.stringify(this.props)}
                        </div>
                    );
                }
            }
			const CompWithDef = DefinitionBehaviour('contact')(TestComponent);
            const renderedComponent = TestUtils.renderIntoDocument(<CompWithDef test='hello'/>);
			expect(renderedComponent.refs.wrappedComponent.props.definition)
				  .to.have.property('firstName');
				// console.log('firstName %j', renderedComponent.refs.wrappedComponent.props.definition.firstName)
        });
        /*before(() => {
            @DefinitionBehaviour('contact')
            class TestComponent extends React.Component {
                render() {
                    return (
                        <div ref='myRef'>
                        {this.props.test}
                        </div>
                    );
                }
            }
            TestUtils.renderIntoDocument(<TestComponent test='hello'/>);
        });
        it('should not bind mdl JS', () => {
            expect(mdlSpy.upgradeElement).not.to.be.called;
        });*/
    });


});

@@ -3422,565 +3422,8 @@
 %7D);%0A
-        /*before(() =%3E %7B%0A            @DefinitionBehaviour('contact')%0A            class TestComponent extends React.Component %7B%0A                render() %7B%0A                    return (%0A                        %3Cdiv ref='myRef'%3E%0A                        %7Bthis.props.test%7D%0A                        %3C/div%3E%0A                    );%0A                %7D%0A            %7D%0A            TestUtils.renderIntoDocument(%3CTestComponent test='hello'/%3E);%0A        %7D);%0A        it('should not bind mdl JS', () =%3E %7B%0A            expect(mdlSpy.upgradeElement).not.to.be.called;%0A        %7D);*/%0A
     

Clean tests comments.