|
1 | 1 | import { afterEach, beforeEach, describe, expect, vi } from 'vitest' |
2 | 2 |
|
3 | | -import type { INodeInputSlot, Point } from '@/lib/litegraph/src/litegraph' |
4 | | -import { LGraphNode, LiteGraph } from '@/lib/litegraph/src/litegraph' |
5 | | -import { LGraph } from '@/lib/litegraph/src/litegraph' |
6 | | -import { NodeInputSlot } from '@/lib/litegraph/src/litegraph' |
7 | | -import { NodeOutputSlot } from '@/lib/litegraph/src/litegraph' |
8 | | -import type { ISerialisedNode } from '@/lib/litegraph/src/litegraph' |
| 3 | +import type { |
| 4 | + INodeInputSlot, |
| 5 | + Point, |
| 6 | + ISerialisedNode |
| 7 | +} from '@/lib/litegraph/src/litegraph' |
| 8 | +import { |
| 9 | + LGraphNode, |
| 10 | + LiteGraph, |
| 11 | + LGraph, |
| 12 | + NodeInputSlot, |
| 13 | + NodeOutputSlot |
| 14 | +} from '@/lib/litegraph/src/litegraph' |
9 | 15 |
|
10 | 16 | import { test } from './fixtures/testExtensions' |
11 | 17 |
|
@@ -261,6 +267,34 @@ describe('LGraphNode', () => { |
261 | 267 | }) |
262 | 268 | }) |
263 | 269 |
|
| 270 | + describe('Applies correct link type on connection', () => { |
| 271 | + it.for<[string, string, string]>([ |
| 272 | + ['IMAGE', 'IMAGE', 'IMAGE'], |
| 273 | + ['*', 'IMAGE', 'IMAGE'], |
| 274 | + ['IMAGE', '*', 'IMAGE'], |
| 275 | + ['*', '*', '*'], |
| 276 | + ['IMAGE,MASK', 'IMAGE,LATENT', 'IMAGE'], |
| 277 | + //An invalid connection should use input type |
| 278 | + ['Mask', 'IMAGE', 'IMAGE'] |
| 279 | + ])( |
| 280 | + 'Link from %s to %s should have type %s', |
| 281 | + ([output, input, expected]) => { |
| 282 | + const target = new LGraphNode('target') |
| 283 | + const source = new LGraphNode('source') |
| 284 | + const graph = new LGraph() |
| 285 | + |
| 286 | + target.addInput('input', input) |
| 287 | + source.addOutput('output', output) |
| 288 | + |
| 289 | + graph.add(source) |
| 290 | + graph.add(target) |
| 291 | + |
| 292 | + const link = source.connect(0, target, 0) |
| 293 | + expect(link?.type).toBe(expected) |
| 294 | + } |
| 295 | + ) |
| 296 | + }) |
| 297 | + |
264 | 298 | describe('getInputPos and getOutputPos', () => { |
265 | 299 | test('should handle collapsed nodes correctly', () => { |
266 | 300 | const node = new LGraphNode('TestNode') as unknown as Omit< |
|
0 commit comments