From f0d300d7842b99da69f660349521cbb08c50c687 Mon Sep 17 00:00:00 2001 From: madhuka Date: Sun, 28 Jun 2015 00:26:32 +0530 Subject: [PATCH] complating Chart Factory for NVD3 and HighChart --- test/spec/chart-factory/high-chart-factory.js | 20 +++++++++++-- test/spec/chart-factory/nvd3-chart-factory.js | 29 ++++++++++++++----- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/test/spec/chart-factory/high-chart-factory.js b/test/spec/chart-factory/high-chart-factory.js index e914be9..e789dc5 100644 --- a/test/spec/chart-factory/high-chart-factory.js +++ b/test/spec/chart-factory/high-chart-factory.js @@ -14,6 +14,9 @@ describe("apacheZeppelinGsocApp HighChartFactory", function() { expect(myChart).toBeDefined(); }); }); + it(" to be define", function() { + expect(myChart.libname).toBe('highxChart'); + }); describe("Model", function() { //testing high chart is built in Genric chart model it("must extend the Genric Chart Model from ChartFactory", function() { @@ -36,12 +39,25 @@ describe("apacheZeppelinGsocApp HighChartFactory", function() { //changing the mockchart type myChart.setChartType('Bar'); expect(myChart.type).toBe('Bar'); + expect(myChart.viewModel.options.chart.type).toBe('bar'); + }); + it("testing setChartAxis", function() { + myChart.setChartAxis('testData'); + expect(myChart.viewModel.options.chart.type).toBe('line'); + expect(myChart.viewModel.xAxis.categories).toEqual([]); }); }); describe("view model", function() { it("testing for attributes", function() { - expect(myChart.viewModel).toBeDefined(); - //to-Do more Testing + expect(myChart.viewModel.size).toBeDefined(); + expect(myChart.viewModel.size.width).toBe(500); + expect(myChart.viewModel.size.height).toBe(300); + expect(myChart.viewModel.series).toBeDefined(); + expect(myChart.viewModel.xAxis).toBeDefined(); + }); + it("testing for series and xAxis", function() { + expect(myChart.viewModel.series[0].data).toBeDefined(); + expect(myChart.viewModel.xAxis.categories).toBeDefined(); }); }); }); \ No newline at end of file diff --git a/test/spec/chart-factory/nvd3-chart-factory.js b/test/spec/chart-factory/nvd3-chart-factory.js index 6b97b0a..0ec7e5a 100644 --- a/test/spec/chart-factory/nvd3-chart-factory.js +++ b/test/spec/chart-factory/nvd3-chart-factory.js @@ -3,28 +3,31 @@ describe("apacheZeppelinGsocApp NVD3ChartFactory", function() { beforeEach(module("apacheZeppelinGsocApp")); var myChart; beforeEach(inject(function(NVD3ChartFactory) { - //making mockchart called mychart from NVD3ChartFactory + //making mock-chart called mychart from NVD3ChartFactory myChart = NVD3ChartFactory; //mock mychart is NVD3Chart myChart.setChartType('Line'); })); - //testing for google chart factory + //testing for Google chart factory describe("Building a Chart", function() { it(" to be define", function() { expect(myChart).toBeDefined(); }); + it(" from NVD3Chart library", function() { + expect(myChart.libname).toBe('NVD3Chart'); + }); }); describe("Model", function() { - //testing NVD3 chart is built in Genric chart model - it("must extend the Genric Chart Model from ChartFactory", function() { + //testing NVD3 chart is built in Generic chart model + it("must extend the Generic Chart Model from ChartFactory", function() { expect(myChart.libname).toBeDefined(); expect(myChart.model).toBeDefined(); expect(myChart.viewModel).toBeDefined(); expect(myChart.type).toBeDefined(); expect(myChart.data).toBeDefined(); }); - //testing genric chart attribute type are followed by NVD3 Charts - it("testing the Genric Chart Model attributr type", function() { + //testing generic chart attribute type are followed by NVD3 Charts + it("testing the Generic Chart Model attribute type", function() { expect(myChart.viewModel).toBeDefined(); expect(myChart.viewModel instanceof Object).toBe(true); expect(myChart.type).toBe('Line'); @@ -33,15 +36,25 @@ describe("apacheZeppelinGsocApp NVD3ChartFactory", function() { }); describe("Operations", function() { it("testing setChartType", function() { - //changing the mockchart type + //changing the mock chart type myChart.setChartType('Bar'); expect(myChart.type).toBe('Bar'); + expect(myChart.viewModel.options.chart.type).toBe('discreteBarChart'); }); }); describe("view model", function() { it("testing for attributes", function() { expect(myChart.viewModel).toBeDefined(); - //to-Do more Testing + expect(myChart.viewModel.options.chart.type).toBeDefined(); + expect(myChart.viewModel.options.chart.showLegend).toBeDefined(); + expect(myChart.viewModel.options.chart.showValues).toBeDefined(); + expect(myChart.viewModel.data).toBeDefined(); + }); + it("testing for values of defaults", function() { + expect(myChart.viewModel.options.chart.showLegend).toBe(true); + expect(myChart.viewModel.options.chart.showValues).toBe(true); + expect(myChart.viewModel.options.chart.height).toBe(300); + expect(myChart.viewModel.options.chart.width).toBe(500); }); }); }); \ No newline at end of file