Skip to content

Commit

Permalink
Adding Test Cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Madhuka committed Jun 25, 2015
1 parent 59cdd46 commit e4d29c4
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 34 deletions.
6 changes: 3 additions & 3 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_'
});
Expand Down
28 changes: 0 additions & 28 deletions test/spec/chart-factory/services.js

This file was deleted.

20 changes: 17 additions & 3 deletions test/spec/services/services.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';

describe("apacheZeppelinGsocApp chartService", function() {
beforeEach(module("apacheZeppelinGsocApp"));
var chartService;
Expand All @@ -15,14 +14,29 @@ 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');
expect(chartService.getGoogleChart('Line').viewModel.type).toBe(
'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');
});
});
});
100 changes: 100 additions & 0 deletions test/spec/services/switch-chart.js
Original file line number Diff line number Diff line change
@@ -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');
});
});
});

0 comments on commit e4d29c4

Please sign in to comment.