import { expect } from 'chai';
import MetaLoader from '../meta-loader';

describe('plugin', () => {
  const source = `
    import React, { PropTypes } from 'react';

    const Button = ({ className = 'btn' }) => ((
      <button className={className}>
        Follow
      </button>
    ));

    Button.propTypes = {
      /* HTML native button types */
      className: PropTypes.string,
    };

    export default Button;
  `;

  it('should extract the PropTypes information', () => {
    const compiler = {
      cacheable: () => null, // TODO add sinon spy once I got internet again
      MetaLoader,
    };
    const expected = 'module.exports = {"description":"","props":{"className":{"type":{"name":"string"},"required":false,"description":""}}}';
    expect(compiler.MetaLoader(source)).to.deep.equal(expected);
  });
});

@@ -93,16 +93,253 @@
 () =%3E %7B%0A
+  let compiler;%0A%0A  beforeEach(() =%3E %7B%0A    compiler = %7B%0A      cacheable: () =%3E null, // TODO add sinon spy once I got internet again%0A      MetaLoader,%0A    %7D;%0A  %7D);%0A%0A  it('should extract the description & PropTypes information', () =%3E %7B%0A  
   const 
@@ -349,16 +349,18 @@
 rce = %60%0A
+  
     impo
@@ -398,24 +398,26 @@
 eact';%0A%0A    
+  
 const Button
@@ -449,16 +449,18 @@
 ) =%3E ((%0A
+  
       %3Cb
@@ -496,16 +496,18 @@
         
+  
 Follow%0A 
@@ -511,16 +511,18 @@
 w%0A      
+  
 %3C/button
@@ -531,13 +531,17 @@
     
+  
 ));%0A%0A
+  
     
@@ -567,16 +567,18 @@
 %7B%0A      
+  
 /* HTML 
@@ -606,16 +606,18 @@
 /%0A      
+  
 classNam
@@ -645,12 +645,16 @@
     
+  
 %7D;%0A%0A
+  
     
@@ -680,60 +680,304 @@
 on;%0A
+  
   %60;%0A
-%0A  it('should extract the PropTypes information
+    const expected = 'module.exports = %7B%22description%22:%22%22,%22props%22:%7B%22className%22:%7B%22type%22:%7B%22name%22:%22string%22%7D,%22required%22:false,%22description%22:%22%22%7D%7D%7D';%0A    expect(compiler.MetaLoader(source)).to.deep.equal(expected);%0A  %7D);%0A%0A  it('should extract the description in case no flow/propTypes are defined
 ', (
@@ -997,262 +997,327 @@
 nst 
-compiler = %7B
+source = %60
 %0A      
-cacheable: () =%3E null, // TODO add sinon spy once I got internet again%0A      MetaLoader,%0A    %7D;%0A    const expected = 'module.exports = %7B%22description%22:%22%22,%22props%22:%7B%22className%22:%7B%22type%22:%7B%22name%22:%22string%22%7D,%22required%22:false,%22description%22:%22%22%7D%7D
+import React, %7B PropTypes %7D from 'react';%0A%0A      /**%0A       * Button component%0A       */%0A      export default(%7B className = 'btn' %7D) =%3E ((%0A        %3Cbutton className=%7BclassName%7D%3E%0A          Follow%0A        %3C/button%3E%0A      ));%0A    %60;%0A    const expected = 'module.exports = %7B%22description%22:%22Button component%22
 %7D';%0A

improve metaLoader tests