test(core): rework built-in repeter track fn tests#51903
test(core): rework built-in repeter track fn tests#51903pkozlowski-opensource wants to merge 1 commit intoangular:mainfrom
Conversation
Rework existing tests so those do NOT depend on the number of calls to the tracking function.
| trackingFn(index: number, items: string[]) { | ||
| return items[index]; |
There was a problem hiding this comment.
WDYT about extending this a bit with
| trackingFn(index: number, items: string[]) { | |
| return items[index]; | |
| trackingFn(index: number, items: string[]) { | |
| trackByCalled = true; | |
| expect(typeof index).toBe('number'); | |
| expect(items).toBe(this.items); | |
| return items[index]; |
and then verifying that trackByCalled is indeed true after rendering, as the current tests would also work if the tracking function is never invoked at all.
There was a problem hiding this comment.
Or perhaps better yet would be to maintain a Map<number, string[]> to track all indices and their items value, which should end up containing three items.
There was a problem hiding this comment.
Have an alternative (but also deduping approach in #51980)
|
|
||
| const fixture = TestBed.createComponent(TestComponent); | ||
| fixture.detectChanges(); | ||
| expect(calls).toEqual([ |
There was a problem hiding this comment.
What I was trying to capture with these tests was that the correct value is passed into the function since we have some special logic around how we generate the function. I don't think that the new tests capture that behavior anymore.
There was a problem hiding this comment.
Have an alternative approach in #51980.
WDYT?
|
Will be tackled as part of #51980 |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Rework existing tests so those do NOT depend on the number of calls to the tracking function.