import { Test, TestingModule } from '@nestjs/testing' import { Nutrition } from '../domain/nutrition' import { MenusController } from './menus.controller' describe('MenusController', () => { let spy: any let menusController: MenusController let menuId: string const nutrition = { generateMenuToPatient: async (_patientId: string): Promise => menuId, } beforeEach(async () => { const app: TestingModule = await Test.createTestingModule({ controllers: [MenusController], providers: [ { provide: Nutrition, useValue: nutrition, }, ], }).compile() menusController = app.get(MenusController) }) describe('.generate', () => { const params = { input: {}, session_variables: { 'x-hasura-user-id': '43434', 'x-hasura-role': 'patient' } } it('call accounts with correct params', async () => { spy = jest.spyOn(nutrition, 'generateMenuToPatient') await menusController.generate(params) expect(spy).toHaveBeenCalledWith('43434') }) }) })