Skip to content

Commit

Permalink
complating Chart Factory for NVD3 and HighChart
Browse files Browse the repository at this point in the history
  • Loading branch information
Madhuka committed Jun 27, 2015
1 parent f79087c commit f0d300d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
20 changes: 18 additions & 2 deletions test/spec/chart-factory/high-chart-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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();
});
});
});
29 changes: 21 additions & 8 deletions test/spec/chart-factory/nvd3-chart-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
});
});
});

0 comments on commit f0d300d

Please sign in to comment.