Skip to content

Commit

Permalink
fix: Adjust node tests for changed happy-dom
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Nov 9, 2023
1 parent f0dea21 commit 0706782
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/utils/clipboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down

0 comments on commit 0706782

Please sign in to comment.