From ca53bbd546d7c97ca2358ae234bde054441faca5 Mon Sep 17 00:00:00 2001 From: jakeweatherhead Date: Tue, 25 Jul 2023 21:14:40 +0200 Subject: [PATCH] Added tests for retrieve_one --- .../asset_manager.service.spec.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/backend/src/asset_manager/asset_manager.service.spec.ts b/backend/src/asset_manager/asset_manager.service.spec.ts index 28322be9..dbf41a99 100644 --- a/backend/src/asset_manager/asset_manager.service.spec.ts +++ b/backend/src/asset_manager/asset_manager.service.spec.ts @@ -177,6 +177,44 @@ describe('AssetManagerService', () => { ).toBeCalledWith(retrieveAllDTO); }); + describe('retrieve_one', () => { + it('should retrieve an image asset', async () => { + const assetDTO = new AssetDTO(); + assetDTO.AssetID = 'test'; + assetDTO.Format = 'image'; + assetDTO.UserID = 1; + + jest.spyOn( + imageManagerService, + 'retrieveOne', + ).mockResolvedValue(assetDTO); + + await service.retrieve_one(assetDTO); + + expect( + imageManagerService.retrieveOne, + ).toBeCalledWith(assetDTO); + }); + + it('should retrieve a text asset', async () => { + const assetDTO = new AssetDTO(); + assetDTO.AssetID = 'test'; + assetDTO.Format = 'text'; + assetDTO.UserID = 1; + + jest.spyOn( + textManagerService, + 'retrieveOne', + ).mockResolvedValue(assetDTO); + + await service.retrieve_one(assetDTO); + + expect( + textManagerService.retrieveOne, + ).toBeCalledWith(assetDTO); + }); + }); + // it('should resize all image assets', async () => { // const retrieveAllDTO = new RetrieveAllDTO(); // retrieveAllDTO.UserID = 1;