diff --git a/lib/core/clipboard/clipboard.directive.spec.ts b/lib/core/clipboard/clipboard.directive.spec.ts index 36700a148a..17f84ee1a3 100644 --- a/lib/core/clipboard/clipboard.directive.spec.ts +++ b/lib/core/clipboard/clipboard.directive.spec.ts @@ -121,20 +121,20 @@ describe('CopyClipboardDirective', () => { it('should copy the content of element when click it', fakeAsync(() => { const spanHTMLElement = element.querySelector('span'); fixture.detectChanges(); - spyOn(document, 'execCommand'); + spyOn(navigator.clipboard, 'writeText'); spanHTMLElement.dispatchEvent(new Event('click')); tick(); fixture.detectChanges(); - expect(document.execCommand).toHaveBeenCalledWith('copy'); + expect(navigator.clipboard.writeText).toHaveBeenCalledWith('text to copy'); })); it('should not copy the content of element when click it', fakeAsync(() => { const spanHTMLElement = element.querySelector('span'); fixture.detectChanges(); - spyOn(document, 'execCommand'); + spyOn(navigator.clipboard, 'writeText'); spanHTMLElement.dispatchEvent(new Event('mouseleave')); tick(); fixture.detectChanges(); - expect(document.execCommand).not.toHaveBeenCalled(); + expect(navigator.clipboard.writeText).not.toHaveBeenCalled(); })); });