Skip to content

Commit 49bc092

Browse files
committed
test(input): fix failing tests
1 parent 771070c commit 49bc092

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

projects/igniteui-angular/migrations/update-12_0_0/index.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,4 +1699,30 @@ export class HGridMultiRowDragComponent {
16991699
`
17001700
);
17011701
});
1702+
1703+
it('Should move disabled attribute w/ no value to igxInput', async () => {
1704+
appTree.create(
1705+
`/testSrc/appPrefix/component/test.component.html`,
1706+
`
1707+
<igx-input-group disabled>
1708+
<input igxInput [(ngModel)]="name">
1709+
</igx-input-group>
1710+
`
1711+
);
1712+
1713+
const tree = await schematicRunner
1714+
.runSchematicAsync(migrationName, {}, appTree)
1715+
.toPromise();
1716+
// this is the expected output
1717+
// putting just the disabled attribute on an igx-input-group is an invalid scenario
1718+
expect(
1719+
tree.readContent('/testSrc/appPrefix/component/test.component.html')
1720+
).toEqual(
1721+
`
1722+
<igx-input-group disabled>
1723+
<input igxInput [(ngModel)]="name" disabled>
1724+
</igx-input-group>
1725+
`
1726+
);
1727+
});
17021728
});

projects/igniteui-angular/migrations/update-12_0_0/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,12 @@ See https://www.infragistics.com/products/ignite-ui-angular/angular/components/t
493493
const matches = repTxt.match(/\/?>/g);
494494
// should always be only 1 match
495495
const lastIndex = repTxt.indexOf(matches[0]);
496+
let property =`${attr.name}`;
497+
if (attr.name === INPUT_GROUP_CHANGES.ATTRIBUTES[0] || attr.value) {
498+
property += `="${attr.value}"`;
499+
}
496500
const addedAttr =
497-
`${repTxt.substring(0, lastIndex)} ${attr.name}="${attr.value}"${repTxt.substring(lastIndex)}`;
501+
`${repTxt.substring(0, lastIndex)} ${property}${repTxt.substring(lastIndex)}`;
498502
addChange(file.url, new FileChange(startTag.start, addedAttr, repTxt, 'replace'));
499503
});
500504
}

projects/igniteui-angular/src/lib/input-group/input-group.component.spec.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ const testInputGroupType = (type: IgxInputGroupType, component: IgxInputGroupCom
353353
};
354354

355355
@Component({
356-
template: `<igx-input-group #igxInputGroup [disabled]="disabled">
357-
<input igxInput />
356+
template: `<igx-input-group #igxInputGroup>
357+
<input igxInput [disabled]="disabled"/>
358358
</igx-input-group>`
359359
})
360360
class InputGroupDisabledComponent {
@@ -368,22 +368,25 @@ class InputGroupDisabledComponent {
368368
}
369369

370370
@Component({
371-
template: `<igx-input-group #igxInputGroup disabled>
372-
<input igxInput />
371+
template: `<igx-input-group #igxInputGroup>
372+
<input igxInput disabled/>
373373
</igx-input-group>`
374374
})
375375
class InputGroupDisabledWithoutValueComponent {
376376
@ViewChild('igxInputGroup')
377377
public igxInputGroup: IgxInputGroupComponent;
378378

379+
@ViewChild(IgxInputDirective)
380+
public inputDir: IgxInputDirective;
381+
379382
public changeDisableState() {
380-
this.igxInputGroup.disabled = !this.igxInputGroup.disabled;
383+
this.inputDir.disabled = !this.inputDir.disabled;
381384
}
382385
}
383386

384387
@Component({
385-
template: `<igx-input-group #igxInputGroup [disabled]="disabled">
386-
<input igxInput />
388+
template: `<igx-input-group #igxInputGroup>
389+
<input igxInput [disabled]="disabled"/>
387390
</igx-input-group>`
388391
})
389392
class InputGroupDisabledByDefaultComponent {

0 commit comments

Comments
 (0)