-
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
530 additions
and
90 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 |
---|---|---|
|
@@ -88,7 +88,7 @@ signatures. You can then run the following command to check the signature by su | |
|
||
If you do not currently have the Adoptium project's public signing key you will get a message such as this: | ||
|
||
```output | ||
```text | ||
gpg: directory '/home/sxa/.gnupg' created | ||
gpg: keybox '/home/sxa/.gnupg/pubring.kbx' created | ||
gpg: Signature made Mon Jul 4 18:20:31 2022 UTC | ||
|
@@ -104,7 +104,7 @@ example to use the Ubuntu key servers run this command: | |
|
||
If you then run the verify command you will get a message indicating that the newly imported key has not been trusted: | ||
|
||
```output | ||
```text | ||
gpg: Good signature from "Adoptium GPG Key (DEB/RPM Signing Key) | ||
<[email protected]>" [unknown] gpg: WARNING: This key is not certified | ||
with a trusted signature! gpg: There is no indication that the signature | ||
|
@@ -122,7 +122,7 @@ gpg --edit-key 3B04D753C9050D9A5D343F39843C48A565F8F04B trust | |
|
||
The verification should then succeed as follows: | ||
|
||
```output | ||
```text | ||
gpg: Signature made Mon Jul 4 18:20:31 2022 UTC | ||
gpg: using RSA key 3B04D753C9050D9A5D343F39843C48A565F8F04B | ||
gpg: checking the trustdb | ||
|
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,8 @@ | ||
import React from 'react'; | ||
import styles from './index.module.scss'; | ||
|
||
const InlineCode = ({ children }: React.PropsWithChildren): JSX.Element => ( | ||
<code className={styles.code}>{children}</code> | ||
); | ||
|
||
export default InlineCode; |
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,60 @@ | ||
import React from 'react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { vi } from 'vitest'; | ||
|
||
import CodeBox from '../index'; | ||
|
||
Object.assign(navigator, { | ||
clipboard: { | ||
writeText: vi.fn(), | ||
}, | ||
}); | ||
|
||
const navigatorClipboardSpy = vi.spyOn(navigator.clipboard, 'writeText'); | ||
|
||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
describe('Codebox component', (): void => { | ||
it('renders correctly', (): void => { | ||
const textToCopy = <p>text to be copy</p>; | ||
const { container } = render( | ||
<CodeBox> | ||
{{ | ||
props: { | ||
className: 'language-html', | ||
children: textToCopy, | ||
}, | ||
}} | ||
</CodeBox> | ||
); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders correctly', async () => { | ||
const textToCopy = <p>text to be copy</p>; | ||
|
||
render( | ||
<CodeBox> | ||
{{ | ||
props: { | ||
className: 'language-html', | ||
children: textToCopy, | ||
}, | ||
}} | ||
</CodeBox> | ||
); | ||
|
||
navigatorClipboardSpy.mockImplementationOnce(() => Promise.resolve()); | ||
|
||
const buttonElement = screen.getByText('copy'); | ||
userEvent.click(buttonElement); | ||
|
||
await screen.findByText('copied'); | ||
|
||
expect(navigatorClipboardSpy).toHaveBeenCalledTimes(1); | ||
expect(navigatorClipboardSpy).toHaveBeenCalledWith(textToCopy.toString()); | ||
}); | ||
}); |
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,16 @@ | ||
import React from 'react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import InlineCode from '../InlineCode'; | ||
|
||
describe('InlineCode component', (): void => { | ||
it('renders correctly', (): void => { | ||
const { container } = render( | ||
<InlineCode> | ||
This is some sample code | ||
</InlineCode> | ||
); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
src/components/CodeBox/__tests__/__snapshots__/CodeBox.test.tsx.snap
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,27 @@ | ||
// Vitest Snapshot v1 | ||
|
||
exports[`Codebox component > renders correctly 1`] = ` | ||
<div> | ||
<pre | ||
class="_pre_4cf629 language-html" | ||
> | ||
<div | ||
class="_top_4cf629" | ||
> | ||
<span> | ||
HTML | ||
</span> | ||
<button | ||
type="button" | ||
> | ||
copy | ||
</button> | ||
</div> | ||
<div | ||
class="_content_4cf629" | ||
> | ||
[object Object] | ||
</div> | ||
</pre> | ||
</div> | ||
`; |
11 changes: 11 additions & 0 deletions
11
src/components/CodeBox/__tests__/__snapshots__/InlineCode.test.tsx.snap
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,11 @@ | ||
// Vitest Snapshot v1 | ||
|
||
exports[`InlineCode component > renders correctly 1`] = ` | ||
<div> | ||
<code | ||
class="_code_4cf629" | ||
> | ||
This is some sample code | ||
</code> | ||
</div> | ||
`; |
Oops, something went wrong.