Skip to content

Commit 42eada6

Browse files
committed
test: remove redundant fake timer setup
Amp-Thread-ID: https://ampcode.com/threads/T-019feeff-305b-73a5-bb82-3ae3a74e816d
1 parent d526dfe commit 42eada6

73 files changed

Lines changed: 22 additions & 219 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/desktop-ui/src/utils/refUtil.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import { beforeEach, describe, expect, it, vi } from 'vitest'
1+
import { describe, expect, it, vi } from 'vitest'
22
import { computed, nextTick, ref } from 'vue'
33

44
import { withSetup } from '@/test/withSetup'
55
import { useMinLoadingDurationRef } from '@/utils/refUtil'
66

77
describe('useMinLoadingDurationRef', () => {
8-
beforeEach(() => {
9-
vi.useFakeTimers()
10-
})
11-
128
it('reflects false when source is initially false', () => {
139
const source = ref(false)
1410
const result = withSetup(() => useMinLoadingDurationRef(source))

apps/website/src/composables/useCarouselAutoplay.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeEach, describe, expect, it, vi } from 'vitest'
1+
import { describe, expect, it, vi } from 'vitest'
22
import { effectScope, nextTick, ref } from 'vue'
33

44
import { useCarouselAutoplay } from './useCarouselAutoplay'
@@ -10,10 +10,6 @@ function runInScope(fn: () => void): () => void {
1010
}
1111

1212
describe('useCarouselAutoplay', () => {
13-
beforeEach(() => {
14-
vi.useFakeTimers()
15-
})
16-
1713
it('advances after the active slide delay elapses', () => {
1814
const index = ref(0)
1915
const advance = vi.fn(() => {

src/base/common/downloadUtil.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ describe('downloadUtil', () => {
318318
let windowOpenSpy: ReturnType<typeof vi.spyOn>
319319

320320
beforeEach(() => {
321-
vi.useFakeTimers()
322321
windowOpenSpy = vi.spyOn(window, 'open').mockImplementation(() => null)
323322
})
324323

src/components/common/TextTicker.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ describe(TextTicker, () => {
1818
let cleanup: (() => void) | undefined
1919

2020
beforeEach(() => {
21-
vi.useFakeTimers()
2221
rafCallbacks = []
2322
vi.spyOn(window, 'requestAnimationFrame').mockImplementation((cb) => {
2423
rafCallbacks.push(cb)

src/components/common/TreeExplorerTreeNode.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ describe('TreeExplorerTreeNode', () => {
3434
beforeAll(() => {
3535
const app = createApp({})
3636
app.use(PrimeVue)
37-
vi.useFakeTimers()
3837
})
3938

4039
it('renders correctly', () => {

src/components/dialog/content/signin/TurnstileWidget.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ describe('TurnstileWidget', () => {
306306
})
307307

308308
it('falls back once the widget fails to resolve within the load timeout', async () => {
309-
vi.useFakeTimers()
310309
const { api, options } = fakeTurnstile()
311310
mockLoadTurnstile.mockResolvedValue(api)
312311

@@ -323,7 +322,6 @@ describe('TurnstileWidget', () => {
323322
})
324323

325324
it('does not fall back once a token arrives before the load timeout', async () => {
326-
vi.useFakeTimers()
327325
const { api, options } = fakeTurnstile()
328326
mockLoadTurnstile.mockResolvedValue(api)
329327

@@ -352,7 +350,6 @@ describe('TurnstileWidget', () => {
352350
})
353351

354352
it('falls back if a post-solve expiry is not followed by a fresh token within the load timeout', async () => {
355-
vi.useFakeTimers()
356353
const { api, options } = fakeTurnstile()
357354
mockLoadTurnstile.mockResolvedValue(api)
358355
window.turnstile = api as unknown as NonNullable<Window['turnstile']>

src/components/graph/NodeDragPreview.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render } from '@testing-library/vue'
2-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
2+
import { afterEach, describe, expect, it, vi } from 'vitest'
33
import { nextTick } from 'vue'
44

55
import NodeDragPreview from '@/components/graph/NodeDragPreview.vue'
@@ -26,10 +26,6 @@ function ghostElement() {
2626
}
2727

2828
describe('NodeDragPreview', () => {
29-
beforeEach(() => {
30-
vi.useFakeTimers()
31-
})
32-
3329
afterEach(() => {
3430
useNodeDragToCanvas().cancelDrag()
3531
})

src/components/graph/NodeTooltip.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ async function renderAndHoverCanvas() {
151151

152152
describe('NodeTooltip', () => {
153153
beforeEach(() => {
154-
vi.useFakeTimers()
155154
setActivePinia(createTestingPinia({ stubActions: false }))
156155

157156
vi.spyOn(useSettingStore(), 'get').mockImplementation(

src/components/queue/job/JobAssetsList.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ describe('JobAssetsList', () => {
444444
})
445445

446446
it('anchors the popover to the active row through Reka', async () => {
447-
vi.useFakeTimers()
448447
const job = buildJob()
449448
const { container } = renderJobAssetsList({ jobs: [job] })
450449

@@ -464,7 +463,6 @@ describe('JobAssetsList', () => {
464463
})
465464

466465
it('clears the previous popover when hovering a new row briefly and leaving the list', async () => {
467-
vi.useFakeTimers()
468466
const firstJob = buildJob({ id: 'job-1' })
469467
const secondJob = buildJob({ id: 'job-2', title: 'Job 2' })
470468
const { container } = renderJobAssetsList({
@@ -494,7 +492,6 @@ describe('JobAssetsList', () => {
494492
})
495493

496494
it('updates the visible popover without closing when hovering another row', async () => {
497-
vi.useFakeTimers()
498495
const firstJob = buildJob({ id: 'job-1' })
499496
const secondJob = buildJob({ id: 'job-2', title: 'Job 2' })
500497
const { container } = renderJobAssetsList({
@@ -532,7 +529,6 @@ describe('JobAssetsList', () => {
532529
})
533530

534531
it('does not show details if the hovered row disappears before the show delay ends', async () => {
535-
vi.useFakeTimers()
536532
const job = buildJob()
537533
const { container, rerender } = renderJobAssetsList({ jobs: [job] })
538534

src/components/ui/search-input/AsyncSearchInput.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { render, screen } from '@testing-library/vue'
22
import userEvent from '@testing-library/user-event'
3-
import { beforeEach, describe, expect, it, vi } from 'vitest'
3+
import { describe, expect, it, vi } from 'vitest'
44
import { defineComponent, ref } from 'vue'
55
import type { ComponentProps } from 'vue-component-type-helpers'
66
import { createI18n } from 'vue-i18n'
@@ -45,10 +45,6 @@ function renderSearch(
4545
}
4646

4747
describe('AsyncSearchInput', () => {
48-
beforeEach(() => {
49-
vi.useFakeTimers()
50-
})
51-
5248
describe('Input binding', () => {
5349
it('renders the initial query', () => {
5450
renderSearch('hello')

0 commit comments

Comments
 (0)