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.1 KB
Raw Blame
import type { GeneratedImageContract } from '@features/gallery';

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

import { getSelectedGalleryImageFromValues } from './selectedImage';

const image: GeneratedImageContract = {
  height: 768,
  imageName: 'selected.png',
  imageUrl: '/selected.png',
  queuedAt: '2026-06-19T00:00:00.000Z',
  sourceQueueItemId: 'queue-item',
  thumbnailUrl: '/selected-thumb.png',
  width: 512,
};

describe('getSelectedGalleryImageFromValues', () => {
  it('normalizes the stored selected image for shared image actions', () => {
    expect(getSelectedGalleryImageFromValues({ selectedBoardId: 'board-1', selectedImage: image })).toMatchObject({
      boardId: 'board-1',
      imageCategory: 'general',
      imageName: 'selected.png',
      starred: false,
    });
  });

  it('falls back to recent images by selected name', () => {
    expect(
      getSelectedGalleryImageFromValues({
        recentImages: [image],
        selectedBoardId: 'board-1',
        selectedImageName: image.imageName,
      })
    )?.toMatchObject({ imageName: 'selected.png' });
  });
});