From 77f3ade86073543b6555d0aac6c326acc586f194 Mon Sep 17 00:00:00 2001 From: Yugay Vasiliy Date: Mon, 24 Jun 2024 08:39:31 +0000 Subject: [PATCH] copies converted text to clipboard - Test --- .../CuneiformConverterForm.test.tsx | 23 +++++++++++++++++++ .../CuneiformConverterForm.tsx | 2 -- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/chronology/ui/CuneiformConverter/CuneiformConverterForm.test.tsx b/src/chronology/ui/CuneiformConverter/CuneiformConverterForm.test.tsx index 7781a3773..de2fcb332 100644 --- a/src/chronology/ui/CuneiformConverter/CuneiformConverterForm.test.tsx +++ b/src/chronology/ui/CuneiformConverter/CuneiformConverterForm.test.tsx @@ -54,4 +54,27 @@ describe('CuneiformConverterForm', () => { expect(screen.getByLabelText('Converted Text')).toHaveValue('𒃻') }) }) + + it('copies converted text to clipboard', async () => { + signServiceMock.getUnicodeFromAtf.mockResolvedValueOnce([ + { unicode: [73979] }, + ]) + + const inputTextArea = screen.getByLabelText('input-atf') + fireEvent.change(inputTextArea, { target: { value: 'test text' } }) + + const convertButton = screen.getByText('Convert') + fireEvent.click(convertButton) + + await waitFor(() => { + expect(screen.getByLabelText('Converted Text')).toHaveValue('𒃻') + }) + + const copyButton = screen.getByText('Copy') + fireEvent.click(copyButton) + + await waitFor(() => { + expect(navigator.clipboard.writeText).toHaveBeenCalledWith('𒃻') + }) + }) }) diff --git a/src/chronology/ui/CuneiformConverter/CuneiformConverterForm.tsx b/src/chronology/ui/CuneiformConverter/CuneiformConverterForm.tsx index b4c21e4f2..95b4bb40e 100644 --- a/src/chronology/ui/CuneiformConverter/CuneiformConverterForm.tsx +++ b/src/chronology/ui/CuneiformConverter/CuneiformConverterForm.tsx @@ -61,10 +61,8 @@ function CuneiformConverterForm({ const copyToClipboard = async () => { try { await navigator.clipboard.writeText(convertedContent) - alert('Text copied to clipboard!') } catch (err) { console.error('Failed to copy text: ', err) - alert('Failed to copy text') } }