mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-22 21:38:52 +00:00
test: harden reset-arg extraction with explicit call assertion
Add expect(reset).toHaveBeenCalled() before reading the mock's first call and use optional chaining on calls[0]?.[0] so a missing call produces a clear assertion error rather than a TypeError on undefined indexing. Addresses CodeRabbit nitpick on PR #11631.
This commit is contained in:
@@ -556,8 +556,9 @@ describe('useWorkflowService', () => {
|
||||
|
||||
expect(workflowStore.openWorkflow).toHaveBeenCalledWith(existingWorkflow)
|
||||
expect(workflowStore.createNewTemporary).not.toHaveBeenCalled()
|
||||
expect(existingWorkflow.changeTracker.reset).toHaveBeenCalled()
|
||||
const resetArg = vi.mocked(existingWorkflow.changeTracker.reset).mock
|
||||
.calls[0][0]
|
||||
.calls[0]?.[0]
|
||||
expect(resetArg?.id).toMatch(
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user