Files
ComfyUI_frontend/tests-ui/tests/nodeSource.test.ts
snomiao 8bfb1009ce [style] migrate to @prettier/plugin-oxc for faster formatting
Replace @trivago/prettier-plugin-sort-imports with @prettier/plugin-oxc
and @ianvs/prettier-plugin-sort-imports for improved performance.

Changes:
- Add @prettier/plugin-oxc (Rust-based fast parser)
- Add @ianvs/prettier-plugin-sort-imports (import sorting compatible with oxc)
- Remove @trivago/prettier-plugin-sort-imports
- Update .prettierrc to use new plugins and compatible import order config
- Reformat all files with new plugin configuration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-19 00:02:04 +00:00

76 lines
2.2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { getNodeSource, NodeSourceType } from '@/types/nodeSource'
describe('getNodeSource', () => {
it('should return UNKNOWN_NODE_SOURCE when python_module is undefined', () => {
const result = getNodeSource(undefined)
expect(result).toEqual({
type: NodeSourceType.Unknown,
className: 'comfy-unknown',
displayText: 'Unknown',
badgeText: '?'
})
})
it('should identify core nodes from nodes module', () => {
const result = getNodeSource('nodes.some_module')
expect(result).toEqual({
type: NodeSourceType.Core,
className: 'comfy-core',
displayText: 'Comfy Core',
badgeText: '🦊'
})
})
it('should identify core nodes from comfy_extras module', () => {
const result = getNodeSource('comfy_extras.some_module')
expect(result).toEqual({
type: NodeSourceType.Core,
className: 'comfy-core',
displayText: 'Comfy Core',
badgeText: '🦊'
})
})
it('should identify core nodes from comfy_api_nodes module', () => {
const result = getNodeSource('comfy_api_nodes.some_module')
expect(result).toEqual({
type: NodeSourceType.Core,
className: 'comfy-core',
displayText: 'Comfy Core',
badgeText: '🦊'
})
})
it('should identify custom nodes and format their names', () => {
const result = getNodeSource('custom_nodes.ComfyUI-Example')
expect(result).toEqual({
type: NodeSourceType.CustomNodes,
className: 'comfy-custom-nodes',
displayText: 'Example',
badgeText: 'Example'
})
})
it('should identify custom nodes with version and format their names', () => {
const result = getNodeSource('custom_nodes.ComfyUI-Example@1.0.0')
expect(result).toEqual({
type: NodeSourceType.CustomNodes,
className: 'comfy-custom-nodes',
displayText: 'Example',
badgeText: 'Example'
})
})
it('should return UNKNOWN_NODE_SOURCE for unrecognized modules', () => {
const result = getNodeSource('unknown_module.something')
expect(result).toEqual({
type: NodeSourceType.Unknown,
className: 'comfy-unknown',
displayText: 'Unknown',
badgeText: '?'
})
})
})