-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Test shared/GithubBuildBranchLink #4670
- Loading branch information
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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,35 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
|
||
import GithubBuildBranchLink from './GithubBuildBranchLink'; | ||
|
||
const defaultBuild = { | ||
branch: 'branch_name', | ||
} | ||
const defaultSite = { | ||
owner: 'repo_owner', | ||
repository: 'repo_name' | ||
}; | ||
const defaultProps = {...{ build: defaultBuild, site: defaultSite}} | ||
|
||
describe('<GithubBuildBranchLink/>', () => { | ||
it('renders', () => { | ||
const props = {...defaultProps}; | ||
render(<GithubBuildBranchLink {...props} />); | ||
|
||
const anchor = screen.getByRole('link'); | ||
|
||
expect(anchor).toHaveClass('branch-link'); | ||
expect(anchor).toHaveAttribute('title', 'View branch on GitHub'); | ||
}); | ||
it('uses the build’s branch and the site’s repo and owner', () => { | ||
const props = {...defaultProps}; | ||
render(<GithubBuildBranchLink {...props} />); | ||
|
||
const anchor = screen.getByRole('link'); | ||
|
||
expect(anchor).toHaveAttribute('href', 'https://github.com/repo_owner/repo_name/tree/branch_name'); | ||
expect(anchor).toHaveTextContent('branch_name'); | ||
}); | ||
}); |