Skip to content

Commit 1b6ec10

Browse files
authored
Merge branch 'master' into dpetev/pickers-toggle
2 parents fe599af + 031a60b commit 1b6ec10

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

projects/igniteui-angular/migrations/common/UpdateChanges.spec.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,4 +856,51 @@ export class AppModule { }`);
856856
}
857857
});
858858
});
859+
860+
describe('Language Service migrations', () => {
861+
862+
it('Should be able to replace property of an event', () => {
863+
pending('set up tests for migrations through lang service');
864+
const membersConfig = {
865+
member: 'onGridKeydown',
866+
replaceWith: 'gridKeydown',
867+
definedIn: [
868+
'IgxGridComponent',
869+
'IgxTreeGridComponent',
870+
'IgxHierarchicalGridComponent',
871+
'IgxRowIslandComponent'
872+
]
873+
};
874+
const fileContent =
875+
`import { Component } from '@angular/core';
876+
import { IGridCreatedEventArgs } from 'igniteui-angular';
877+
@Component({
878+
selector: 'app-custom-grid',
879+
template: ''
880+
})
881+
export class CustomGridComponent {
882+
public childGridCreated(event: IGridCreatedEventArgs) {
883+
event.grid.onGridKeydown.subscribe(() => {});
884+
}
885+
}
886+
`;
887+
appTree.create('test.component.ts', fileContent);
888+
const expectedFileContent =
889+
`import { Component } from '@angular/core';
890+
import { IGridCreatedEventArgs } from 'igniteui-angular';
891+
@Component({
892+
selector: 'app-custom-grid',
893+
template: ''
894+
})
895+
export class CustomGridComponent {
896+
public childGridCreated(event: IGridCreatedEventArgs) {
897+
event.grid.gridKeydown.subscribe(() => {});
898+
}
899+
}
900+
`;
901+
const update = new UnitUpdateChanges(__dirname, appTree);
902+
update.applyChanges();
903+
expect(appTree.readContent('test.component.ts')).toEqual(expectedFileContent);
904+
});
905+
});
859906
});

projects/igniteui-angular/migrations/common/tsUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export const getTypeDefinitionAtPosition =
267267
definition.name = maybeReturnType.kind === 'className' ? maybeReturnType.text : '';
268268
return definition;
269269
}
270-
let typeDefs = getTypeDefinitions(langServ, entryPath, definition.textSpan.start);
270+
let typeDefs = getTypeDefinitions(langServ, definition.fileName || entryPath, definition.textSpan.start);
271271
// if there are no type definitions found, the identifier is a ts property, referred in an internal/external template
272272
// or is a reference in a decorator
273273
if (!typeDefs) {

projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ describe('IgxDateRangePicker', () => {
761761
fixture = TestBed.createComponent(DateRangeTwoInputsTestComponent);
762762
fixture.detectChanges();
763763
dateRange = fixture.componentInstance.dateRange;
764+
dateRange.value = { start: new Date('2/2/2020'), end: new Date('3/3/2020')};
764765
startInput = fixture.debugElement.query(By.css('input'));
765766
endInput = fixture.debugElement.queryAll(By.css('input'))[1];
766767
calendar = fixture.debugElement.query(By.css(CSS_CLASS_CALENDAR));
@@ -1139,7 +1140,8 @@ describe('IgxDateRangePicker', () => {
11391140
DateRangeTestComponent,
11401141
DateRangeDefaultComponent,
11411142
DateRangeCustomComponent,
1142-
DateRangeTemplatesComponent
1143+
DateRangeTemplatesComponent,
1144+
DateRangeTwoInputsTestComponent
11431145
],
11441146
imports: [
11451147
IgxDateRangePickerModule,
@@ -1154,6 +1156,15 @@ describe('IgxDateRangePicker', () => {
11541156
})
11551157
.compileComponents();
11561158
}));
1159+
1160+
it('should render range separator', () => {
1161+
fixture = TestBed.createComponent(DateRangeTwoInputsTestComponent);
1162+
fixture.detectChanges();
1163+
1164+
const range = fixture.debugElement.query(By.css(CSS_CLASS_DATE_RANGE));
1165+
expect(range.children[1].nativeElement.innerText).toBe('-');
1166+
});
1167+
11571168
it('should render default toggle icon', () => {
11581169
fixture = TestBed.createComponent(DateRangeDefaultComponent);
11591170
fixture.detectChanges();
@@ -1314,6 +1325,7 @@ export class DateRangeDefaultComponent extends DateRangeTestComponent {
13141325
</igx-picker-toggle>
13151326
<input igxInput igxDateTimeEditor type="text">
13161327
</igx-date-range-start>
1328+
<ng-template igxDateRangeSeparator>-</ng-template>
13171329
<igx-date-range-end>
13181330
<input igxInput igxDateTimeEditor type="text">
13191331
</igx-date-range-end>

0 commit comments

Comments
 (0)