Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly restore globals in env teardown (#1774)
* fix: correctly restore globals in env teardown * test: more tests
- Loading branch information
1 parent
cbcba4f
commit 90f4995
Showing
2 changed files
with
17 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { populateGlobal } from 'vitest/src/integrations/env/utils' | ||
import { expect, test, vi } from 'vitest' | ||
|
||
test('returns valid globals', () => { | ||
const globalEvent = vi.fn() | ||
const winEvent = vi.fn() | ||
const global = { | ||
Event: globalEvent, | ||
} | ||
const win = { Event: winEvent } | ||
const { originals } = populateGlobal(global, win) | ||
expect(originals.get('Event')).toBe(globalEvent) | ||
expect(win.Event).toBe(winEvent) | ||
expect(global.Event).toBe(winEvent) | ||
}) |