MME-25 Prepare enter-recipe-data spec for testing.

This commit is contained in:
Jesse Brault 2026-02-10 18:17:23 -06:00
parent 6b78540dd3
commit cec414f171

View File

@ -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<EnterRecipeData>;
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<ImageViewWithBlobUrl>),
),
} as Partial<ImageService>;
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();
});