diff --git a/resources/assets/js/__tests__/setup.ts b/resources/assets/js/__tests__/setup.ts index d1edcd5b..220e4f6a 100644 --- a/resources/assets/js/__tests__/setup.ts +++ b/resources/assets/js/__tests__/setup.ts @@ -56,3 +56,9 @@ window.SSO_PROVIDERS = [] window.createLemonSqueezy = vi.fn() Axios.defaults.adapter = vi.fn() + +Object.assign(navigator, { + clipboard: { + writeText: vi.fn() + } +}) diff --git a/resources/assets/js/components/playlist/InvitePlaylistContributors.spec.ts b/resources/assets/js/components/playlist/InvitePlaylistContributors.spec.ts index 7a25848a..133d8563 100644 --- a/resources/assets/js/components/playlist/InvitePlaylistContributors.spec.ts +++ b/resources/assets/js/components/playlist/InvitePlaylistContributors.spec.ts @@ -9,7 +9,6 @@ new class extends UnitTestCase { protected test () { it('works', async () => { this.mock(playlistCollaborationService, 'createInviteLink').mockResolvedValue('http://localhost:3000/invite/1234') - const writeTextMock = this.mock(navigator.clipboard, 'writeText') const playlist = factory('playlist') this.render(Component, { @@ -21,7 +20,7 @@ new class extends UnitTestCase { await this.user.click(screen.getByText('Invite')) await waitFor(async () => { - expect(writeTextMock).toHaveBeenCalledWith('http://localhost:3000/invite/1234') + expect(navigator.clipboard.writeText).toHaveBeenCalledWith('http://localhost:3000/invite/1234') screen.getByText('Link copied to clipboard!') }) })