From 070678274782410284e26b117298f0603bff2813 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 9 Nov 2023 14:29:05 +0100 Subject: [PATCH] fix: Adjust node tests for changed happy-dom Signed-off-by: Ferdinand Thiessen --- src/utils/clipboard.spec.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) 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() })