Skip to content
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

Closed

Conversation

dunnkevin
Copy link

@dunnkevin dunnkevin commented Jun 13, 2023

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

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

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 13, 2023
@netlify
Copy link

netlify bot commented Jun 13, 2023

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 309acc5
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/64880145885b1c00087e57e4
😎 Deploy Preview https://deploy-preview-9064--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 88 🟢 97 🟢 92 🟢 100 🟠 89 Report
/docs/installation 🟠 76 🟢 100 🟢 92 🟢 100 🟠 89 Report

Copy link
Collaborator

@slorber slorber left a 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

Comment on lines +787 to +794
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);
});
Copy link
Collaborator

@slorber slorber Jun 14, 2023

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"

Comment on lines +776 to +786
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'},
]);
});
Copy link
Collaborator

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

@slorber slorber changed the title test(docusaurus-theme-common) Adding filterDocCardListItems coverage test(theme-common): increase filterDocCardListItems test coverage Jun 14, 2023
Comment on lines +768 to +775
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);
});
Copy link
Collaborator

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

@dunnkevin dunnkevin closed this Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants