diff --git a/src/app/pages/recipe-upload-page/steps/enter-recipe-data/enter-recipe-data.spec.ts b/src/app/pages/recipe-upload-page/steps/enter-recipe-data/enter-recipe-data.spec.ts index 6738e68..1310078 100644 --- a/src/app/pages/recipe-upload-page/steps/enter-recipe-data/enter-recipe-data.spec.ts +++ b/src/app/pages/recipe-upload-page/steps/enter-recipe-data/enter-recipe-data.spec.ts @@ -1,17 +1,63 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; - import { EnterRecipeData } from './enter-recipe-data'; +import { provideQueryClient, QueryClient } from '@tanstack/angular-query-experimental'; +import { inputBinding } from '@angular/core'; +import { RecipeDraftViewModel } from '../../../../shared/models/RecipeDraftView.model'; +import { ResourceOwner } from '../../../../shared/models/ResourceOwner.model'; +import { ImageService } from '../../../../shared/services/ImageService'; +import { of } from 'rxjs'; +import { SliceView, SliceViewMeta } from '../../../../shared/models/SliceView.model'; +import { ImageViewWithBlobUrl } from '../../../../shared/client-models/ImageViewWithBlobUrl'; describe('EnterRecipeData', () => { let component: EnterRecipeData; let fixture: ComponentFixture; beforeEach(async () => { + const queryClient = new QueryClient({ + defaultOptions: { + queries: { + retry: false, + }, + }, + }); + + const imageServiceMock = { + getOwnedImagesCount: vi.fn(() => of(0)), + getOwnedImageViewsWithBlobUrls: vi.fn(() => + of({ + count: 0, + slice: {} as SliceViewMeta, + content: [], + } as SliceView), + ), + } as Partial; + await TestBed.configureTestingModule({ imports: [EnterRecipeData], + providers: [ + provideQueryClient(queryClient), + { + provide: ImageService, + useValue: imageServiceMock, + }, + ], }).compileComponents(); - fixture = TestBed.createComponent(EnterRecipeData); + fixture = TestBed.createComponent(EnterRecipeData, { + bindings: [ + inputBinding( + 'draft', + () => + ({ + id: 'test-id', + created: new Date(), + state: 'ENTER_DATA', + owner: {} as ResourceOwner, + }) satisfies RecipeDraftViewModel, + ), + ], + }); component = fixture.componentInstance; await fixture.whenStable(); });