-
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/GithubBuildShaLink #4669
- Loading branch information
Showing
3 changed files
with
79 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
|
||
import GithubBuildShaLink from './GithubBuildShaLink'; | ||
|
||
const defaultBuild = { | ||
clonedCommitSha: 'cloned_sha', | ||
requestedCommitSha: 'requested_sha' | ||
} | ||
const defaultSite = { | ||
owner: 'repo_owner', | ||
repository: 'repo_name' | ||
}; | ||
const defaultProps = {...{ build: defaultBuild, site: defaultSite}} | ||
|
||
describe('<GithubBuildShaLink/>', () => { | ||
it('renders', () => { | ||
const props = {...defaultProps}; | ||
render(<GithubBuildShaLink {...props} />); | ||
|
||
const anchor = screen.getByRole('link'); | ||
expect(anchor).toHaveClass('sha-link'); | ||
expect(anchor).toHaveAttribute('title', 'View commit on GitHub'); | ||
|
||
}); | ||
it('uses clonedCommitSha by default, if provided', () => { | ||
const props = {...defaultProps}; | ||
render(<GithubBuildShaLink {...props} />); | ||
|
||
const anchor = screen.getByRole('link'); | ||
|
||
expect(anchor).toHaveAttribute('href', 'https://github.com/repo_owner/repo_name/commit/cloned_sha'); | ||
expect(anchor).toHaveTextContent('cloned_'); | ||
|
||
}); | ||
it('uses requestedCommitSha if clonedCommitSha is not provided', () => { | ||
const props = {...{ build: { requestedCommitSha: '1234567890'}, site: defaultSite}}; | ||
render(<GithubBuildShaLink {...props} />); | ||
|
||
const anchor = screen.getByRole('link'); | ||
|
||
expect(anchor).toHaveAttribute('href', 'https://github.com/repo_owner/repo_name/commit/1234567890'); | ||
expect(anchor).toHaveTextContent('1234567'); | ||
|
||
}); | ||
it('renders nothing if no sha is provided', () => { | ||
const props = {...{ build: {}, site: defaultSite}}; | ||
const { container } = render(<GithubBuildShaLink {...props} />); | ||
expect(container.innerHTML).toBe(''); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -1827,6 +1827,17 @@ | |
dependencies: | ||
"@bull-board/api" "6.5.3" | ||
|
||
"@cfaester/enzyme-adapter-react-18@^0.8.0": | ||
version "0.8.0" | ||
resolved "https://registry.yarnpkg.com/@cfaester/enzyme-adapter-react-18/-/enzyme-adapter-react-18-0.8.0.tgz#313814eb79658a6e74209f9f1743bcefff14a46f" | ||
integrity sha512-3Z3ThTUouHwz8oIyhTYQljEMNRFtlVyc3VOOHCbxs47U6cnXs8K9ygi/c1tv49s7MBlTXeIcuN+Ttd9aPtILFQ== | ||
dependencies: | ||
enzyme-shallow-equal "^1.0.0" | ||
function.prototype.name "^1.1.6" | ||
has "^1.0.4" | ||
react-is "^18.2.0" | ||
react-shallow-renderer "^16.15.0" | ||
|
||
"@colors/[email protected]": | ||
version "1.5.0" | ||
resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" | ||
|
@@ -5585,7 +5596,7 @@ envinfo@^7.7.3: | |
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.14.0.tgz#26dac5db54418f2a4c1159153a0b2ae980838aae" | ||
integrity sha512-CO40UI41xDQzhLB1hWyqUKgFhs250pNcGbyGKe1l/e4FSaI/+YE4IMG76GDt0In67WLPACIITC+sOi08x4wIvg== | ||
|
||
enzyme-shallow-equal@^1.0.1: | ||
enzyme-shallow-equal@^1.0.0, enzyme-shallow-equal@^1.0.1: | ||
version "1.0.7" | ||
resolved "https://registry.yarnpkg.com/enzyme-shallow-equal/-/enzyme-shallow-equal-1.0.7.tgz#4e3aa678022387a68e6c47aff200587851885b5e" | ||
integrity sha512-/um0GFqUXnpM9SvKtje+9Tjoz3f1fpBC3eXRFrNs8kpYn69JljciYP7KZTqM/YQbUY9KUjvKB4jo/q+L6WGGvg== | ||
|
@@ -6896,7 +6907,7 @@ has-tostringtag@^1.0.0, has-tostringtag@^1.0.2: | |
dependencies: | ||
has-symbols "^1.0.3" | ||
|
||
has@^1.0.3: | ||
has@^1.0.3, has@^1.0.4: | ||
version "1.0.4" | ||
resolved "https://registry.yarnpkg.com/has/-/has-1.0.4.tgz#2eb2860e000011dae4f1406a86fe80e530fb2ec6" | ||
integrity sha512-qdSAmqLF6209RFj4VVItywPMbm3vWylknmB3nvNiUIs72xAimcM8nVYxYr7ncvZq5qzk9MKIZR8ijqD/1QuYjQ== | ||
|
@@ -9784,6 +9795,11 @@ react-highlight@^0.15.0: | |
dependencies: | ||
highlight.js "^10.5.0" | ||
|
||
"react-is@^16.12.0 || ^17.0.0 || ^18.0.0", react-is@^18.0.0, react-is@^18.2.0: | ||
version "18.3.1" | ||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.3.1.tgz#e83557dc12eae63a99e003a46388b1dcbb44db7e" | ||
integrity sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg== | ||
|
||
react-is@^16.13.1, react-is@^16.4.2, react-is@^16.7.0: | ||
version "16.13.1" | ||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" | ||
|
@@ -9794,11 +9810,6 @@ react-is@^17.0.1, react-is@^17.0.2: | |
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" | ||
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== | ||
|
||
react-is@^18.0.0: | ||
version "18.3.1" | ||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.3.1.tgz#e83557dc12eae63a99e003a46388b1dcbb44db7e" | ||
integrity sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg== | ||
|
||
react-notification-system-redux@^2.0.1: | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/react-notification-system-redux/-/react-notification-system-redux-2.0.1.tgz#e1f47e788d344fac9b5183402bb96c73033e5854" | ||
|
@@ -9843,6 +9854,14 @@ [email protected]: | |
dependencies: | ||
"@remix-run/router" "1.21.0" | ||
|
||
react-shallow-renderer@^16.15.0: | ||
version "16.15.0" | ||
resolved "https://registry.yarnpkg.com/react-shallow-renderer/-/react-shallow-renderer-16.15.0.tgz#48fb2cf9b23d23cde96708fe5273a7d3446f4457" | ||
integrity sha512-oScf2FqQ9LFVQgA73vr86xl2NaOIX73rh+YFqcOp68CWj56tSfgtGKrEbyhCj0rSijyG9M1CYprTh39fBi5hzA== | ||
dependencies: | ||
object-assign "^4.1.1" | ||
react-is "^16.12.0 || ^17.0.0 || ^18.0.0" | ||
|
||
react@^18.2.0: | ||
version "18.3.1" | ||
resolved "https://registry.yarnpkg.com/react/-/react-18.3.1.tgz#49ab892009c53933625bd16b2533fc754cab2891" | ||
|