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

Add test cases for existing events in GitHubEventAction component #18

Merged
merged 9 commits into from
Oct 26, 2021

Conversation

ansh-saini
Copy link
Contributor

@ansh-saini ansh-saini commented Oct 15, 2021

Closes #16

Hi, I've setup a basic framework for testing events in this component. For future development, we can just keep adding more objects in the testCases array with the expected output. I've added a testContext key (optional) which can be used to give more context to the test name. Like handling singular and plural cases etc...

I've kept the payload minimal to avoid bloating the file with lots of data. That would've made writing new test cases harder. I would love to know your thoughts on this approach.

Copy link
Member

@mattxwang mattxwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Ansh, thank you for your contribution! As-is, this looks good. However, I have a few questions for you:

  • I'd like to test the content of the links as well (i.e. the href), to see if we properly interpret the API. Is this something you could add to this PR?
  • As we add more events, I think inlining everything in the test file itself is probably not sustainable. In addition, we're currently testing a fragment of the data returned, rather than the entire input. Could we:
    • move all the test input data (the "fixtures") to their own file(s)? I think one file per test fixture may make sense, but feel free to give me feedback on this idea.
    • include the entire GitHub API response in the test fixture? instead of just the data that we'd need

@ansh-saini
Copy link
Contributor Author

Hey, thanks for the review.
We can definitely add tests for the href attribute.
I like the fixtures approach too. It's more maintainable in the long run.

I'll be working on these on the weekend.

Copy link
Member

@mattxwang mattxwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Ansh, looks good! I've left some very minor (naming-related) comments, but other than that we're in pretty good shape to merge. Thanks for all your work so far!

(p.s. - can you add newlines to the end of your JSON files? leads to clean diffs!)

components/GitHubEventAction.tsx Show resolved Hide resolved
test/components/GitHubEventAction.test.tsx Show resolved Hide resolved
test/fixtures/createEvent.json Outdated Show resolved Hide resolved
test/fixtures/deleteEvent.json Outdated Show resolved Hide resolved
test/fixtures/issuesEvent.json Outdated Show resolved Hide resolved
test/fixtures/pullRequestEvent.json Outdated Show resolved Hide resolved
Copy link
Member

@mattxwang mattxwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Nice job Ansh, the contribution is much appreciated. I'll go ahead and merge.

@mattxwang mattxwang merged commit c60dedf into uclaacm:main Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write tests for the existing <GitHubEventAction /> behaviour
2 participants