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.

1.0 KB
Raw Blame
import type { GalleryImage } from '@features/gallery';

import { describe, expect, it } from 'vitest';

import { getImageContextMenuImages } from './ImageContextMenu';

const image: GalleryImage = {
  boardId: 'none',
  height: 512,
  imageCategory: 'general',
  imageName: 'image.png',
  imageUrl: '/image.png',
  queuedAt: '2026-06-15T00:00:00Z',
  sourceQueueItemId: 'queue-item',
  starred: false,
  thumbnailUrl: '/thumb.png',
  width: 512,
};

describe('getImageContextMenuImages', () => {
  it('returns only usable images from a context menu target', () => {
    expect(getImageContextMenuImages({ images: [image], x: 0, y: 0 })).toEqual([image]);
    expect(
      getImageContextMenuImages({ images: [image, { imageName: 'missing-urls.png' } as GalleryImage], x: 0, y: 0 })
    ).toEqual([image]);
  });

  it('tolerates stale or malformed targets', () => {
    expect(getImageContextMenuImages(null)).toEqual([]);
    expect(getImageContextMenuImages({ images: undefined as unknown as GalleryImage[], x: 0, y: 0 })).toEqual([]);
  });
});