import { Meteor } from 'meteor/meteor';
import { describe, it } from 'meteor/practicalmeteor:mocha';
import { expect } from 'meteor/practicalmeteor:chai';
import React from 'react';
import { render } from 'react-dom';
import { MDlReact } from 'meteor/zodiase:mdl-react';

export default (createContainer) => {

  describe("mdl-react/MaterialLayout", () => {

    const { MaterialLayout } = MDlReact;

    it("should render empty without error", () => {
      expect(() => {
        render(React.createElement(MaterialLayout), createContainer());
      }).to.not.throw(Error);
    });

  });

  describe("mdl-react/MaterialLayout.Title", () => {

    const { MaterialLayout } = MDlReact;

    it("should render empty without error", () => {
      expect(() => {
        render(React.createElement(MaterialLayout.Title), createContainer());
      }).to.not.throw(Error);
    });

    it("should render and then find the element", (done) => {
      const elementId = Meteor.uuid();

      render(React.createElement(MaterialLayout.Title, {
        id: elementId
      }), createContainer(), () => {
        const element = document.getElementById(elementId);
        expect(element).to.not.be.null;
        done();
      });
    });

    it("should render empty correctly", (done) => {
      const elementId = Meteor.uuid();

      render(React.createElement(MaterialLayout.Title, {
        id: elementId
      }), createContainer(), () => {
        const element = document.getElementById(elementId);
        expect(element.classList.contains(MaterialLayout.Title.cssName)).to.be.true;
        done();
      });
    });

    it("should render with correct button text", (done) => {
      const elementId = Meteor.uuid(),
            randomButtonText = Meteor.uuid();

      render(React.createElement(MaterialLayout.Title, {
        id: elementId
      }, randomButtonText), createContainer(), () => {
        const element = document.getElementById(elementId);
        expect(element.textContent).to.equal(randomButtonText);
        done();
      });
    });

  });

};
@@ -1651,15 +1651,8 @@
 ect 
-button 
 text
@@ -1658,32 +1658,32 @@
 t%22, (done) =%3E %7B%0A
+
       const elem
@@ -1719,30 +1719,24 @@
       random
-Button
 Text = Meteo
@@ -1836,30 +1836,24 @@
    %7D, random
-Button
 Text), creat
@@ -1926,32 +1926,32 @@
 yId(elementId);%0A
+
         expect(e
@@ -1989,14 +1989,8 @@
 ndom
-Button
 Text

Fix a typo.