VariantCandidatesPlate.test.tsx 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import { describe, it, expect, vi } from 'vitest';
  2. import { waitFor } from '@testing-library/react';
  3. import { http, HttpResponse } from 'msw';
  4. import { server } from '../mocks/server';
  5. import { render } from '../utils';
  6. import { VariantCandidates, type VariantCandidate } from '../../components/PrintModal/VariantCandidates';
  7. describe('VariantCandidates', () => {
  8. it('chooses the plate it shows when none was picked', async () => {
  9. server.use(
  10. http.get('/api/v1/library/files/:id/plates', () =>
  11. HttpResponse.json({
  12. is_multi_plate: true,
  13. plates: [
  14. { index: 1, name: 'Plate 1' },
  15. { index: 2, name: 'Plate 2' },
  16. ],
  17. }),
  18. ),
  19. );
  20. const onPlateChange = vi.fn();
  21. const candidates = [{ id: 7, filename: 'part.3mf', sliced_for_model: 'X1C' }] as VariantCandidate[];
  22. render(
  23. <VariantCandidates candidates={candidates} onReorder={vi.fn()} plateByFile={{}} onPlateChange={onPlateChange} />,
  24. );
  25. await waitFor(() => expect(onPlateChange).toHaveBeenCalledWith(7, 1));
  26. });
  27. });