'use strict';

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

describe('BarChart', function() {
  it('renders barchart', function() {
    var React = require('react/addons');
    var BarChart = require('../src/barchart').BarChart;
    var generate = require('./utils/datagen').generateArrayOfNumbers;
    var TestUtils = React.addons.TestUtils;

    // Render a barchart using array data
    var data = generate(5);
    var barchart = TestUtils.renderIntoDocument(
      <BarChart data={data} width={400} height={200} />
    );

    // Verify that it has rendered the main chart svg
    var barchartGroup = TestUtils.findRenderedDOMComponentWithClass(
      barchart, 'rd3-barchart');
    expect(barchartGroup).to.exist;
    expect(barchartGroup.tagName).to.equal('G');

    // Verify that it has the same number of bars as the array's length
    var bars = TestUtils.scryRenderedDOMComponentsWithTag(
      barchart, 'rect');
    expect(bars.length).to.equal(data.length);
  });
  it('renders barchart with negative values', function() {
    var React = require('react/addons');
    var BarChart = require('../src/barchart').BarChart;
    var generate = require('./utils/datagen').generateArrayOfNumbers;
    var TestUtils = React.addons.TestUtils;

    // Render a barchart using array data
    var data = generate(5);

    // Set a few values to negative numbers
    data[1] = -100;
    data[3] = -150;

    var barchart = TestUtils.renderIntoDocument(
      <BarChart data={data} width={400} height={200} />
    );

    // Verify that it has rendered the main chart svg
    var barchartGroup = TestUtils.findRenderedDOMComponentWithClass(
      barchart, 'rd3-barchart');
    expect(barchartGroup).to.exist;
    expect(barchartGroup.tagName).to.equal('G');

    // Verify that it has the same number of bars as the array's length
    var bars = TestUtils.scryRenderedDOMComponentsWithTag(
      barchart, 'rect');
    expect(bars.length).to.equal(data.length);
  });
});

@@ -268,38 +268,37 @@
 .generateArrayOf
-Number
+Point
 s;%0A    var TestU
@@ -319,32 +319,226 @@
 ddons.TestUtils;
+%0A    var length = 5;%0A%0A    var data = %5B%0A      %7B%0A        name: %22series1%22,%0A        values: generate(length)%0A      %7D,%0A      %7B%0A        name: %22series2%22,%0A        values: generate(length)%0A      %7D%0A    %5D;
 %0A%0A    // Render 
@@ -569,36 +569,8 @@
 ata%0A
-    var data = generate(5);%0A
     
@@ -1112,32 +1112,41 @@
 qual(data.length
+ * length
 );%0A  %7D);%0A  it('r
@@ -1138,16 +1138,17 @@
 ;%0A  %7D);%0A
+%0A
   it('re
@@ -1360,14 +1360,13 @@
 ayOf
-Number
+Point
 s;%0A 
@@ -1417,72 +1417,196 @@
     
-// Render a barchart using array data%0A    var data = generate(5)
+var length = 5;%0A%0A    var data = %5B%0A      %7B%0A        name: %22series1%22,%0A        values: generate(length)%0A      %7D,%0A      %7B%0A        name: %22series2%22,%0A        values: generate(length)%0A      %7D%0A    %5D
 ;%0A%0A 
@@ -1657,17 +1657,32 @@
    data%5B
-1
+0%5D.values%5B1%5D%5B'y'
 %5D = -100
@@ -1692,17 +1692,32 @@
    data%5B
-3
+1%5D.values%5B3%5D%5B'y'
 %5D = -150
@@ -2270,24 +2270,33 @@
 (data.length
+ * length
 );%0A  %7D);%0A%7D);

Change test to bar chart