From 4f4850486972b0c09512bddf16ca64b319b9d7bc Mon Sep 17 00:00:00 2001 From: Bob Renwick Date: Fri, 28 Nov 2014 15:57:56 +0000 Subject: [PATCH] adding a test to make sure the new updateLegend behaviour works --- spec/legend-spec.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/spec/legend-spec.js b/spec/legend-spec.js index cb2cf6d..a70f494 100644 --- a/spec/legend-spec.js +++ b/spec/legend-spec.js @@ -151,4 +151,36 @@ describe('c3 chart legend', function () { }); + describe('legend.show', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 130, 100, 200, 100, 250, 150] + ] + }, + legend: { + show: false + } + }; + expect(true).toBeTruthy(); + }); + + it('should not initially have rendered any legend items', function () { + expect(d3.selectAll('.c3-legend-item').empty()).toBe(true); + }); + + it('allows us to show the legend on showLegend call', function () { + chart.legend.show(); + d3.selectAll('.c3-legend-item').each(function () { + expect(d3.select(this).style('visibility')).toBe('visible'); + // This selects all the children, but we expect it to be empty + expect(d3.select(this).selectAll("*").length).not.toEqual(0); + }); + }); + + }); + });