Skip to content

Commit

Permalink
Merge branch 'master' into featTagSetShowAll
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-chase authored Nov 23, 2020
2 parents f4abed4 + cefe023 commit 83fe55f
Show file tree
Hide file tree
Showing 24 changed files with 1,836 additions and 144 deletions.
8 changes: 2 additions & 6 deletions packages/babel-preset-ibm-cloud-cognitive/CHANGELOG.md
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
Expand Down
29 changes: 21 additions & 8 deletions packages/cdai/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))



Expand All @@ -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)

Expand Down
6 changes: 4 additions & 2 deletions packages/cdai/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "@carbon/ibm-cloud-cognitive-cdai",
"private": true,
"description": "Carbon for Cloud & Cognitive CD&AI UI components",
"version": "0.2.0",
"version": "0.4.1",
"license": "Apache-2.0",
"main": "lib/index.js",
"module": "es/index.js",
Expand All @@ -20,6 +19,9 @@
"carbon for cloud & cognitive",
"cdai"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"storybook": "start-storybook -p 6006",
"build": "node scripts/build.js"
Expand Down
21 changes: 21 additions & 0 deletions packages/cdai/src/component_helpers/Clipboard.js
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);
};
54 changes: 54 additions & 0 deletions packages/cdai/src/component_helpers/Clipboard.spec.js
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);
});
});
Loading

0 comments on commit 83fe55f

Please sign in to comment.