Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

894 B
Raw Blame
import { getHasCycles } from 'features/nodes/store/util/getHasCycles';
import { add, buildEdge, buildNode } from 'features/nodes/store/util/testUtils';
import { describe, expect, it } from 'vitest';

describe(getHasCycles.name, () => {
  const n1 = buildNode(add);
  const n2 = buildNode(add);
  const n3 = buildNode(add);
  const nodes = [n1, n2, n3];

  it('should return true if the graph WOULD have cycles after adding the edge', () => {
    const edges = [buildEdge(n1.id, 'value', n2.id, 'a'), buildEdge(n2.id, 'value', n3.id, 'a')];
    const result = getHasCycles(n3.id, n1.id, nodes, edges);
    expect(result).toBe(true);
  });

  it('should return false if the graph WOULD NOT have cycles after adding the edge', () => {
    const edges = [buildEdge(n1.id, 'value', n2.id, 'a')];
    const result = getHasCycles(n2.id, n3.id, nodes, edges);
    expect(result).toBe(false);
  });
});