diff --git a/src/utils/clipboard.spec.ts b/src/utils/clipboard.spec.ts index 9d7e941b..740badee 100644 --- a/src/utils/clipboard.spec.ts +++ b/src/utils/clipboard.spec.ts @@ -6,18 +6,11 @@ import { expect, describe, it, vi, beforeAll } from 'vitest' import { copyToCipboard } from './clipboard' describe('utils:clipboard', () => { - beforeAll(() => { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - window.navigator.clipboard = { - writeText: vi.fn(() => Promise.resolve()), - } - }) - it('writes to clipboard', () => { + const spy = vi.spyOn(window.navigator.clipboard, 'writeText') const prompt = vi.spyOn(window, 'prompt').mockImplementation(() => '') copyToCipboard('foo bar') - expect(window.navigator.clipboard.writeText).toBeCalledWith('foo bar') + expect(spy).toBeCalledWith('foo bar') expect(prompt).not.toBeCalled() })