From d1c570756ec273a4033f0040ac88ea049038f13c Mon Sep 17 00:00:00 2001 From: Jay Date: Fri, 20 Oct 2023 10:55:58 +0530 Subject: [PATCH 1/2] add test for CopyToClipboard component --- .../CopyToClipboard/CopyToClipboard.test.js | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/components/CopyToClipboard/CopyToClipboard.test.js b/src/components/CopyToClipboard/CopyToClipboard.test.js index 86c56b2e..8af50201 100644 --- a/src/components/CopyToClipboard/CopyToClipboard.test.js +++ b/src/components/CopyToClipboard/CopyToClipboard.test.js @@ -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 Render', () => { + const textToCopy = "boooo"; + const displayText = "BUTTON_TEST_NAME" + cy.mount( +
+ { + document.querySelector('.dummy').innerText = textToCopy + }} + /> + PLACEHOLDER +
+ ); + 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); + }); -}); +}); \ No newline at end of file From b401e2ccee582168855b112c76ac9ccfb6a2282b Mon Sep 17 00:00:00 2001 From: Jay Date: Fri, 20 Oct 2023 11:32:07 +0530 Subject: [PATCH 2/2] modify test description --- src/components/CopyToClipboard/CopyToClipboard.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/CopyToClipboard/CopyToClipboard.test.js b/src/components/CopyToClipboard/CopyToClipboard.test.js index 8af50201..29277c87 100644 --- a/src/components/CopyToClipboard/CopyToClipboard.test.js +++ b/src/components/CopyToClipboard/CopyToClipboard.test.js @@ -3,7 +3,7 @@ import CopyToClipboard from './index'; import Button from '../Button' describe('CoopyToClipboard', () => { - it('Test Component Render', () => { + it('Test component rendering and Test copy functionality', () => { const textToCopy = "boooo"; const displayText = "BUTTON_TEST_NAME" cy.mount(