test: simplify test file mocking patterns (#8320)

Simplifies test mocking patterns across multiple test files.

- Removes redundant `vi.hoisted()` calls
- Cleans up mock implementations
- Removes unused imports and variables

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-8320-test-simplify-test-file-mocking-patterns-2f46d73d36508150981bd8ecb99a6a11)
by [Unito](https://www.unito.io)

---------

Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Alexander Brown
2026-01-28 12:17:16 -08:00
committed by GitHub
parent 3e2352423b
commit e44b411ff6
24 changed files with 627 additions and 511 deletions

View File

@@ -4,6 +4,8 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
import type { AssetItem } from '@/platform/assets/schemas/assetSchema'
import { useMediaAssetActions } from './useMediaAssetActions'
// Use vi.hoisted to create a mutable reference for isCloud
const mockIsCloud = vi.hoisted(() => ({ value: false }))
@@ -126,7 +128,6 @@ describe('useMediaAssetActions', () => {
})
it('should use asset.name as filename', async () => {
const { useMediaAssetActions } = await import('./useMediaAssetActions')
const actions = useMediaAssetActions()
const asset = createMockAsset({
@@ -146,7 +147,6 @@ describe('useMediaAssetActions', () => {
})
it('should use asset_hash as filename when available', async () => {
const { useMediaAssetActions } = await import('./useMediaAssetActions')
const actions = useMediaAssetActions()
const asset = createMockAsset({
@@ -160,7 +160,6 @@ describe('useMediaAssetActions', () => {
})
it('should fall back to asset.name when asset_hash is not available', async () => {
const { useMediaAssetActions } = await import('./useMediaAssetActions')
const actions = useMediaAssetActions()
const asset = createMockAsset({
@@ -174,7 +173,6 @@ describe('useMediaAssetActions', () => {
})
it('should fall back to asset.name when asset_hash is null', async () => {
const { useMediaAssetActions } = await import('./useMediaAssetActions')
const actions = useMediaAssetActions()
const asset = createMockAsset({
@@ -196,7 +194,6 @@ describe('useMediaAssetActions', () => {
})
it('should use asset_hash for each asset', async () => {
const { useMediaAssetActions } = await import('./useMediaAssetActions')
const actions = useMediaAssetActions()
const assets = [