diff --git a/test/karma.conf.js b/test/karma.conf.js index 379e921..74bed8a 100755 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -79,9 +79,9 @@ module.exports = function(config) { logLevel: config.LOG_INFO, // Uncomment the following lines if you are using grunt's server to run the tests - // proxies: { - // '/': 'http://localhost:9000/' - // }, + proxies: { + '/': 'http://localhost:9000/' + }, // URL root prevent conflicts with the site root // urlRoot: '_karma_' }); diff --git a/test/spec/chart-factory/services.js b/test/spec/chart-factory/services.js deleted file mode 100644 index f5cdcde..0000000 --- a/test/spec/chart-factory/services.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - -describe("apacheZeppelinGsocApp chartService", function() { - beforeEach(module("apacheZeppelinGsocApp")); - var chartService; - beforeEach(inject(function(ChartService) { - chartService = ChartService; - })); - describe("Testing Function APIs", function() { - it("chartService to be define", function() { - expect(chartService).toBeDefined(); - expect(chartService.getHighChart()).toBeDefined(); - expect(chartService.getGoogleChart()).toBeDefined(); - expect(chartService.getNVD3Chart()).toBeDefined(); - }); - }); - describe("Testing Function Operations", function() { - it("chartService on getGoogleChart", function() { - expect(chartService).toBeDefined(); - expect(chartService.getGoogleChart('Bar')).toBeDefined(); - expect(chartService.getGoogleChart('Line').libname).toBe( - 'googleChart'); - expect(chartService.getGoogleChart('Line').type).toBe('Line'); - expect(chartService.getGoogleChart('Line').viewModel.type).toBe( - 'LineChart'); - }); - }); -}); \ No newline at end of file diff --git a/test/spec/services/services.js b/test/spec/services/services.js index f5cdcde..155aba1 100644 --- a/test/spec/services/services.js +++ b/test/spec/services/services.js @@ -1,5 +1,4 @@ 'use strict'; - describe("apacheZeppelinGsocApp chartService", function() { beforeEach(module("apacheZeppelinGsocApp")); var chartService; @@ -15,9 +14,8 @@ describe("apacheZeppelinGsocApp chartService", function() { }); }); describe("Testing Function Operations", function() { - it("chartService on getGoogleChart", function() { + it("testing the Google Chart Model", function() { expect(chartService).toBeDefined(); - expect(chartService.getGoogleChart('Bar')).toBeDefined(); expect(chartService.getGoogleChart('Line').libname).toBe( 'googleChart'); expect(chartService.getGoogleChart('Line').type).toBe('Line'); @@ -25,4 +23,20 @@ describe("apacheZeppelinGsocApp chartService", function() { 'LineChart'); }); }); + describe("Testing Function Operations", function() { + it("testing the High Chart Model", function() { + expect(chartService).toBeDefined(); + expect(chartService.getHighChart('Line').libname).toBe( + 'highxChart'); + expect(chartService.getHighChart('Line').type).toBe('Line'); + }); + }); + describe("Testing Function Operations", function() { + it("testing the NVD3 Chart Model", function() { + expect(chartService).toBeDefined(); + expect(chartService.getNVD3Chart('Bar').libname).toBe( + 'NVD3Chart'); + expect(chartService.getNVD3Chart('Bar').type).toBe('Bar'); + }); + }); }); \ No newline at end of file diff --git a/test/spec/services/switch-chart.js b/test/spec/services/switch-chart.js new file mode 100644 index 0000000..8a24b02 --- /dev/null +++ b/test/spec/services/switch-chart.js @@ -0,0 +1,100 @@ +'use strict'; +describe("apacheZeppelinGsocApp chartService", function() { + beforeEach(module("apacheZeppelinGsocApp")); + var chartService; + beforeEach(inject(function(ChartService) { + chartService = ChartService; + })); + describe("Google Chart", function() { + it("Google Chart Type Switching", function() { + expect(chartService).toBeDefined(); + expect(chartService.getHighChart()).toBeDefined(); + expect(chartService.getGoogleChart('Bar').libname).toBe( + 'googleChart'); + expect(chartService.getGoogleChart('Bar').viewModel.type).toBe( + 'BarChart'); + expect(chartService.getGoogleChart('Line').viewModel.type).toBe( + 'LineChart'); + expect(chartService.getGoogleChart('Bar').viewModel.type).toBe( + 'BarChart'); + }); + it("testing the Google Chart View.Model", function() { + expect(chartService.getGoogleChart('Line').viewModel.data instanceof Object) + .toBe(true); + expect(chartService.getGoogleChart('Line').viewModel.cssStyle) + .toBe('height:400px; width:500px;'); + expect(chartService.getGoogleChart('Line').viewModel.options instanceof Object) + .toBe(true); + expect(chartService.getGoogleChart('Line').viewModel.options.displayExactValues) + .toBe(true); + }); + }); + describe("High Chart", function() { + var categories, myHighChart; + beforeEach(function() { + categories = [1, 2, 3, 4]; + myHighChart = chartService.getHighChart('Line'); + myHighChart.viewModel.xAxis.categories = categories; + }); + it("High Chart Type Switching", function() { + expect(chartService.getHighChart('Line').libname).toBe( + 'highxChart'); + expect(myHighChart.viewModel.options.chart.type).toBe( + 'line'); + expect(chartService.getHighChart('Line').data instanceof Object) + .toBe(true); + expect(chartService.getHighChart('Line').viewModel.options.chart + .type).toBe( + 'line'); + expect(chartService.getHighChart('Bar').viewModel.options.chart + .type).toBe( + 'bar'); + expect(chartService.getHighChart('Bar').type).toBe( + 'Bar'); + }); + it("testing the High Chart View.Model", function() { + expect(chartService.getHighChart('Line').viewModel.data instanceof Object) + .toBe(false); + expect(chartService.getHighChart('Line').viewModel.size instanceof Object) + .toBe(true); + expect(chartService.getHighChart('Line').viewModel.size.width) + .toBe(500); + expect(chartService.getHighChart('Line').viewModel.size.height) + .toBe(300); + }); + it("testing the High Chart changing the xAxis.categories", function() { + expect(myHighChart.viewModel.xAxis.categories instanceof Array) + .toBe(true); + expect(myHighChart.viewModel.xAxis.categories).toEqual( + categories); + }); + }); + describe("Testing NVD3Chart", function() { + var data, myNVD3Chart; + beforeEach(function() { + data = { + 'values': [12, 34, 23] + }; + myNVD3Chart = chartService.getNVD3Chart('Line'); + myNVD3Chart.viewModel.data = [1, 2]; + }); + it("Testing NVD3Chart Data Transform", function() { + expect(chartService.getNVD3Chart('Bar').libname).toBe( + 'NVD3Chart'); + expect(myNVD3Chart.type).toBe('Bar'); + expect(myNVD3Chart.viewModel.data).toEqual([1, 2]); + myNVD3Chart.viewModel.data = data; + expect(myNVD3Chart.viewModel.data).toEqual(data); + }); + it("Testing NVD3Chart Chart Type Transform", function() { + expect(chartService.getNVD3Chart('Line').viewModel.options.chart + .type).toBe( + 'lineChart'); + expect(chartService.getNVD3Chart('Bar').viewModel.options.chart + .type).toBe( + 'discreteBarChart'); + expect(chartService.getNVD3Chart('Bar').type).toBe( + 'Bar'); + }); + }); +}); \ No newline at end of file