LCOV - code coverage report
Current view: top level - src/renderer/extensions/vueNodes/widgets/composables - useBooleanWidget.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 87.5 % 8 7
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
       2              : import { isBooleanInputSpec } from '@comfyorg/object-info-parser/schemas/nodeDefSchemaV2'
       3              : import type { InputSpec } from '@comfyorg/object-info-parser/schemas/nodeDefSchemaV2'
       4              : import type { ComfyWidgetConstructorV2 } from '@/types/widgetConstructor'
       5              : 
       6         2356 : export const useBooleanWidget = () => {
       7         4711 :   const widgetConstructor: ComfyWidgetConstructorV2 = (
       8              :     node: LGraphNode,
       9              :     inputSpec: InputSpec
      10              :   ) => {
      11          326 :     if (!isBooleanInputSpec(inputSpec)) {
      12            0 :       throw new Error(`Invalid input data: ${inputSpec}`)
      13              :     }
      14              : 
      15          326 :     const defaultVal = inputSpec.default ?? false
      16          326 :     const options = {
      17              :       on: inputSpec.label_on,
      18              :       off: inputSpec.label_off
      19              :     }
      20              : 
      21          326 :     return node.addWidget(
      22              :       'toggle',
      23              :       inputSpec.name,
      24              :       defaultVal,
      25              :       () => {},
      26              :       options
      27              :     )
      28              :   }
      29              : 
      30         4711 :   return widgetConstructor
      31              : }
        

Generated by: LCOV version 2.0-1