-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into featTagSetShowAll
- Loading branch information
Showing
24 changed files
with
1,836 additions
and
144 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 |
---|---|---|
@@ -1,16 +1,12 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
All notable changes to this project will be documented in this file. See | ||
[Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [0.0.3](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/babel-preset-ibm-cloud-cognitive/compare/babel-preset-ibm-cloud-cognitive@[email protected]) (2020-11-17) | ||
|
||
**Note:** Version bump only for package babel-preset-ibm-cloud-cognitive | ||
|
||
|
||
|
||
|
||
|
||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. See | ||
|
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 |
---|---|---|
|
@@ -3,12 +3,20 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
# [0.2.0](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/compare/@carbon/[email protected]...@carbon/[email protected]) (2020-11-17) | ||
## [0.4.1](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/compare/@carbon/[email protected]...@carbon/[email protected]) (2020-11-23) | ||
|
||
**Note:** Version bump only for package @carbon/ibm-cloud-cognitive-cdai | ||
|
||
|
||
|
||
|
||
|
||
# [0.3.0](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/compare/@carbon/[email protected]...@carbon/[email protected]) (2020-11-23) | ||
|
||
|
||
### Features | ||
|
||
* update to carbon 10.24.0 ([#217](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/issues/217)) ([76839f3](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/commit/76839f36eca23132559c47f61d9efa0cfcd8414d)) | ||
* add cdai apikey component ([#223](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/issues/223)) ([4c09f15](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/commit/4c09f15c3c62c3965d98c91b9695fa7a1cba8f0b)) | ||
|
||
|
||
|
||
|
@@ -19,21 +27,26 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline | |
All notable changes to this project will be documented in this file. See | ||
[Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [0.1.3](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/compare/@carbon/[email protected]...@carbon/[email protected]) (2020-11-17) | ||
|
||
**Note:** Version bump only for package @carbon/ibm-cloud-cognitive-cdai | ||
# [0.2.0](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/compare/@carbon/[email protected]...@carbon/[email protected]) (2020-11-17) | ||
|
||
### Features | ||
|
||
- update to carbon 10.24.0 | ||
([#217](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/issues/217)) | ||
([76839f3](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/commit/76839f36eca23132559c47f61d9efa0cfcd8414d)) | ||
|
||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. See | ||
[Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [0.1.2](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/compare/@carbon/[email protected].1...@carbon/[email protected].2) (2020-11-17) | ||
## [0.1.3](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/compare/@carbon/[email protected].2...@carbon/[email protected].3) (2020-11-17) | ||
|
||
**Note:** Version bump only for package @carbon/ibm-cloud-cognitive-cdai | ||
|
||
## [0.1.2](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/compare/@carbon/[email protected]...@carbon/[email protected]) (2020-11-17) | ||
|
||
|
||
|
||
**Note:** Version bump only for package @carbon/ibm-cloud-cognitive-cdai | ||
|
||
## [0.1.1](https://github.com/carbon-design-system/ibm-cloud-cognitive/tree/master/packages/cdai/compare/@carbon/[email protected]...@carbon/[email protected]) (2020-11-13) | ||
|
||
|
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,21 @@ | ||
// | ||
// Copyright IBM Corp. 2020, 2020 | ||
// | ||
// This source code is licensed under the Apache-2.0 license found in the | ||
// LICENSE file in the root directory of this source tree. | ||
// | ||
|
||
export const copyToClipboard = (event, content) => { | ||
const field = document.createElement('textarea'); | ||
event.currentTarget.parentNode.appendChild(field); | ||
|
||
field.textContent = content; | ||
field.select(); | ||
document.execCommand('copy'); | ||
|
||
event.currentTarget.parentNode.removeChild(field); | ||
}; | ||
|
||
export const copyContentToClipboard = (content) => { | ||
return (event) => copyToClipboard(event, content); | ||
}; |
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,54 @@ | ||
// | ||
// Copyright IBM Corp. 2020, 2020 | ||
// | ||
// This source code is licensed under the Apache-2.0 license found in the | ||
// LICENSE file in the root directory of this source tree. | ||
// | ||
|
||
jest.unmock('./Clipboard.js'); | ||
|
||
import { copyToClipboard, copyContentToClipboard } from './Clipboard.js'; | ||
import sinon from 'sinon'; | ||
|
||
describe('Clipboard tests', () => { | ||
const sandbox = sinon.createSandbox(); | ||
|
||
beforeEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
const testEvent = { | ||
currentTarget: { | ||
parentNode: document.body, | ||
}, | ||
}; | ||
|
||
it('content is copied to clipboard', () => { | ||
const content = 'this is a test value'; | ||
let elementContent = null; | ||
document.execCommand = sinon.stub().callsFake(() => { | ||
elementContent = document.body.textContent; | ||
}); | ||
copyToClipboard(testEvent, content); | ||
|
||
expect(document.execCommand.calledOnce).toBe(true); | ||
expect(elementContent).toEqual(content); | ||
}); | ||
|
||
it('copyContentToClipboard() returns a function which copies the provided content to the clipboard', () => { | ||
// setup - define some content and stub out the execCommand function | ||
const content = 'some test content'; | ||
let elementContent = null; | ||
document.execCommand = sinon.stub().callsFake(() => { | ||
elementContent = document.body.textContent; | ||
}); | ||
|
||
let copyToClipboardFunc = copyContentToClipboard(content); | ||
// confirm we get a function back | ||
expect(typeof copyToClipboardFunc).toBe('function'); | ||
// invoke the function and confirm it calls the stubbed function with the correct content | ||
copyToClipboardFunc(testEvent); | ||
expect(document.execCommand.calledOnce).toBe(true); | ||
expect(elementContent).toEqual(content); | ||
}); | ||
}); |
Oops, something went wrong.