mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-05 21:20:12 +00:00
refactor: remove extra function
This commit is contained in:
@@ -4,41 +4,18 @@ import type { ComputedRef } from 'vue'
|
||||
|
||||
import type { TaskItemImpl } from '@/stores/queueStore'
|
||||
import type { JobErrorDialogService } from '@/components/queue/job/useJobErrorReporting'
|
||||
import * as jobErrorReporting from '@/components/queue/job/useJobErrorReporting'
|
||||
import { useJobErrorReporting } from '@/components/queue/job/useJobErrorReporting'
|
||||
|
||||
/**
|
||||
* Creates a mock TaskItemImpl with an error message.
|
||||
*/
|
||||
const createTaskWithError = (errorMessage?: string): TaskItemImpl =>
|
||||
({ errorMessage }) as unknown as TaskItemImpl
|
||||
|
||||
describe('extractErrorMessage', () => {
|
||||
it('returns null when task is null', () => {
|
||||
expect(jobErrorReporting.extractErrorMessage(null)).toBeNull()
|
||||
})
|
||||
|
||||
it('returns null when errorMessage is undefined', () => {
|
||||
expect(
|
||||
jobErrorReporting.extractErrorMessage(createTaskWithError())
|
||||
).toBeNull()
|
||||
})
|
||||
|
||||
it('returns the error message when present', () => {
|
||||
expect(
|
||||
jobErrorReporting.extractErrorMessage(
|
||||
createTaskWithError('Something failed')
|
||||
)
|
||||
).toBe('Something failed')
|
||||
})
|
||||
})
|
||||
|
||||
describe('useJobErrorReporting', () => {
|
||||
let taskState = ref<TaskItemImpl | null>(null)
|
||||
let taskForJob: ComputedRef<TaskItemImpl | null>
|
||||
let copyToClipboard: ReturnType<typeof vi.fn>
|
||||
let showErrorDialog: ReturnType<typeof vi.fn>
|
||||
let dialog: JobErrorDialogService
|
||||
let composable: ReturnType<typeof jobErrorReporting.useJobErrorReporting>
|
||||
let composable: ReturnType<typeof useJobErrorReporting>
|
||||
|
||||
beforeEach(() => {
|
||||
taskState = ref<TaskItemImpl | null>(null)
|
||||
@@ -46,7 +23,7 @@ describe('useJobErrorReporting', () => {
|
||||
copyToClipboard = vi.fn()
|
||||
showErrorDialog = vi.fn()
|
||||
dialog = { showErrorDialog }
|
||||
composable = jobErrorReporting.useJobErrorReporting({
|
||||
composable = useJobErrorReporting({
|
||||
taskForJob,
|
||||
copyToClipboard,
|
||||
dialog
|
||||
|
||||
Reference in New Issue
Block a user