Skip to content

Commit

Permalink
add test for CopyToClipboard component (#304)
Browse files Browse the repository at this point in the history
* add test for CopyToClipboard component

* modify test description
  • Loading branch information
jay-deshmukh authored Oct 20, 2023
1 parent 72832e3 commit 0239331
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/components/CopyToClipboard/CopyToClipboard.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
import CoopyToClipboard from './index';
import React from 'react';
import CopyToClipboard from './index';
import Button from '../Button'

describe('CoopyToClipboard', () => {
it('TODO', () => {
expect(true).to.equal(true);
it('Test component rendering and Test copy functionality', () => {
const textToCopy = "boooo";
const displayText = "BUTTON_TEST_NAME"
cy.mount(
<div>
<CopyToClipboard
copy={textToCopy}
display={displayText}
theme="primary"
element={Button}
onCopy={() => {
document.querySelector('.dummy').innerText = textToCopy
}}
/>
<span className='dummy'>PLACEHOLDER</span>
</div>
);
cy.get('span.dummy').invoke('text').should('eq', 'PLACEHOLDER');
cy.contains(textToCopy).should('not.exist');
cy.contains(displayText).should('exist').click()
cy.get('span.dummy').invoke('text').should('eq', textToCopy);

});
});
});

0 comments on commit 0239331

Please sign in to comment.