-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: lazy render list and table templates (#585)
* fix: lazy render list and table templates * fix: test improvements * fix: trying to fix tests * fix: test fixes * fix: lint issue * fix: add types jest node * fix: remove types of tscondig lib * fix: remove promise frtom test * fix: build error global var * fix: lint var let issue --------- Co-authored-by: kim.tran <[email protected]> Co-authored-by: SchettlerKoehler <[email protected]> Co-authored-by: Kim Tran <[email protected]>
- Loading branch information
1 parent
f02dac2
commit cc0faea
Showing
18 changed files
with
185 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
libs/angular-testing/src/lib/mocks/IntersectionObserverMock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
export class IntersectionObserverMock { | ||
private callback: any | ||
private entries: any[] | ||
root: any | ||
rootMargin: any | ||
thresholds: any | ||
constructor(callback: any, _options: any) { | ||
this.callback = callback | ||
this.entries = [] | ||
} | ||
|
||
observe(target: Element) { | ||
const entry = { | ||
boundingClientRect: target.getBoundingClientRect(), | ||
intersectionRatio: 1, | ||
isIntersecting: true, | ||
target: target, | ||
} | ||
this.entries.push(entry) | ||
setTimeout(() => { | ||
this.callback(this.entries, this) | ||
}) | ||
} | ||
|
||
takeRecords() { | ||
return this.entries | ||
} | ||
|
||
unobserve(target: any) { | ||
this.entries = this.entries.filter((entry) => entry.target !== target) | ||
} | ||
|
||
disconnect() { | ||
this.entries = [] | ||
} | ||
} | ||
|
||
export function ensureIntersectionObserverMockExists() { | ||
if (!global.IntersectionObserver || global.IntersectionObserver !== IntersectionObserverMock) { | ||
global.IntersectionObserver = IntersectionObserverMock | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
libs/angular-testing/src/lib/utils/waitForDeferredViewsToBeRendered.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ComponentHarness, ContentContainerComponentHarness } from '@angular/cdk/testing' | ||
|
||
export async function waitForDeferredViewsToBeRendered(harness: ComponentHarness | ContentContainerComponentHarness) { | ||
return await new Promise<void>((resolve) => { | ||
setTimeout(() => { | ||
console.warn( | ||
'waitForTasksOutsideAngular has not finished within 500ms. We are not waiting any longer to not cause timeouts.' | ||
); | ||
(harness as any).forceStabilize().then(() => resolve()) | ||
}, 500) | ||
// waitForTasksOutsideAngular makes sure that the observe method of the IntersectionObserver is called for each defer block. | ||
// setTimeout makes sure that we are only continuing after the IntersectionObserverMock has called ther callback for each | ||
// defer block, because js scheduling is making sure that all methods which are scheduled via setTimeout are executed in the | ||
// respective order. This guarentees that the resolve method is called after the defer block was rendered. | ||
;(harness as any).waitForTasksOutsideAngular().then(() => setTimeout(() => resolve())) | ||
}) | ||
} |
Oops, something went wrong.