Skip to content

Commit ab3a17b

Browse files
committed
fix(*): fixing tests
1 parent 59ffc8c commit ab3a17b

File tree

6 files changed

+81
-56
lines changed

6 files changed

+81
-56
lines changed

projects/igniteui-angular-wrappers/src/lib/igcombo/igcombo.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ export class IgComboComponent extends IgControlBase<IgCombo> implements ControlV
311311
* @param event Indicates the browser event which triggered this action (not API). Calling the method with this param set to "true" will trigger [selectionChanging](ui.igcombo#events:selectionChanging) and [selectionChanged](ui.igcombo#events:selectionChanged) events.
312312
*/
313313
/* istanbul ignore next */
314-
public value(value?: object, options?: object, event?: object): object { return; }
314+
public value(value?: object, options?: object, event?: object): any { return; }
315315

316316
/**
317317
* Selects a list item from the drop-down list.

projects/igniteui-angular-wrappers/src/lib/igcontrolbase/igcontrolbase.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
import { ElementRef, EventEmitter, IterableDiffers, DoCheck, SimpleChanges, Input, ChangeDetectorRef, KeyValueDiffers, Renderer2, Directive } from '@angular/core';
1+
import {
2+
ElementRef,
3+
EventEmitter,
4+
IterableDiffers,
5+
DoCheck,
6+
SimpleChanges,
7+
Input,
8+
ChangeDetectorRef,
9+
KeyValueDiffers,
10+
Renderer2,
11+
Directive,
12+
OnInit
13+
} from '@angular/core';
214

315
declare var jQuery: any;
416

@@ -48,7 +60,7 @@ const NODES = {
4860
};
4961

5062
@Directive()
51-
export class IgControlBase<Model> implements DoCheck {
63+
export class IgControlBase<Model> implements DoCheck, OnInit {
5264
@Input()
5365
public options: any = {};
5466

@@ -63,16 +75,19 @@ export class IgControlBase<Model> implements DoCheck {
6375
private _nativeElement: any;
6476
public widgetId: string;
6577

66-
constructor(el: ElementRef, renderer: Renderer2, differs: IterableDiffers, public kvalDiffers: KeyValueDiffers, public cdr: ChangeDetectorRef) {
78+
constructor(el: ElementRef, renderer: Renderer2, differs: IterableDiffers,
79+
public kvalDiffers: KeyValueDiffers, public cdr: ChangeDetectorRef) {
6780
this._differs = differs;
6881
this._nativeElement = el.nativeElement;
6982
this._widgetName = this.convertToCamelCase(el.nativeElement.nodeName.toLowerCase()); // ig-grid -> igGrid
7083
this._el = el.nativeElement.appendChild(document.createElement(NODES[el.nativeElement.nodeName.toLowerCase()]));
7184

7285
for (const propt in jQuery.ui[this._widgetName].prototype.events) {
86+
if (jQuery.ui[this._widgetName].prototype.events.hasOwnProperty(propt)) {
7387
this[propt] = new EventEmitter();
7488
// cahcing the event emmitters for cases when the event name is the same as a method name.
7589
this._evtEmmiters[propt] = this[propt];
90+
}
7691
}
7792
}
7893

@@ -105,7 +120,7 @@ export class IgControlBase<Model> implements DoCheck {
105120

106121
for (const opt in jQuery.ui[this._widgetName].prototype.options) {
107122
if (opt !== 'dataSource') {
108-
object.defineProperty(this, opt, {
123+
Object.defineProperty(this, opt, {
109124
set: this.createSetter(opt),
110125
enumerable: true,
111126
configurable: true
@@ -117,19 +132,21 @@ export class IgControlBase<Model> implements DoCheck {
117132
for (const name in propNames) {
118133
if (name.indexOf('_') !== 0 && typeof jQuery.ui[this._widgetName].prototype[name] === 'function'
119134
&& name !== 'dataSource') {
120-
object.defineProperty(that, name, {
135+
Object.defineProperty(that, name, {
121136
get: that.createMethodGetter(name)
122137
});
123138
}
124139
}
125140
// events binding
126141
for (const propt in jQuery.ui[this._widgetName].prototype.events) {
142+
if (jQuery.ui[this._widgetName].prototype.events.hasOwnProperty(propt)) {
127143
evtName = this._widgetName.toLowerCase() + propt.toLowerCase();
128144
this._events[evtName] = propt;
129-
jQuery(this._el).on(evtName, function(evt, ui) {
145+
jQuery(this._el).on(evtName, (evt, ui) => {
130146
const emmiter = that._evtEmmiters[that._events[evt.type]];
131147
emmiter.emit({ event: evt, ui });
132148
});
149+
}
133150
}
134151

135152
jQuery(this._el).attr('id', this.widgetId);

projects/igniteui-angular-wrappers/src/lib/iggrid/column.directive.ts

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,47 @@ import { ElementRef, Directive } from '@angular/core';
33
declare var jQuery: any;
44

55
@Directive({
6-
selector: 'column',
7-
inputs: ['headerText', 'key', 'formatter', 'format', 'dataType', 'width', 'hidden', 'template', 'unbound', 'group', 'rowspan', 'formula', 'unboundValues', 'unboundValuesUpdateMode', 'headerCssClass', 'columnCssClass']
6+
selector: 'column',
7+
inputs: ['headerText', 'key', 'formatter', 'format', 'dataType', 'width', 'hidden', 'template', 'unbound', 'group', 'rowspan', 'formula', 'unboundValues', 'unboundValuesUpdateMode', 'headerCssClass', 'columnCssClass']
88
})
99
export class Column {
10-
public _settings: any = {};
11-
private _el: any;
10+
public _settings: any = {};
11+
private _el: any;
1212

13-
constructor(el: ElementRef) {
14-
this._el = el;
15-
const self = this;
16-
let i, settings = ['headerText', 'key', 'formatter', 'format', 'dataType', 'width', 'hidden', 'template', 'unbound', 'group', 'rowspan', 'formula', 'unboundValues', 'unboundValuesUpdateMode', 'headerCssClass', 'columnCssClass'];
17-
for (i = 0; i < settings.length; i++) {
18-
object.defineProperty(self, settings[i], {
19-
set: self.createColumnsSetter(settings[i]),
20-
get: self.createColumnsGetter(settings[i]),
21-
enumerable: true,
22-
configurable: true
23-
});
24-
}
25-
}
13+
constructor(el: ElementRef) {
14+
this._el = el;
15+
const self = this;
16+
let i;
17+
const settings = ['headerText', 'key', 'formatter', 'format', 'dataType', 'width', 'hidden', 'template', 'unbound', 'group', 'rowspan', 'formula', 'unboundValues', 'unboundValuesUpdateMode', 'headerCssClass', 'columnCssClass'];
18+
for (i = 0; i < settings.length; i++) {
19+
Object.defineProperty(self, settings[i], {
20+
set: self.createColumnsSetter(settings[i]),
21+
get: self.createColumnsGetter(settings[i]),
22+
enumerable: true,
23+
configurable: true
24+
});
25+
}
26+
}
2627

27-
createColumnsSetter(name) {
28-
return function(value) {
29-
const grid = jQuery(this._el.nativeElement.parentElement).find('table[role=\'grid\']');
30-
const columns = grid.igGrid('option', 'columns');
31-
this._settings[name] = value;
28+
createColumnsSetter(name) {
29+
return function(value) {
30+
const grid = jQuery(this._el.nativeElement.parentElement).find('table[role=\'grid\']');
31+
const columns = grid.igGrid('option', 'columns');
32+
this._settings[name] = value;
3233

33-
if (jQuery.ui.igGrid &&
34-
jQuery.ui.igGrid.prototype.options &&
35-
jQuery.ui.igGrid.prototype.options.hasOwnProperty('columns') &&
36-
grid.data('igGrid')) {
37-
// reapply all column settings when a column setting is changed
38-
grid.igGrid('option', 'columns', columns);
39-
}
40-
};
41-
}
34+
if (jQuery.ui.igGrid &&
35+
jQuery.ui.igGrid.prototype.options &&
36+
jQuery.ui.igGrid.prototype.options.hasOwnProperty('columns') &&
37+
grid.data('igGrid')) {
38+
// reapply all column settings when a column setting is changed
39+
grid.igGrid('option', 'columns', columns);
40+
}
41+
};
42+
}
4243

43-
createColumnsGetter(name) {
44-
return () => {
45-
return this._settings[name];
46-
};
47-
}
44+
createColumnsGetter(name) {
45+
return () => {
46+
return this._settings[name];
47+
};
48+
}
4849
}

projects/igniteui-angular-wrappers/src/lib/iggrid/feature.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ export class Feature<Model> {
5050
});
5151
}
5252
for (const setting in jQuery.ui[this.featureName].prototype.options) {
53-
object.defineProperty(self, setting, {
53+
Object.defineProperty(self, setting, {
5454
set: self.createFeatureSetter(setting),
5555
get: self.createFeatureGetter(setting),
5656
enumerable: true,
5757
configurable: true
5858
});
5959
}
60-
const propNames = object.getOwnPropertyNames(jQuery.ui[this.featureName].prototype);
60+
const propNames = Object.getOwnPropertyNames(jQuery.ui[this.featureName].prototype);
6161
for (let i = 0; i < propNames.length; i++) {
6262
const name = propNames[i];
6363
if (name.indexOf('_') !== 0 && typeof jQuery.ui[this.featureName].prototype[name] === 'function') {
64-
object.defineProperty(self, name, {
64+
Object.defineProperty(self, name, {
6565
get: self.createMethodGetter(name)
6666
});
6767
}

projects/igniteui-angular-wrappers/src/lib/iggrid/iggrid.component.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,18 +292,20 @@ export class IgGridComponent extends IgGridBase<IgGrid> {
292292
public activeRow(): object { return; }
293293

294294
/**
295-
* Retrieves a cell value using the row index and the column key. If a primaryKey is defined, rowId is assumed to be the row Key (not index).
296-
* If primary key is not defined, then rowId is converted to a number and is used as a row index.
295+
* Retrieves a cell value using the row index and the column key.
296+
* If a primaryKey is defined, rowId is assumed to be the row Key (not index).
297+
* If primary key is not defined, then rowId is converted to a number and is used as a row index.
297298
*
298299
* @param rowId Row index or row key (primary key).
299300
* @param colKey The column key.
300301
*/
301302
/* istanbul ignore next */
302-
public getCellValue(rowId: object, colKey: string): object { return; }
303+
public getCellValue(rowId: any, colKey: string): any { return; }
303304

304305
/**
305-
* Returns the cell text. If colKey is a number, the index of the column is used (instead of a column name)- does not apply when using a Multi-Row Layout grid.
306-
* This is the actual text (or HTML string) for the contents of the cell.
306+
* Returns the cell text. If colKey is a number, the index of the column is used (instead of a column name)
307+
* - does not apply when using a Multi-Row Layout grid.
308+
* This is the actual text (or HTML string) for the contents of the cell.
307309
*
308310
* @param rowId Row index or row data key (primary key)
309311
* @param colKey Column key.
@@ -312,7 +314,8 @@ export class IgGridComponent extends IgGridBase<IgGrid> {
312314
public getCellText(rowId: object, colKey: string): string { return; }
313315

314316
/**
315-
* Sets a new template for a column after initialization and renders the grid if not explicitly disabled. This method will replace any existing explicitly set row template and will build one anew from the column ones.
317+
* Sets a new template for a column after initialization and renders the grid if not explicitly disabled.
318+
* This method will replace any existing explicitly set row template and will build one anew from the column ones.
316319
*
317320
* @param col An identifier of the column to set template for (index or key)
318321
* @param tmpl The column template to set
@@ -322,15 +325,19 @@ export class IgGridComponent extends IgGridBase<IgGrid> {
322325
public setColumnTemplate(col: object, tmpl: string, render?: boolean): void { return; }
323326

324327
/**
325-
* Commits all pending transactions to the client data source. Note that there won't be anything to commit on the UI, since it is updated instantly. In order to rollback the actual UI, a call to dataBind() is required.
328+
* Commits all pending transactions to the client data source.
329+
* Note that there won't be anything to commit on the UI, since it is updated instantly.
330+
* In order to rollback the actual UI, a call to dataBind() is required.
326331
*
327332
* @param rowId If specified, will commit only that transaction corresponding to the specified record key.
328333
*/
329334
/* istanbul ignore next */
330335
public commit(rowId?: object): void { return; }
331336

332337
/**
333-
* Clears the transaction log (delegates to igDataSource). Note that this does not update the UI. In case the UI must be updated, set the second parameter "updateUI" to true, which will trigger a call to dataBind() to re-render the contents.
338+
* Clears the transaction log (delegates to igDataSource). Note that this does not update the UI.
339+
* In case the UI must be updated, set the second parameter "updateUI" to true,
340+
* which will trigger a call to dataBind() to re-render the contents.
334341
*
335342
* @param rowId If specified, will only rollback the transactions with that row id.
336343
* @param updateUI Whether to update the UI or not.

projects/igniteui-angular-wrappers/src/lib/iggrid/iggridfeatures/iggridupdating.directive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class IgGridUpdatingFeature extends Feature<IgGridUpdating> {
3030
* @param values Pairs of values in the format { column1Key: value1, column2Key: value2, ... } .
3131
*/
3232
/* istanbul ignore next */
33-
public updateRow(rowId: object, values: object): void { return; }
33+
public updateRow(rowId: any, values: object): void { return; }
3434

3535
/**
3636
* Adds a new row to the grid. It also creates a transaction and updates the UI.
@@ -46,7 +46,7 @@ export class IgGridUpdatingFeature extends Feature<IgGridUpdating> {
4646
* @param rowId The primary key of the row to delete.
4747
*/
4848
/* istanbul ignore next */
49-
public deleteRow(rowId: object): void { return; }
49+
public deleteRow(rowId: any): void { return; }
5050

5151
/**
5252
* Starts editing for the row or cell specified (depending on the [editMode](ui.iggridupdating#options:editMode)).

0 commit comments

Comments
 (0)