Skip to content

Commit

Permalink
Added additional coverage for textManagerService retrieveOne
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeweatherhead committed Jul 25, 2023
1 parent 136c7e4 commit f0d3fa5
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions backend/src/asset_manager/asset_manager.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AuthService } from '../auth/auth.service';
import { JwtService } from '@nestjs/jwt';
import { AssetDTO } from '../assets/dto/asset.dto';
import { RetrieveAllDTO } from './dto/retrieve_all.dto';
import { text } from 'stream/consumers';

describe('AssetManagerService', () => {
let service: AssetManagerService;
Expand Down Expand Up @@ -103,11 +104,17 @@ describe('AssetManagerService', () => {
retrieveAllDTO.UserID = 1;
retrieveAllDTO.ParentFolderID = 'test';

const assetDTO = new AssetDTO();
assetDTO.AssetID = 'test';
assetDTO.Format = 'image';
assetDTO.UserID = 1;
const assets = [assetDTO];
const imgAssetDTO = new AssetDTO();
imgAssetDTO.AssetID = 'test';
imgAssetDTO.Format = 'image';
imgAssetDTO.UserID = 1;

const textAssetDTO = new AssetDTO();
textAssetDTO.AssetID = 'test';
textAssetDTO.Format = 'image';
textAssetDTO.UserID = 1;

const assets = [imgAssetDTO, textAssetDTO];

jest
.spyOn(assetsService, 'retrieveAllAssets')
Expand All @@ -132,7 +139,7 @@ describe('AssetManagerService', () => {
imageManagerService,
'retrieveOne',
)
.mockResolvedValue(assetDTO);
.mockResolvedValue(imgAssetDTO);

jest
.spyOn(
Expand All @@ -145,7 +152,7 @@ describe('AssetManagerService', () => {
S3Service.prototype,
'retrieveAsset',
)
.mockResolvedValue(assetDTO);
.mockResolvedValue(imgAssetDTO);

jest
.spyOn(
Expand All @@ -154,21 +161,20 @@ describe('AssetManagerService', () => {
)
.mockResolvedValue('Compressed content');

jest
.spyOn(
textManagerService,
'retrieveOne',
)
.mockResolvedValue(textAssetDTO);

await service.retrieve_all(
retrieveAllDTO,
);

expect(
assetsService.retrieveAllAssets,
).toBeCalledWith(retrieveAllDTO);

// expect(
// imageManagerService.retrieveOne,
// ).toBeCalledWith(assetDTO);

// expect(
// imageManagerService.compressImage,
// ).toBeCalledWith(assetDTO.Content);
});

// it('should resize all image assets', async () => {
Expand Down

0 comments on commit f0d3fa5

Please sign in to comment.