mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-8648] Fix deprecated copy to clipboard api (#7610)
This commit is contained in:
committed by
GitHub
parent
0b2e218b88
commit
24e5893a56
@@ -54,7 +54,7 @@ describe('ClipboardService', () => {
|
||||
});
|
||||
|
||||
it('should copy text to clipboard', () => {
|
||||
spyOn(document, 'execCommand');
|
||||
spyOn(navigator.clipboard, 'writeText');
|
||||
spyOn(inputElement, 'select');
|
||||
spyOn(inputElement, 'setSelectionRange');
|
||||
|
||||
@@ -65,7 +65,7 @@ describe('ClipboardService', () => {
|
||||
expect(inputElement.select).toHaveBeenCalledWith();
|
||||
expect(inputElement.setSelectionRange)
|
||||
.toHaveBeenCalledWith(0, inputElement.value.length);
|
||||
expect(document.execCommand).toHaveBeenCalledWith('copy');
|
||||
expect(navigator.clipboard.writeText).toHaveBeenCalledWith('some text');
|
||||
});
|
||||
|
||||
it('should notify copy to clipboard with message', () => {
|
||||
@@ -76,4 +76,14 @@ describe('ClipboardService', () => {
|
||||
|
||||
expect(notificationService.openSnackMessage).toHaveBeenCalledWith('success');
|
||||
});
|
||||
|
||||
it('should copy content to clipboard', () => {
|
||||
spyOn(navigator.clipboard, 'writeText');
|
||||
spyOn(notificationService, 'openSnackMessage');
|
||||
|
||||
clipboardService.copyContentToClipboard('some text', 'some message');
|
||||
|
||||
expect(navigator.clipboard.writeText).toHaveBeenCalledWith('some text');
|
||||
expect(notificationService.openSnackMessage).toHaveBeenCalledWith('some message');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user