Skip to content

Commit cdc8a15

Browse files
committed
fix background test
1 parent cecf0ba commit cdc8a15

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tests/background.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeEach, describe, expect, it } from 'vitest'
1+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
22
import { handleCommentEvent, openSpots } from '../src/entrypoints/background'
33
import type { CommentEvent, CommentSpot } from '../src/lib/enhancer'
44

@@ -14,8 +14,13 @@ const mockSpot = {
1414
}
1515
describe('Background Event Handler', () => {
1616
beforeEach(() => {
17+
vi.useFakeTimers()
18+
vi.setSystemTime(new Date('2025-09-19T10:00:00.000Z'))
1719
openSpots.clear()
1820
})
21+
afterEach(() => {
22+
vi.useRealTimers()
23+
})
1924
describe('ENHANCED Event', () => {
2025
it('should create new comment state when textarea is enhanced', () => {
2126
handleCommentEvent(
@@ -30,7 +35,12 @@ describe('Background Event Handler', () => {
3035
[
3136
"test-key",
3237
{
33-
"drafts": [],
38+
"drafts": [
39+
[
40+
1758276000000,
41+
"",
42+
],
43+
],
3444
"sentOn": null,
3545
"spot": {
3646
"type": "TEST_SPOT",

0 commit comments

Comments
 (0)