Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ export interface ReactJsonViewProps {

export interface OnCopyProps {
/**
* The JSON tree source object
* The value of the copied entry.
*/
src: object
src: object | string | number | boolean | null | undefined
/**
* List of keys.
*/
Expand Down
11 changes: 10 additions & 1 deletion test/tests/js/components/CopyToClipboard-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { expect } from 'chai'

import CopyToClipboard from './../../../../src/js/components/CopyToClipboard'

function copyToClipboard (src) {
function copyToClipboard (src, clickCallback) {
const copied = []
const { clipboard } = global.navigator

Expand All @@ -20,6 +20,7 @@ function copyToClipboard (src) {
src={src}
namespace={['root']}
theme='rjv-default'
clickCallback={clickCallback}
hidden={false}
/>
)
Expand Down Expand Up @@ -96,4 +97,12 @@ describe('<CopyToClipboard />', function () {
it('CopyToClipboard copies a regexp as source text', function () {
expect(copyToClipboard(/pattern/g)).to.deep.equal(['/pattern/g'])
})

it('CopyToClipboard passes a string value to clickCallback as src', function () {
const calls = []
copyToClipboard('a string', copy => calls.push(copy))
expect(calls).to.deep.equal([
{ src: 'a string', namespace: ['root'], name: 'root' }
])
})
})
Loading