test(common): Add test for NgForOfContext.count (#36046)

`NgForOfContext.count` is the length of the iterable.

PR Close #36046
This commit is contained in:
Keen Yee Liau 2020-03-23 17:33:39 -07:00 committed by Misko Hevery
parent 36fc28642a
commit 4f9717331d
1 changed files with 11 additions and 0 deletions

View File

@ -203,6 +203,17 @@ let thisArg: any;
detectChangesAndExpectText('0123456789');
}));
it('should display count correctly', async(() => {
const template = '<span *ngFor="let item of items; let len=count">{{len}}</span>';
fixture = createTestComponent(template);
getComponent().items = [0, 1, 2];
detectChangesAndExpectText('333');
getComponent().items = [4, 3, 2, 1, 0, -1];
detectChangesAndExpectText('666666');
}));
it('should display first item correctly', async(() => {
const template =
'<span *ngFor="let item of items; let isFirst=first">{{isFirst.toString()}}</span>';