Skip to content

Commit

Permalink
Added test component and directive
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrathings committed Jan 15, 2017
1 parent c1f4466 commit ee4c779
Show file tree
Hide file tree
Showing 10 changed files with 1,361 additions and 48 deletions.
37 changes: 27 additions & 10 deletions dist/test/angular2-nvd3.component.spec.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
"use strict";
var testing_1 = require("@angular/core/testing");
var angular2_nvd3_component_1 = require("../angular2-nvd3/angular2-nvd3.component");
describe('tasks:NvD3Component', function () {
var comp;
var fixture;
beforeEach(function () {
testing_1.TestBed.configureTestingModule({
declarations: [angular2_nvd3_component_1.NvD3Component],
var sample_data_1 = require("./sample-data");
sample_data_1.SampleData.chartTypes.forEach(function (type) {
describe("tasks:NvD3Component " + type, function () {
var component;
var fixture;
var componentElement;
beforeEach(function () {
testing_1.TestBed.configureTestingModule({
declarations: [angular2_nvd3_component_1.NvD3Component],
});
fixture = testing_1.TestBed.createComponent(angular2_nvd3_component_1.NvD3Component);
component = fixture.componentInstance;
component.options = sample_data_1.SampleData.allOptions[type];
component.data = sample_data_1.SampleData.allData[type];
fixture.detectChanges();
componentElement = fixture.nativeElement;
});
it("should have svg", function () {
expect(componentElement.querySelectorAll('svg').length).toBe(1);
});
it('should svg have class nvd3-svg', function () {
var gElement = componentElement.querySelector('svg');
expect(gElement.classList).toContain('nvd3-svg');
});
it("should g have class nv-" + type, function () {
var gElement = componentElement.querySelector('g');
expect(gElement.className.baseVal).toContain(sample_data_1.SampleData.chartClassExpected[type]);
});
});
it('should call ngOnChanges', function () {
});
it('should call ngOnInit', function () {
});
});
320 changes: 320 additions & 0 deletions dist/test/sample-data.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,320 @@
export declare namespace SampleData {
const chartTypes: string[];
const allOptions: {
lineChart: {
chart: {
type: string;
height: number;
x: (d: any) => any;
y: (d: any) => any;
};
};
discreteBarChart: {
chart: {
type: string;
height: number;
x: (d: any) => any;
y: (d: any) => any;
};
};
pieChart: {
chart: {
type: string;
height: number;
x: (d: any) => any;
y: (d: any) => any;
};
};
scatterChart: {
chart: {
type: string;
height: number;
};
};
multiBarChart: {
chart: {
type: string;
height: number;
stacked: boolean;
};
};
candlestickBarChart: {
chart: {
type: string;
height: number;
x: (d: any) => any;
y: (d: any) => any;
};
};
ohlcBarChart: {
chart: {
type: string;
height: number;
x: (d: any) => any;
y: (d: any) => any;
};
};
boxPlotChart: {
chart: {
type: string;
height: number;
x: (d: any) => any;
};
};
multiChart: {
chart: {
type: string;
height: number;
};
};
sunburstChart: {
chart: {
type: string;
height: number;
};
};
stackedAreaChart: {
chart: {
type: string;
height: number;
x: (d: any) => any;
y: (d: any) => any;
};
};
multiBarHorizontalChart: {
chart: {
type: string;
height: number;
x: (d: any) => any;
y: (d: any) => any;
};
};
cumulativeLineChart: {
chart: {
type: string;
height: number;
x: (d: any) => any;
y: (d: any) => number;
average: (d: any) => number;
};
};
historicalBarChart: {
chart: {
type: string;
height: number;
x: (d: any) => any;
y: (d: any) => number;
};
};
parallelCoordinates: {
chart: {
type: string;
height: number;
dimensionData: string[];
};
};
sparklinePlus: {
chart: {
type: string;
height: number;
x: (d: any, i: any) => any;
};
};
bulletChart: {
chart: {
type: string;
height: number;
};
};
linePlusBarWithFocusChart: {
chart: {
type: string;
height: number;
color: string[];
x: (d: any, i: any) => any;
};
};
forceDirectedGraph: {
chart: {
type: string;
};
};
};
const allData: {
lineChart: {
key: string;
values: {
x: number;
y: number;
}[];
}[];
discreteBarChart: {
key: string;
values: {
'label': string;
'value': number;
}[];
}[];
pieChart: {
key: string;
y: number;
}[];
scatterChart: {
key: string;
values: {
x: number;
y: number;
}[];
}[];
multiBarChart: {
key: string;
values: {
x: number;
y: number;
}[];
}[];
candlestickBarChart: {
values: {
'date': number;
'open': number;
'high': number;
'low': number;
'close': number;
'volume': number;
'adjusted': number;
}[];
}[];
ohlcBarChart: {
values: {
'date': number;
'open': number;
'high': number;
'low': number;
'close': number;
'volume': number;
'adjusted': number;
}[];
}[];
boxPlotChart: {
label: string;
values: {
Q1: number;
Q2: number;
Q3: number;
whisker_low: number;
whisker_high: number;
outliers: number[];
};
}[];
multiChart: {
key: string;
type: string;
yAxis: number;
values: {
x: number;
y: number;
}[];
}[];
sunburstChart: {
'name': string;
'children': {
'name': string;
'children': {
'name': string;
'children': {
'name': string;
'size': number;
}[];
}[];
}[];
}[];
stackedAreaChart: {
'key': string;
'values': number[][];
}[];
multiBarHorizontalChart: {
'key': string;
'values': {
'label': string;
'value': number;
}[];
}[];
cumulativeLineChart: {
key: string;
values: number[][];
mean: number;
}[];
historicalBarChart: {
'key': string;
'bar': boolean;
'values': number[][];
}[];
parallelCoordinates: {
'name': string;
'economy (mpg)': string;
'cylinders': string;
'displacement (cc)': string;
'power (hp)': string;
'weight (lb)': string;
'0-60 mph (s)': string;
'year': string;
}[];
sparklinePlus: {
x: number;
y: number;
}[];
bulletChart: {
'title': string;
'subtitle': string;
'ranges': number[];
'measures': number[];
'markers': number[];
};
linePlusBarWithFocusChart: ({
'key': string;
'bar': boolean;
'values': {
x: number;
y: number;
}[];
} | {
'key': string;
'values': {
x: number;
y: number;
}[];
})[];
forceDirectedGraph: {
'nodes': {
'name': string;
'group': number;
}[];
'links': {
'source': number;
'target': number;
'value': number;
}[];
};
};
const chartClassExpected: {
lineChart: string;
discreteBarChart: string;
pieChart: string;
scatterChart: string;
multiBarChart: string;
multiBarHorizontalChart: string;
candlestickBarChart: string;
ohlcBarChart: string;
boxPlotChart: string;
multiChart: string;
sunburstChart: string;
stackedAreaChart: string;
cumulativeLineChart: string;
historicalBarChart: string;
parallelCoordinates: string;
sparklinePlus: string;
bulletChart: string;
linePlusBarWithFocusChart: string;
forceDirectedGraph: string;
};
}
Loading

0 comments on commit ee4c779

Please sign in to comment.