Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielailie committed Oct 12, 2023
1 parent fed3b68 commit 80bf286
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/modules/marketplaces/tests/marketplaces.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,12 +689,7 @@ describe('Marketplaces Service', () => {
const persistenceService = module.get<PersistenceService>(PersistenceService);
const cacheService = module.get<MarketplacesCachingService>(MarketplacesCachingService);

cacheService.getAllMarketplaces = jest.fn().mockReturnValueOnce(
new CollectionType({
items: inputMarketplace,
count: inputCount,
}),
);
cacheService.getMarketplaceByAddressAndCollection = jest.fn().mockReturnValueOnce(null);
persistenceService.getMarketplaceByKey = jest.fn().mockReturnValueOnce(inputMarketplace[0]);
persistenceService.saveMarketplaceCollection = jest.fn(() => {
throw new Error();
Expand All @@ -710,7 +705,27 @@ describe('Marketplaces Service', () => {
const cacheService = module.get<MarketplacesCachingService>(MarketplacesCachingService);
const eventPublisher = module.get<CacheEventsPublisherService>(CacheEventsPublisherService);

cacheService.getAllMarketplaces = jest.fn().mockReturnValueOnce(
cacheService.getMarketplaceByAddressAndCollection = jest.fn().mockReturnValueOnce(null);
eventPublisher.publish = jest.fn();
persistenceService.getMarketplaceByKey = jest.fn().mockReturnValueOnce(inputMarketplace[0]);

persistenceService.saveMarketplaceCollection = jest.fn().mockReturnValueOnce(
new MarketplaceCollectionEntity({
collectionIdentifier: 'collection',
marketplaces: [inputMarketplace[0]],
}),
);
const expectedResult = await service.whitelistCollectionOnMarketplace(new WhitelistCollectionRequest({ marketplaceKey: 'xoxno' }));

expect(expectedResult).toBeTruthy();
});

it('when marketplace and collection already whitelistedreturns true', async () => {
const persistenceService = module.get<PersistenceService>(PersistenceService);
const cacheService = module.get<MarketplacesCachingService>(MarketplacesCachingService);
const eventPublisher = module.get<CacheEventsPublisherService>(CacheEventsPublisherService);

cacheService.getMarketplaceByAddressAndCollection = jest.fn().mockReturnValueOnce(
new CollectionType({
items: inputMarketplace,
count: inputCount,
Expand Down

0 comments on commit 80bf286

Please sign in to comment.