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
test(theme-common): increase filterDocCardListItems test coverage #9064
Conversation
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
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.
Thanks for the coverage 👍
Almost looks great
it('includes html items', () => { | ||
const items = [ | ||
{type: 'link', href: '/foo/bar', label: 'Foo'}, | ||
{type: 'link', href: 'bar/foo', label: 'Bar'}, | ||
{type: 'html', value: 'baz'}, | ||
]; | ||
expect(filterDocCardListItems(items)).toEqual(items); | ||
}); |
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.
maybe html items can be included in the first test case? "list of valid items"
it('filters out unlisted items', () => { | ||
const items = [ | ||
{type: 'link', href: '/foo/bar', label: 'Foo'}, | ||
{type: 'link', href: 'bar/foo', label: 'Bar'}, | ||
{type: 'link', href: '/foo/unlisted', label: 'Unlisted', unlisted: true}, | ||
]; | ||
expect(filterDocCardListItems(items)).toEqual([ | ||
{type: 'link', href: '/foo/bar', label: 'Foo'}, | ||
{type: 'link', href: 'bar/foo', label: 'Bar'}, | ||
]); | ||
}); |
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.
Maybe add other filtered item types here?
- link with no href
- category with unlisted link
- category with no href
- category having all its direct childs being filtered
it('returns original list of valid items', () => { | ||
const items = [ | ||
{type: 'link', href: '/foo/bar', label: 'Foo'}, | ||
{type: 'link', href: 'bar/foo', label: 'Bar'}, | ||
{type: 'link', href: '/foo/listed', label: 'Listed'}, | ||
]; | ||
expect(filterDocCardListItems(items)).toEqual(items); | ||
}); |
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.
maybe add html items here, and also valid categories with valid items as children
Pre-flight checklist
Motivation
I was getting the repo set up locally and looking at the test infrastructure and noticed some coverage missing for the common theme utils - I chose this package and file pretty arbitrarily just as a starting point to look at the code base. The tests added here are primarily a sanity check to make sure the behavior of this function doesn't drastically change, and it pushes up Jest's coverage for the file.
Test Plan
Test links
Deploy preview: https://deploy-preview-9064--docusaurus-2.netlify.app/
Related issues/PRs