'use strict';

const expect = require('chai').expect;

describe('ReactApp AST Parser Tests', function() {
  const modifyTestBundleFile = require('../previewParser.js').modifyTestBundleFile;
  const structureES5Obj = require('../previewParser.js').structureInitialES5StateObj;
  const structureES6Obj = require('../previewParser.js').structureInitialES6StateObj;
  const queryES5Ast = require('../previewParser.js').queryES5Ast;
  const queryES6Ast = require('../previewParser.js').queryES6Ast;
  const previewParserFixtures = require('./fixtures/bundleFileFixture.js');
  

  it('modifyTestBundleFile should be a function', function() {
    expect(modifyTestBundleFile).to.be.a.function;
  });

  it('modifyTestBundleFile should throw error when parser receives empty js code string', function() {
    expect(modifyTestBundleFile.bind(modifyTestBundleFile,'')).to.throw(Error, /Empty AST input/); 
  });

  it('modifyTestBundleFile should return a string', function() {
      expect(modifyTestBundleFile(previewParserFixtures.bundledSetState))
        .to.equal(previewParserFixtures.modifiedBundle);
  });

  it('structureES5Obj should be a function', function() {
    expect(structureES5Obj).to.be.a.function;
  });


  it('structureES6Obj should be a function', function() {
    expect(structureES6Obj).to.be.a.function;
  });

  it('queryES5Ast should be a function', function() {
    expect(queryES5Ast).to.be.a.function;
  });

  it('queryES5Ast should throw error when it receives empty bundle file path', function() {
    expect(queryES5Ast.bind(queryES5Ast, '')).to.throw(Error, /Empty bundle file input/); 
  });


   it('queryES6Ast should be a function', function() {
    expect(queryES6Ast).to.be.a.function;
  });

  it('queryES6Ast should throw error when it receives empty bundle file path', function() {
    expect(queryES6Ast.bind(queryES6Ast, '')).to.throw(Error, /Empty bundle file input/); 
  });

  describe('getComponentName Tests', function() {
    const getComponentName = require('../previewParser.js').getComponentName;

    it('should return a valid function', function() {
      expect(getComponentName).to.be.a('function');
    });

    it('should return a component name for ES6 using Component', function() {
      const bundle = 'App=function(_Component)';
      expect(getComponentName(bundle, bundle.length)).to.equal('App');
    });

    it('should return a component name for ES6 using React.Component', function() {
      const bundle = 'Base=function(_React$Component)';
      expect(getComponentName(bundle, bundle.length)).to.equal('Base');
    });

    it('should return a component name for ES5 using React.createClass with spaces', function() {
      const bundle = 'var Node = (324, _react.createClass)';
      expect(getComponentName(bundle, bundle.length)).to.equal('Node');
    });
  })
})
@@ -46,16 +46,42 @@
 .expect;
+%0Aconst fs = require('fs');
 %0A%0Adescri
@@ -596,35 +596,218 @@
 %0A  %0A
-%0A
   
-it('modifyTestBundleFile
+const modifySetStateStrings = require('../previewParser.js').modifySetStateStrings;%0A  let previewParserFixtures = require('./fixtures/previewParserFixtures/bundleFileFixture.js');%0A%0A  it('modifySetStateStrings
  sho
@@ -856,30 +856,31 @@
 t(modify
-TestBundleFile
+SetStateStrings
 ).to.be.
@@ -906,38 +906,39 @@
   it('modify
-TestBundleFile
+SetStateStrings
  should thro
@@ -1023,80 +1023,124 @@
 dify
-TestBundleFile.bind(modifyTestBundleFile,'')).to.throw(Error, /Empty AST
+SetStateStrings.bind(modifySetStateStrings,'')).to.throw(Error, /Bundle string is empty, provide valid bundle string
  inp
@@ -1165,30 +1165,31 @@
 ('modify
-TestBundleFile
+SetStateStrings
  should 
@@ -1238,30 +1238,31 @@
 t(modify
-TestBundleFile
+SetStateStrings
 (preview
@@ -3087,8 +3087,9 @@
 %0A  %7D)%0A%7D)
+%0A

fix merge conflicts