-
Notifications
You must be signed in to change notification settings - Fork 448
Add tests for link type #7213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for link type #7213
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,17 @@ | ||
| import { afterEach, beforeEach, describe, expect, vi } from 'vitest' | ||
|
|
||
| import type { INodeInputSlot, Point } from '@/lib/litegraph/src/litegraph' | ||
| import { LGraphNode, LiteGraph } from '@/lib/litegraph/src/litegraph' | ||
| import { LGraph } from '@/lib/litegraph/src/litegraph' | ||
| import { NodeInputSlot } from '@/lib/litegraph/src/litegraph' | ||
| import { NodeOutputSlot } from '@/lib/litegraph/src/litegraph' | ||
| import type { ISerialisedNode } from '@/lib/litegraph/src/litegraph' | ||
| import type { | ||
| INodeInputSlot, | ||
| Point, | ||
| ISerialisedNode | ||
| } from '@/lib/litegraph/src/litegraph' | ||
| import { | ||
| LGraphNode, | ||
| LiteGraph, | ||
| LGraph, | ||
| NodeInputSlot, | ||
| NodeOutputSlot | ||
| } from '@/lib/litegraph/src/litegraph' | ||
|
|
||
| import { test } from './fixtures/testExtensions' | ||
|
|
||
|
|
@@ -261,6 +267,34 @@ describe('LGraphNode', () => { | |
| }) | ||
| }) | ||
|
|
||
| describe('Applies correct link type on connection', () => { | ||
| it.for<[string, string, string]>([ | ||
| ['IMAGE', 'IMAGE', 'IMAGE'], | ||
| ['*', 'IMAGE', 'IMAGE'], | ||
| ['IMAGE', '*', 'IMAGE'], | ||
| ['*', '*', '*'], | ||
| ['IMAGE,MASK', 'IMAGE,LATENT', 'IMAGE'], | ||
| //An invalid connection should use input type | ||
| ['Mask', 'IMAGE', 'IMAGE'] | ||
| ])( | ||
| 'Link from %s to %s should have type %s', | ||
| ([output, input, expected]) => { | ||
| const target = new LGraphNode('target') | ||
| const source = new LGraphNode('source') | ||
| const graph = new LGraph() | ||
|
|
||
| target.addInput(input, input) | ||
| source.addOutput(output, output) | ||
|
||
|
|
||
| graph.add(source) | ||
| graph.add(target) | ||
|
|
||
| const link = source.connect(0, target, 0) | ||
| expect(link?.type).toBe(expected) | ||
| } | ||
| ) | ||
| }) | ||
AustinMroz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| describe('getInputPos and getOutputPos', () => { | ||
| test('should handle collapsed nodes correctly', () => { | ||
| const node = new LGraphNode('TestNode') as unknown as Omit< | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.