-
Notifications
You must be signed in to change notification settings - Fork 6
Add test cases for existing events in GitHubEventAction
component
#18
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1c521e7
add test cases for handled events
ansh-saini 6ebddb4
lint
ansh-saini 3869783
Merge branch 'uclaacm:main' into main
ansh-saini 308451a
remove extra space from PullRequestReviewCommentEvent
ansh-saini 4e01fe7
add fixtures
ansh-saini 750209f
update test to use fixtures
ansh-saini d5eb54b
rename files to be more descriptive
ansh-saini 4c2ee17
add blank lines and fix file name issue
ansh-saini b3658f2
fix failing tests
ansh-saini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,91 @@ | ||
import React from 'react'; | ||
import GitHubEventAction from '../../components/GitHubEventAction'; | ||
import createEventBranchData from '../fixtures/CreateEvent-Branch.json'; | ||
import deleteEventBranchData from '../fixtures/DeleteEvent-Branch.json'; | ||
import forkEventData from '../fixtures/ForkEvent.json'; | ||
import issueCommentEventData from '../fixtures/IssueCommentEvent.json'; | ||
import issuesEventClosedData from '../fixtures/IssuesEvent-Closed.json'; | ||
import issuesEventOpenedData from '../fixtures/IssuesEvent-Opened.json'; | ||
import pullRequestEventClosedData from '../fixtures/PullRequestEvent-Closed.json'; | ||
import pullRequestEventOpenedData from '../fixtures/PullRequestEvent-Opened.json'; | ||
import pullRequestReviewCommentEventData from '../fixtures/PullRequestReviewCommentEvent.json'; | ||
import pullRequestReviewEventData from '../fixtures/PullRequestReviewEvent.json'; | ||
import pushEventMultipleCommitsData from '../fixtures/PushEvent-MultipleCommits.json'; | ||
import pushEventSingleCommitData from '../fixtures/PushEvent-SingleCommit.json'; | ||
|
||
import { render } from '../testUtils'; | ||
|
||
|
||
const testCases = [ | ||
{ | ||
data: createEventBranchData, | ||
expectedOutput: 'created branch town-hall-f21 in', | ||
}, | ||
{ | ||
data: deleteEventBranchData, | ||
expectedOutput: 'deleted branch jedis-typo in', | ||
}, | ||
{ | ||
data: forkEventData, | ||
expectedOutput: 'forked ansh-saini/website-1 from', | ||
expectedHref: 'https://github.com/ansh-saini/website-1', | ||
}, | ||
{ | ||
data: issueCommentEventData, | ||
expectedOutput: 'commented on issue #45 in', | ||
expectedHref: 'https://github.com/uclaacm/membership-portal/pull/45', | ||
}, | ||
{ | ||
data: issuesEventOpenedData, | ||
expectedOutput: 'opened issue #106 in', | ||
expectedHref: 'https://github.com/uclaacm/icpc-website/issues/106', | ||
}, | ||
{ | ||
data: issuesEventClosedData, | ||
expectedOutput: 'closed issue #321 in', | ||
expectedHref: 'https://github.com/uclaacm/website/issues/321', | ||
}, | ||
{ | ||
data: pullRequestEventOpenedData, | ||
expectedOutput: 'opened pull request #324 in', | ||
expectedHref: 'https://github.com/uclaacm/website/pull/324', | ||
}, | ||
{ | ||
data: pullRequestEventClosedData, | ||
expectedOutput: 'closed pull request #324 in', | ||
expectedHref: 'https://github.com/uclaacm/website/pull/324', | ||
}, | ||
{ | ||
data: pullRequestReviewEventData, | ||
expectedOutput: 'reviewed pull request #262 in', | ||
expectedHref: 'https://github.com/uclaacm/hack.uclaacm.com/pull/262', | ||
}, | ||
{ | ||
data: pullRequestReviewCommentEventData, | ||
expectedOutput: 'commented on pull request #262 in', | ||
expectedHref: 'https://github.com/uclaacm/hack.uclaacm.com/pull/262#discussion_r734235143', | ||
}, | ||
{ | ||
data: pushEventSingleCommitData, | ||
expectedOutput: 'pushed 1 commit to', | ||
}, | ||
{ | ||
data: pushEventMultipleCommitsData, | ||
expectedOutput: 'pushed 2 commits to', | ||
}, | ||
]; | ||
|
||
describe('GitHub Event Action', () => { | ||
testCases.forEach(({data ,expectedOutput, expectedHref}) => { | ||
it(`renders correct string for ${data.type}`, () => { | ||
const {container} = render(<GitHubEventAction payload={data.payload} type={data.type} />, {}); | ||
|
||
const element = container.querySelector('span'); | ||
expect(element.textContent).toBe(expectedOutput); | ||
|
||
if (expectedHref) { | ||
expect(element.querySelector('a').href).toBe(expectedHref); | ||
} | ||
ansh-saini marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
}); | ||
}); |
This file contains hidden or 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,33 @@ | ||
{ | ||
"id": "18563679088", | ||
"type": "CreateEvent", | ||
"actor": { | ||
"id": 14893287, | ||
"login": "mattxwang", | ||
"display_login": "mattxwang", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/mattxwang", | ||
"avatar_url": "https://avatars.githubusercontent.com/u/14893287?" | ||
}, | ||
"repo": { | ||
"id": 103854310, | ||
"name": "uclaacm/website", | ||
"url": "https://api.github.com/repos/uclaacm/website" | ||
}, | ||
"payload": { | ||
"ref": "town-hall-f21", | ||
"ref_type": "branch", | ||
"master_branch": "main", | ||
"description": "The official website for ACM at UCLA, the largest tech community on campus!", | ||
"pusher_type": "user" | ||
}, | ||
"public": true, | ||
"created_at": "2021-10-23T01:35:29Z", | ||
"org": { | ||
"id": 8324381, | ||
"login": "uclaacm", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/orgs/uclaacm", | ||
"avatar_url": "https://avatars.githubusercontent.com/u/8324381?" | ||
} | ||
} |
This file contains hidden or 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,31 @@ | ||
{ | ||
"id": "18562886179", | ||
"type": "DeleteEvent", | ||
"actor": { | ||
"id": 15240801, | ||
"login": "dtjanaka", | ||
"display_login": "dtjanaka", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/dtjanaka", | ||
"avatar_url": "https://avatars.githubusercontent.com/u/15240801?" | ||
}, | ||
"repo": { | ||
"id": 103854310, | ||
"name": "uclaacm/website", | ||
"url": "https://api.github.com/repos/uclaacm/website" | ||
}, | ||
"payload": { | ||
"ref": "jedis-typo", | ||
"ref_type": "branch", | ||
"pusher_type": "user" | ||
}, | ||
"public": true, | ||
"created_at": "2021-10-22T22:59:22Z", | ||
"org": { | ||
"id": 8324381, | ||
"login": "uclaacm", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/orgs/uclaacm", | ||
"avatar_url": "https://avatars.githubusercontent.com/u/8324381?" | ||
} | ||
} |
This file contains hidden or 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,135 @@ | ||
{ | ||
"id": "18564222370", | ||
"type": "ForkEvent", | ||
"actor": { | ||
"id": 32511936, | ||
"login": "ansh-saini", | ||
"display_login": "ansh-saini", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/ansh-saini", | ||
"avatar_url": "https://avatars.githubusercontent.com/u/32511936?" | ||
}, | ||
"repo": { | ||
"id": 103854310, | ||
"name": "uclaacm/website", | ||
"url": "https://api.github.com/repos/uclaacm/website" | ||
}, | ||
"payload": { | ||
"forkee": { | ||
"id": 420308904, | ||
"node_id": "R_kgDOGQ1nqA", | ||
"name": "website-1", | ||
"full_name": "ansh-saini/website-1", | ||
"private": false, | ||
"owner": { | ||
"login": "ansh-saini", | ||
"id": 32511936, | ||
"node_id": "MDQ6VXNlcjMyNTExOTM2", | ||
"avatar_url": "https://avatars.githubusercontent.com/u/32511936?v=4", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/ansh-saini", | ||
"html_url": "https://github.com/ansh-saini", | ||
"followers_url": "https://api.github.com/users/ansh-saini/followers", | ||
"following_url": "https://api.github.com/users/ansh-saini/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/ansh-saini/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/ansh-saini/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/ansh-saini/subscriptions", | ||
"organizations_url": "https://api.github.com/users/ansh-saini/orgs", | ||
"repos_url": "https://api.github.com/users/ansh-saini/repos", | ||
"events_url": "https://api.github.com/users/ansh-saini/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/ansh-saini/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
}, | ||
"html_url": "https://github.com/ansh-saini/website-1", | ||
"description": "The official website for ACM at UCLA, the largest tech community on campus!", | ||
"fork": true, | ||
"url": "https://api.github.com/repos/ansh-saini/website-1", | ||
"forks_url": "https://api.github.com/repos/ansh-saini/website-1/forks", | ||
"keys_url": "https://api.github.com/repos/ansh-saini/website-1/keys{/key_id}", | ||
"collaborators_url": "https://api.github.com/repos/ansh-saini/website-1/collaborators{/collaborator}", | ||
"teams_url": "https://api.github.com/repos/ansh-saini/website-1/teams", | ||
"hooks_url": "https://api.github.com/repos/ansh-saini/website-1/hooks", | ||
"issue_events_url": "https://api.github.com/repos/ansh-saini/website-1/issues/events{/number}", | ||
"events_url": "https://api.github.com/repos/ansh-saini/website-1/events", | ||
"assignees_url": "https://api.github.com/repos/ansh-saini/website-1/assignees{/user}", | ||
"branches_url": "https://api.github.com/repos/ansh-saini/website-1/branches{/branch}", | ||
"tags_url": "https://api.github.com/repos/ansh-saini/website-1/tags", | ||
"blobs_url": "https://api.github.com/repos/ansh-saini/website-1/git/blobs{/sha}", | ||
"git_tags_url": "https://api.github.com/repos/ansh-saini/website-1/git/tags{/sha}", | ||
"git_refs_url": "https://api.github.com/repos/ansh-saini/website-1/git/refs{/sha}", | ||
"trees_url": "https://api.github.com/repos/ansh-saini/website-1/git/trees{/sha}", | ||
"statuses_url": "https://api.github.com/repos/ansh-saini/website-1/statuses/{sha}", | ||
"languages_url": "https://api.github.com/repos/ansh-saini/website-1/languages", | ||
"stargazers_url": "https://api.github.com/repos/ansh-saini/website-1/stargazers", | ||
"contributors_url": "https://api.github.com/repos/ansh-saini/website-1/contributors", | ||
"subscribers_url": "https://api.github.com/repos/ansh-saini/website-1/subscribers", | ||
"subscription_url": "https://api.github.com/repos/ansh-saini/website-1/subscription", | ||
"commits_url": "https://api.github.com/repos/ansh-saini/website-1/commits{/sha}", | ||
"git_commits_url": "https://api.github.com/repos/ansh-saini/website-1/git/commits{/sha}", | ||
"comments_url": "https://api.github.com/repos/ansh-saini/website-1/comments{/number}", | ||
"issue_comment_url": "https://api.github.com/repos/ansh-saini/website-1/issues/comments{/number}", | ||
"contents_url": "https://api.github.com/repos/ansh-saini/website-1/contents/{+path}", | ||
"compare_url": "https://api.github.com/repos/ansh-saini/website-1/compare/{base}...{head}", | ||
"merges_url": "https://api.github.com/repos/ansh-saini/website-1/merges", | ||
"archive_url": "https://api.github.com/repos/ansh-saini/website-1/{archive_format}{/ref}", | ||
"downloads_url": "https://api.github.com/repos/ansh-saini/website-1/downloads", | ||
"issues_url": "https://api.github.com/repos/ansh-saini/website-1/issues{/number}", | ||
"pulls_url": "https://api.github.com/repos/ansh-saini/website-1/pulls{/number}", | ||
"milestones_url": "https://api.github.com/repos/ansh-saini/website-1/milestones{/number}", | ||
"notifications_url": "https://api.github.com/repos/ansh-saini/website-1/notifications{?since,all,participating}", | ||
"labels_url": "https://api.github.com/repos/ansh-saini/website-1/labels{/name}", | ||
"releases_url": "https://api.github.com/repos/ansh-saini/website-1/releases{/id}", | ||
"deployments_url": "https://api.github.com/repos/ansh-saini/website-1/deployments", | ||
"created_at": "2021-10-23T04:01:56Z", | ||
"updated_at": "2021-10-23T00:15:36Z", | ||
"pushed_at": "2021-10-23T01:36:00Z", | ||
"git_url": "git://github.com/ansh-saini/website-1.git", | ||
"ssh_url": "git@github.com:ansh-saini/website-1.git", | ||
"clone_url": "https://github.com/ansh-saini/website-1.git", | ||
"svn_url": "https://github.com/ansh-saini/website-1", | ||
"homepage": "https://acm.cs.ucla.edu", | ||
"size": 111762, | ||
"stargazers_count": 0, | ||
"watchers_count": 0, | ||
"language": null, | ||
"has_issues": false, | ||
"has_projects": true, | ||
"has_downloads": true, | ||
"has_wiki": true, | ||
"has_pages": false, | ||
"forks_count": 0, | ||
"mirror_url": null, | ||
"archived": false, | ||
"disabled": false, | ||
"open_issues_count": 0, | ||
"license": { | ||
"key": "mpl-2.0", | ||
"name": "Mozilla Public License 2.0", | ||
"spdx_id": "MPL-2.0", | ||
"url": "https://api.github.com/licenses/mpl-2.0", | ||
"node_id": "MDc6TGljZW5zZTE0" | ||
}, | ||
"allow_forking": true, | ||
"is_template": false, | ||
"topics": [ | ||
|
||
], | ||
"visibility": "public", | ||
"forks": 0, | ||
"open_issues": 0, | ||
"watchers": 0, | ||
"default_branch": "main", | ||
"public": true | ||
} | ||
}, | ||
"public": true, | ||
"created_at": "2021-10-23T04:01:57Z", | ||
"org": { | ||
"id": 8324381, | ||
"login": "uclaacm", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/orgs/uclaacm", | ||
"avatar_url": "https://avatars.githubusercontent.com/u/8324381?" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.