|
| 1 | +import { getNodeSource, NodeSourceType } from '@/types/nodeSource' |
| 2 | + |
| 3 | +describe('getNodeSource', () => { |
| 4 | + it('should return UNKNOWN_NODE_SOURCE when python_module is undefined', () => { |
| 5 | + const result = getNodeSource(undefined) |
| 6 | + expect(result).toEqual({ |
| 7 | + type: NodeSourceType.Unknown, |
| 8 | + className: 'comfy-unknown', |
| 9 | + displayText: 'Unknown', |
| 10 | + badgeText: '?' |
| 11 | + }) |
| 12 | + }) |
| 13 | + |
| 14 | + it('should identify core nodes from nodes module', () => { |
| 15 | + const result = getNodeSource('nodes.some_module') |
| 16 | + expect(result).toEqual({ |
| 17 | + type: NodeSourceType.Core, |
| 18 | + className: 'comfy-core', |
| 19 | + displayText: 'Comfy Core', |
| 20 | + badgeText: '🦊' |
| 21 | + }) |
| 22 | + }) |
| 23 | + |
| 24 | + it('should identify core nodes from comfy_extras module', () => { |
| 25 | + const result = getNodeSource('comfy_extras.some_module') |
| 26 | + expect(result).toEqual({ |
| 27 | + type: NodeSourceType.Core, |
| 28 | + className: 'comfy-core', |
| 29 | + displayText: 'Comfy Core', |
| 30 | + badgeText: '🦊' |
| 31 | + }) |
| 32 | + }) |
| 33 | + |
| 34 | + it('should identify custom nodes and format their names', () => { |
| 35 | + const result = getNodeSource('custom_nodes.ComfyUI-Example') |
| 36 | + expect(result).toEqual({ |
| 37 | + type: NodeSourceType.CustomNodes, |
| 38 | + className: 'comfy-custom-nodes', |
| 39 | + displayText: 'Example', |
| 40 | + badgeText: 'Example' |
| 41 | + }) |
| 42 | + }) |
| 43 | + |
| 44 | + it('should identify custom nodes with version and format their names', () => { |
| 45 | + const result = getNodeSource('custom_nodes.ComfyUI-Example@1.0.0') |
| 46 | + expect(result).toEqual({ |
| 47 | + type: NodeSourceType.CustomNodes, |
| 48 | + className: 'comfy-custom-nodes', |
| 49 | + displayText: 'Example', |
| 50 | + badgeText: 'Example' |
| 51 | + }) |
| 52 | + }) |
| 53 | + |
| 54 | + it('should return UNKNOWN_NODE_SOURCE for unrecognized modules', () => { |
| 55 | + const result = getNodeSource('unknown_module.something') |
| 56 | + expect(result).toEqual({ |
| 57 | + type: NodeSourceType.Unknown, |
| 58 | + className: 'comfy-unknown', |
| 59 | + displayText: 'Unknown', |
| 60 | + badgeText: '?' |
| 61 | + }) |
| 62 | + }) |
| 63 | +}) |
0 commit comments