-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Madhuka/milestone-03-testcases
Adding Test cases for Chart Factory
- Loading branch information
Showing
8 changed files
with
355 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
'use strict'; | ||
describe("apacheZeppelinGsocApp ChartFactory", function() { | ||
beforeEach(module("apacheZeppelinGsocApp")); | ||
var chartService; | ||
//Mock Chart Factory will extend the ChartFactory | ||
var MyChartFactory; | ||
beforeEach(inject(function(ChartFactory) { | ||
//mockups models | ||
function xChartModel(d) { | ||
return { | ||
c: [{ | ||
v: d.Make | ||
}] | ||
}; | ||
} | ||
|
||
function getXChart(error, rows) { | ||
MyChartFactory.data.rows = rows; | ||
} | ||
var newChartLibrary = { | ||
model: xChartModel, | ||
get: getXChart | ||
}; | ||
MyChartFactory = new ChartFactory('MyTestChartLib', | ||
newChartLibrary); | ||
})); | ||
//testing for genric chart factory | ||
describe("Instance", function() { | ||
it(" to be define", function() { | ||
expect(MyChartFactory).toBeDefined(); | ||
}); | ||
}); | ||
describe("Model", function() { | ||
//testing My chart is built in Genric chart model | ||
it("must extend the Genric Chart Model from ChartFactory", function() { | ||
expect(MyChartFactory.libname).toBeDefined(); | ||
expect(MyChartFactory.model).toBeDefined(); | ||
expect(MyChartFactory.viewModel).toBeDefined(); | ||
expect(MyChartFactory.type).toBeDefined(); | ||
expect(MyChartFactory.data).toBeDefined(); | ||
}); | ||
//testing genric chart attribute type are followed by My Charts | ||
it("testing the Genric Google Chart Model", function() { | ||
expect(MyChartFactory).toBeDefined(); | ||
expect(MyChartFactory.viewModel).toBeDefined(); | ||
expect(MyChartFactory.viewModel instanceof Object).toBe(true); | ||
expect(MyChartFactory.type instanceof Object).toBe(true); | ||
expect(MyChartFactory.data instanceof Object).toBe(true); | ||
}); | ||
}); | ||
describe("Operations", function() { | ||
//testing genric chart attribute type are followed by Google Charts | ||
it("testing chart library is setted correctly", function() { | ||
expect(MyChartFactory.model instanceof Object).toBe(true); | ||
expect(MyChartFactory.libname).toBe('MyTestChartLib'); | ||
}); | ||
it("testing set chart Model", function() { | ||
expect(MyChartFactory.model.model instanceof Object).toBe( | ||
true); | ||
expect(MyChartFactory.model.get instanceof Function).toBe( | ||
true); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
describe("apacheZeppelinGsocApp GoogleChartFactory", function() { | ||
beforeEach(module("apacheZeppelinGsocApp")); | ||
var myChart; | ||
beforeEach(inject(function(GoogleChartFactory) { | ||
//making mockchart called mychart from GoogleChartFactory | ||
myChart = GoogleChartFactory; | ||
//mock mychart is GoogleChart | ||
myChart.setChartType('Line'); | ||
})); | ||
//testing for google chart factory | ||
describe("Building a Chart", function() { | ||
it(" to be define", function() { | ||
expect(myChart).toBeDefined(); | ||
}); | ||
}); | ||
describe("Model", function() { | ||
//testing Google chart is built in Genric chart model | ||
it("must extend the Genric 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 Google Charts | ||
it("testing the Genric Chart Model attributr type", function() { | ||
expect(myChart.viewModel).toBeDefined(); | ||
expect(myChart.viewModel instanceof Object).toBe(true); | ||
expect(myChart.type).toBe('Line'); | ||
expect(myChart.data instanceof Object).toBe(true); | ||
}); | ||
}); | ||
describe("Operations", function() { | ||
it("testing setChartType", function() { | ||
//changing the mockchart type | ||
myChart.setChartType('Bar'); | ||
expect(myChart.type).toBe('Bar'); | ||
}); | ||
}); | ||
describe("view model", function() { | ||
it("testing for attributes", function() { | ||
expect(myChart.viewModel.options).toBeDefined(); | ||
//to-Do more Testing | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
describe("apacheZeppelinGsocApp HighChartFactory", function() { | ||
beforeEach(module("apacheZeppelinGsocApp")); | ||
var myChart; | ||
beforeEach(inject(function(HighChartFactory) { | ||
//making mockchart called mychart from HighChartFactory | ||
myChart = HighChartFactory; | ||
//mock mychart is highChart | ||
myChart.setChartType('Line'); | ||
})); | ||
//testing for google chart factory | ||
describe("Building a Chart", function() { | ||
it(" to be define", function() { | ||
expect(myChart).toBeDefined(); | ||
}); | ||
}); | ||
describe("Model", function() { | ||
//testing high chart is built in Genric chart model | ||
it("must extend the Genric 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 high Charts | ||
it("testing the Genric Chart Model attributr type", function() { | ||
expect(myChart.viewModel).toBeDefined(); | ||
expect(myChart.viewModel instanceof Object).toBe(true); | ||
expect(myChart.type).toBe('Line'); | ||
expect(myChart.data instanceof Object).toBe(true); | ||
}); | ||
}); | ||
describe("Operations", function() { | ||
it("testing setChartType", function() { | ||
//changing the mockchart type | ||
myChart.setChartType('Bar'); | ||
expect(myChart.type).toBe('Bar'); | ||
}); | ||
}); | ||
describe("view model", function() { | ||
it("testing for attributes", function() { | ||
expect(myChart.viewModel).toBeDefined(); | ||
//to-Do more Testing | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
describe("apacheZeppelinGsocApp NVD3ChartFactory", function() { | ||
beforeEach(module("apacheZeppelinGsocApp")); | ||
var myChart; | ||
beforeEach(inject(function(NVD3ChartFactory) { | ||
//making mockchart called mychart from NVD3ChartFactory | ||
myChart = NVD3ChartFactory; | ||
//mock mychart is NVD3Chart | ||
myChart.setChartType('Line'); | ||
})); | ||
//testing for google chart factory | ||
describe("Building a Chart", function() { | ||
it(" to be define", function() { | ||
expect(myChart).toBeDefined(); | ||
}); | ||
}); | ||
describe("Model", function() { | ||
//testing NVD3 chart is built in Genric chart model | ||
it("must extend the Genric 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() { | ||
expect(myChart.viewModel).toBeDefined(); | ||
expect(myChart.viewModel instanceof Object).toBe(true); | ||
expect(myChart.type).toBe('Line'); | ||
expect(myChart.data instanceof Object).toBe(true); | ||
}); | ||
}); | ||
describe("Operations", function() { | ||
it("testing setChartType", function() { | ||
//changing the mockchart type | ||
myChart.setChartType('Bar'); | ||
expect(myChart.type).toBe('Bar'); | ||
}); | ||
}); | ||
describe("view model", function() { | ||
it("testing for attributes", function() { | ||
expect(myChart.viewModel).toBeDefined(); | ||
//to-Do more Testing | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'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("testing the Google Chart Model", function() { | ||
expect(chartService).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'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
'use strict'; | ||
describe("apacheZeppelinGsocApp chartService", function() { | ||
beforeEach(module("apacheZeppelinGsocApp")); | ||
var chartService; | ||
beforeEach(inject(function(ChartService) { | ||
chartService = ChartService; | ||
})); | ||
describe("Google Chart", function() { | ||
var googleChart; | ||
beforeEach(function() { | ||
googleChart = chartService.getGoogleChart('Bar'); | ||
}); | ||
it("switching chart type ", 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'); | ||
}); | ||
it("testing Chart view model", function() { | ||
expect(googleChart.viewModel.data instanceof Object) | ||
.toBe(true); | ||
expect(googleChart.viewModel.cssStyle) | ||
.toBe('height:400px; width:500px;'); | ||
expect(googleChart.viewModel.options instanceof Object) | ||
.toBe(true); | ||
expect(googleChart.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("Switching chart type", 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 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 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 transforming data ", 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("transforming chart tType", 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'); | ||
}); | ||
}); | ||
}); |