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 { describe, expect, it, vi } from 'vitest';

import { createCanvasOperationStores } from './operationStores';

describe('createCanvasOperationStores', () => {
  it('publishes filter and Select Object session snapshots independently', () => {
    const stores = createCanvasOperationStores();
    const onFilter = vi.fn();
    const onSam = vi.fn();
    stores.filterSession.subscribe(onFilter);
    stores.samSession.subscribe(onSam);

    stores.filterSession.set({ status: 'ready' } as never);
    expect(onFilter).toHaveBeenCalledOnce();
    expect(onSam).not.toHaveBeenCalled();

    stores.samSession.set({ status: 'ready' } as never);
    expect(onSam).toHaveBeenCalledOnce();
  });

  it('does not notify for an identical snapshot reference', () => {
    const stores = createCanvasOperationStores();
    const listener = vi.fn();
    const snapshot = { status: 'ready' } as never;
    stores.filterSession.subscribe(listener);
    stores.filterSession.set(snapshot);
    stores.filterSession.set(snapshot);
    expect(listener).toHaveBeenCalledOnce();
  });
});