Skip to content

Commit 574cf3c

Browse files
fixup! feat: add blockfrost DRep provider
1 parent 363e67b commit 574cf3c

File tree

5 files changed

+16
-27
lines changed

5 files changed

+16
-27
lines changed

packages/cardano-services-client/test/AssetInfoProvider/BlockfrostAssetProvider.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Responses } from '@blockfrost/blockfrost-js';
55
import { BlockfrostAssetProvider } from '../../src';
66
import { BlockfrostClient } from '../../src/blockfrost/BlockfrostClient';
77
import { logger } from '@cardano-sdk/util-dev';
8-
import { mockResponses } from './util';
8+
import { mockResponses } from '../util';
99

1010
describe('BlockfrostAssetProvider', () => {
1111
let request: jest.Mock;

packages/cardano-services-client/test/AssetInfoProvider/util.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/cardano-services-client/test/DRepProvider/BlockfrostDRepProvider.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Responses } from '@blockfrost/blockfrost-js';
55
import { BlockfrostClient } from '../../src/blockfrost/BlockfrostClient';
66
import { BlockfrostDRepProvider } from '../../src';
77
import { logger } from '@cardano-sdk/util-dev';
8-
import { mockResponses } from './util';
8+
import { mockResponses } from '../util';
99

1010
describe('BlockfrostDRepProvider', () => {
1111
let request: jest.Mock;
@@ -28,7 +28,7 @@ describe('BlockfrostDRepProvider', () => {
2828
hex: 'a61261172624e8333ceff098648d90f8e404e2e36d5b5f5985cbd35d'
2929
} as Responses['drep'];
3030

31-
test('has nft metadata', async () => {
31+
test('getDRepInfo', async () => {
3232
mockResponses(request, [
3333
[
3434
`governance/dreps/${mockedDRepId}`,

packages/cardano-services-client/test/DRepProvider/util.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/cardano-services-client/test/util.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,16 @@ export const getBobHandleProviderResponse = {
6060
policyId: Cardano.PolicyId('50fdcdbfa3154db86a87e4b5697ae30d272e0bbcfa8122efd3e301cb'),
6161
profilePic: Asset.Uri('ipfs://zrljm7nskakjydxlr450ktsj08zuw6aktvgfkmmyw9semrkrezryq3yd1')
6262
};
63+
64+
export const mockResponses = (request: jest.Mock, responses: [string | RegExp, unknown][]) => {
65+
request.mockImplementation(async (endpoint: string) => {
66+
for (const [match, response] of responses) {
67+
if (typeof match === 'string') {
68+
if (match === endpoint) return response;
69+
} else if (match.test(endpoint)) {
70+
return response;
71+
}
72+
}
73+
throw new Error(`Not implemented/matched: ${endpoint}`);
74+
});
75+
};

0 commit comments

Comments
 (0)