-
Notifications
You must be signed in to change notification settings - Fork 4
Ds test coverage #2000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Ds test coverage #2000
Conversation
|
View your CI Pipeline Execution ↗ for commit 80fd336
☁️ Nx Cloud last updated this comment at |
🚀 Preview Deploy Report✅ Successfully deployed preview here |
…into ds-test-coverage
axdanbol
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to use https://testing-library.com/ to interact with components and elements in the tests instead of relying on fixture and other brittle solutions
libs/design-system/content-templates/markdown/src/lib/markdown.component.spec.ts
Outdated
Show resolved
Hide resolved
libs/design-system/content-templates/markdown/src/lib/markdown.component.spec.ts
Outdated
Show resolved
Hide resolved
libs/design-system/content-templates/markdown/src/lib/markdown.component.spec.ts
Outdated
Show resolved
Hide resolved
libs/design-system/content-templates/markdown/src/lib/markdown.component.spec.ts
Outdated
Show resolved
Hide resolved
libs/design-system/navigation/site-navigation/src/lib/site-navigation.component.spec.ts
Outdated
Show resolved
Hide resolved
| async function setup(data?: string) { | ||
| const user = userEvent.setup(); | ||
| const result = await render(MarkdownComponent, { | ||
| providers: [provideMarkdown(), provideHttpClient(), provideAnalytics()], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add provideHttpClientTesting()
| }); | ||
|
|
||
| it('should call logEvent when anchor is clicked', async () => { | ||
| const { container, fixture, user, logEventSpy } = await setup('# Test\n[Link](https://example.com)'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use container or fixture. Use screen.getBy*, etc.
| const anchor = container.querySelector('a[href="https://example.com"]') as HTMLAnchorElement; | ||
| expect(anchor).toBeTruthy(); | ||
|
|
||
| component.attachEventListeners(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should automatically be called when the markdown is rendered. Have you verified that the event doesn't fire as it should?
| expect(logEventSpy).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should push listeners when attaching event listeners', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this test
|
|
||
| it('should call unlisten functions when clearing event listeners', async () => { | ||
| const { container, fixture } = await setup('# Test\n[Link](https://example.com)'); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grab a reference to the anchor then call rerender and test that clicking the old anchor element doesn't generate a logEvent
This PR closes #1960