mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-26 01:34:07 +00:00
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>
30 lines
707 B
TypeScript
30 lines
707 B
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
import { useTelemetry } from '@/platform/telemetry'
|
|
|
|
vi.mock('@/platform/distribution/types', () => ({
|
|
isCloud: false
|
|
}))
|
|
|
|
describe('useTelemetry', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
it('should return null when not in cloud distribution', () => {
|
|
const provider = useTelemetry()
|
|
|
|
// Should return null for OSS builds
|
|
expect(provider).toBeNull()
|
|
})
|
|
|
|
it('should return null consistently for OSS builds', () => {
|
|
const provider1 = useTelemetry()
|
|
const provider2 = useTelemetry()
|
|
|
|
// Both should be null for OSS builds
|
|
expect(provider1).toBeNull()
|
|
expect(provider2).toBeNull()
|
|
})
|
|
})
|