Skip to content

Commit 856d26d

Browse files
committed
Adding tests for more controls
Adding tests for more controls
1 parent f5bdad9 commit 856d26d

File tree

22 files changed

+1046
-114
lines changed

22 files changed

+1046
-114
lines changed

src/igniteui.angular2.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var NODES = {
3535
"ig-map": "div",
3636
"ig-bullet-graph": "div",
3737
"ig-linear-gauge": "div",
38-
"ig-qrcode-barcode": "div",
38+
"ig-q-r-code-barcode": "div",
3939
"ig-validator": "div",
4040
"ig-upload": "div",
4141
"ig-popover": "div",
@@ -777,7 +777,7 @@ export class IgValidatorComponent extends IgControlBase<IgValidator> {
777777
var evtName;
778778
this._el = jQuery(document).find("#" + this.widgetId);
779779
jQuery(this._el)[this._widgetName](this._config);
780-
780+
this._events = new Map<string, string>();
781781
//events binding
782782
let that = this;
783783
for (var propt in jQuery.ui[this._widgetName].prototype.events) {
@@ -845,6 +845,7 @@ export class IgPopoverComponent extends IgControlBase<IgPopover> {
845845
var elem = jQuery(document).find("#" + this.widgetId);
846846
if (elem.length === 1) {
847847
this._el = elem;
848+
this._events = new Map<string, string>();
848849
//events binding
849850
let that = this;
850851
var evtName;
@@ -875,7 +876,7 @@ export class IgNotifierComponent extends IgControlBase<any> {
875876
var elem = jQuery(document).find("#" + this.widgetId);
876877
if (elem.length === 1) {
877878
this._el = elem;
878-
879+
this._events = new Map<string, string>();
879880
//events binding
880881
let that = this;
881882
var evtName;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
// modeled after https://github.com/angular/angular/blob/cee2318110eeea115e5f6fc5bfc814cbaa7d90d8/modules/angular2/test/common/directives/ng_for_spec.ts
3+
import { it, iit, describe, expect, inject, injectAsync, beforeEachProviders, fakeAsync, tick, TestComponentBuilder, AsyncTestCompleter } from 'angular2/testing_internal';
4+
import {Component, ViewChild, TemplateRef} from 'angular2/core';
5+
import * as Infragistics from '../../../src/igniteui.angular2';
6+
7+
export function main() {
8+
describe('Infragistics Angular2 BulletGraph', () => {
9+
it('should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
10+
var template = '<div><ig-bullet-graph widgetId="bulletGraph" [(options)]="opts"></ig-bullet-graph></div>';
11+
tcb.overrideTemplate(TestComponent, template)
12+
.createAsync(TestComponent)
13+
.then((fixture) => {
14+
fixture.detectChanges();
15+
expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgBulletGraphComponent);
16+
async.done();
17+
});
18+
}));
19+
20+
});
21+
}
22+
23+
@Component({
24+
selector: 'test-cmp',
25+
template: '<div></div>', //"Component 'TestComponent' must have either 'template' or 'templateUrl' set."
26+
directives: [Infragistics.IgBulletGraphComponent]
27+
})
28+
class TestComponent {
29+
private opts: any;
30+
31+
@ViewChild(Infragistics.IgBulletGraphComponent) public viewChild: Infragistics.IgBulletGraphComponent;
32+
33+
constructor() {
34+
this.opts = {
35+
height: "80px",
36+
width: "100%",
37+
minimumValue: 0,
38+
maximumValue: 30,
39+
value: 26,
40+
targetValue: 22,
41+
ranges: [
42+
{
43+
name: 'bad',
44+
startValue: 0,
45+
endValue: 14
46+
},
47+
{
48+
name: 'acceptable',
49+
startValue: 14,
50+
endValue: 25
51+
},
52+
{
53+
name: 'good',
54+
startValue: 25,
55+
endValue: 30
56+
}]
57+
}
58+
}
59+
}

tests/unit/igdatachart/chart.spec.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {Component, ViewChild, TemplateRef} from 'angular2/core';
44
import * as Infragistics from '../../../src/igniteui.angular2';
55

66
export function main() {
7-
describe('Infragistics Angular2 DataChart', () => {
7+
describe('Infragistics Angular2 DataChart and Zoombar', () => {
88
it('should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
99
var template = '<div><ig-data-chart widgetId="datachart1" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-data-chart></div>';
1010
tcb.overrideTemplate(TestComponent, template)
@@ -15,21 +15,33 @@ export function main() {
1515
async.done();
1616
});
1717
}));
18+
19+
it('Zoombar should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
20+
var template = '<div><ig-data-chart widgetId="datachart1" [(options)]="opts"></ig-data-chart><ig-zoombar [(options)]="zoombarOpts" widgetId="zoombar"></ig-zoombar></div>';
21+
tcb.overrideTemplate(TestComponent, template)
22+
.createAsync(TestComponent)
23+
.then((fixture) => {
24+
fixture.detectChanges();
25+
expect(fixture.debugElement.componentInstance.viewChild2).toBeAnInstanceOf(Infragistics.IgZoombarComponent);
26+
async.done();
27+
});
28+
}));
1829
});
1930
}
2031

2132
@Component({
2233
selector: 'test-cmp',
2334
template: '<div></div>', //"Component 'TestComponent' must have either 'template' or 'templateUrl' set."
24-
directives: [Infragistics.IgDataChartComponent]
35+
directives: [Infragistics.IgDataChartComponent,Infragistics.IgZoombarComponent]
2536
})
2637
class TestComponent {
2738
private opts: any;
2839
private zoombarOpts:any;
2940
private data: Array<any>;
3041
private cdi: number;
3142
@ViewChild(Infragistics.IgDataChartComponent) public viewChild: Infragistics.IgDataChartComponent;
32-
43+
@ViewChild(Infragistics.IgZoombarComponent) public viewChild2: Infragistics.IgZoombarComponent;
44+
3345
constructor() {
3446
this.cdi = 10;
3547
this.data = [{
@@ -63,5 +75,8 @@ class TestComponent {
6375
valueMemberPath: "Pop2015"
6476
}]
6577
};
78+
this.zoombarOpts = {
79+
target: "#datachart1"
80+
};
6681
}
6782
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// modeled after https://github.com/angular/angular/blob/cee2318110eeea115e5f6fc5bfc814cbaa7d90d8/modules/angular2/test/common/directives/ng_for_spec.ts
2+
import { it, iit, describe, expect, inject, injectAsync, beforeEachProviders, fakeAsync, tick, TestComponentBuilder, AsyncTestCompleter } from 'angular2/testing_internal';
3+
import {Component, ViewChild, TemplateRef} from 'angular2/core';
4+
import * as Infragistics from '../../../src/igniteui.angular2';
5+
6+
export function main() {
7+
describe('Infragistics Angular2 DoughnutChart', () => {
8+
it('should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
9+
var template = '<div><ig-doughnut-chart widgetId="chart1" [(options)]="opts" ></ig-doughnut-chart></div>';
10+
tcb.overrideTemplate(TestComponent, template)
11+
.createAsync(TestComponent)
12+
.then((fixture) => {
13+
fixture.detectChanges();
14+
expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgDoughnutChartComponent);
15+
async.done();
16+
});
17+
}));
18+
});
19+
}
20+
21+
@Component({
22+
selector: 'test-cmp',
23+
template: '<div></div>', //"Component 'TestComponent' must have either 'template' or 'templateUrl' set."
24+
directives: [Infragistics.IgDoughnutChartComponent]
25+
})
26+
class TestComponent {
27+
private opts: any;
28+
private data:any;
29+
30+
@ViewChild(Infragistics.IgDoughnutChartComponent) public viewChild: Infragistics.IgDoughnutChartComponent;
31+
32+
constructor() {
33+
this.data = [
34+
{ "CountryName": "China", "Pop1990": 1141, "Pop2008": 1333, "Pop2025": 1458 },
35+
{ "CountryName": "India", "Pop1990": 849, "Pop2008": 1140, "Pop2025": 1398 },
36+
{ "CountryName": "United States", "Pop1990": 250, "Pop2008": 304, "Pop2025": 352 },
37+
{ "CountryName": "Indonesia", "Pop1990": 178, "Pop2008": 228, "Pop2025": 273 },
38+
{ "CountryName": "Brazil", "Pop1990": 150, "Pop2008": 192, "Pop2025": 223 }
39+
];
40+
this.opts = {
41+
width: "500px",
42+
height: "500px",
43+
series:
44+
[{
45+
name: "Pop1990",
46+
labelMemberPath: "CountryName",
47+
valueMemberPath: "Pop1990",
48+
dataSource: this.data
49+
}]
50+
};
51+
}
52+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// modeled after https://github.com/angular/angular/blob/cee2318110eeea115e5f6fc5bfc814cbaa7d90d8/modules/angular2/test/common/directives/ng_for_spec.ts
2+
import { it, iit, describe, expect, inject, injectAsync, beforeEachProviders, fakeAsync, tick, TestComponentBuilder, AsyncTestCompleter } from 'angular2/testing_internal';
3+
import {Component, ViewChild, TemplateRef} from 'angular2/core';
4+
import * as Infragistics from '../../../src/igniteui.angular2';
5+
6+
export function main() {
7+
describe('Infragistics Angular2 FunnelChart', () => {
8+
it('should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
9+
var template = '<div><ig-funnel-chart widgetId="chart1" [(options)]="opts" ></ig-funnel-chart></div>';
10+
tcb.overrideTemplate(TestComponent, template)
11+
.createAsync(TestComponent)
12+
.then((fixture) => {
13+
fixture.detectChanges();
14+
expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgFunnelChartComponent);
15+
async.done();
16+
});
17+
}));
18+
});
19+
}
20+
21+
@Component({
22+
selector: 'test-cmp',
23+
template: '<div></div>', //"Component 'TestComponent' must have either 'template' or 'templateUrl' set."
24+
directives: [Infragistics.IgFunnelChartComponent]
25+
})
26+
class TestComponent {
27+
private opts: any;
28+
private data:any;
29+
30+
@ViewChild(Infragistics.IgFunnelChartComponent) public viewChild: Infragistics.IgFunnelChartComponent;
31+
32+
constructor() {
33+
this.data = [
34+
{ Budget: 30, Department: "Administration" },
35+
{ Budget: 50, Department: "Sales" },
36+
{ Budget: 60, Department: "IT" },
37+
{ Budget: 50, Department: "Marketing" },
38+
{ Budget: 100, Department: "Development" },
39+
{ Budget: 20, Department: "Support" }
40+
];
41+
this.opts = {
42+
width: "100%",
43+
height: "450px",
44+
dataSource: this.data,
45+
valueMemberPath: "Budget",
46+
innerLabelMemberPath: "Budget",
47+
innerLabelVisibility: "visible",
48+
outerLabelMemberPath: "Department",
49+
outerLabelVisibility: "visible"
50+
};
51+
}
52+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
// modeled after https://github.com/angular/angular/blob/cee2318110eeea115e5f6fc5bfc814cbaa7d90d8/modules/angular2/test/common/directives/ng_for_spec.ts
3+
import { it, iit, describe, expect, inject, injectAsync, beforeEachProviders, fakeAsync, tick, TestComponentBuilder, AsyncTestCompleter } from 'angular2/testing_internal';
4+
import {Component, ViewChild, TemplateRef} from 'angular2/core';
5+
import * as Infragistics from '../../../src/igniteui.angular2';
6+
7+
export function main() {
8+
describe('Infragistics Angular2 Linear Gauge', () => {
9+
it('should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
10+
var template = '<div><ig-linear-gauge widgetId="lGauge" [(options)]="opts"></ig-linear-gauge></div>';
11+
tcb.overrideTemplate(TestComponent, template)
12+
.createAsync(TestComponent)
13+
.then((fixture) => {
14+
fixture.detectChanges();
15+
expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgLinearGaugeComponent);
16+
async.done();
17+
});
18+
}));
19+
20+
});
21+
}
22+
23+
@Component({
24+
selector: 'test-cmp',
25+
template: '<div></div>', //"Component 'TestComponent' must have either 'template' or 'templateUrl' set."
26+
directives: [Infragistics.IgLinearGaugeComponent]
27+
})
28+
class TestComponent {
29+
private opts: any;
30+
31+
@ViewChild(Infragistics.IgLinearGaugeComponent) public viewChild: Infragistics.IgLinearGaugeComponent;
32+
33+
constructor() {
34+
this.opts = {
35+
height: "80px",
36+
width: "100%",
37+
value: 27,
38+
maximumValue: 30,
39+
ranges: [{startValue:0, endValue:22, name:"target"}]
40+
};
41+
}
42+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// modeled after https://github.com/angular/angular/blob/cee2318110eeea115e5f6fc5bfc814cbaa7d90d8/modules/angular2/test/common/directives/ng_for_spec.ts
2+
import { it, iit, describe, expect, inject, injectAsync, beforeEachProviders, fakeAsync, tick, TestComponentBuilder, AsyncTestCompleter } from 'angular2/testing_internal';
3+
import {Component, ViewChild, TemplateRef} from 'angular2/core';
4+
import * as Infragistics from '../../../src/igniteui.angular2';
5+
6+
export function main() {
7+
describe('Infragistics Angular2 Notifier', () => {
8+
it('should initialize correctly', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
9+
var template = '<div><ig-notifier widgetId="notifier" [(options)]="opts"></ig-notifier></div>';
10+
tcb.overrideTemplate(TestComponent, template)
11+
.createAsync(TestComponent)
12+
.then((fixture) => {
13+
fixture.detectChanges();
14+
expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgNotifierComponent);
15+
async.done();
16+
});
17+
}));
18+
19+
it('should initialize correctly when having a target element', injectAsync([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
20+
var template = '<div><ig-notifier widgetId="successEditor" [(options)]="opts"></ig-notifier> <input id="successEditor"/></div>';
21+
tcb.overrideTemplate(TestComponent, template)
22+
.createAsync(TestComponent)
23+
.then((fixture) => {
24+
fixture.detectChanges();
25+
expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgNotifierComponent);
26+
async.done();
27+
});
28+
}));
29+
30+
});
31+
}
32+
33+
@Component({
34+
selector: 'test-cmp',
35+
template: '<div></div>', //"Component 'TestComponent' must have either 'template' or 'templateUrl' set."
36+
directives: [Infragistics.IgNotifierComponent]
37+
})
38+
class TestComponent {
39+
private opts: any;
40+
41+
@ViewChild(Infragistics.IgNotifierComponent) public viewChild: Infragistics.IgNotifierComponent;
42+
43+
constructor() {
44+
this.opts = {
45+
contentTemplate:"<div>Test Content</div>"
46+
};
47+
}
48+
}

0 commit comments

Comments
 (0)