Skip to content

Commit

Permalink
nocks
Browse files Browse the repository at this point in the history
  • Loading branch information
pyramation committed Nov 14, 2024
1 parent c6d6ada commit 43523c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
3 changes: 2 additions & 1 deletion v1/packages/client/__tests__/client-mock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import nock from 'nock';
import { ChainRegistryClient } from '../src/registry';
import { assets, chains } from '../test-utils';

const baseUrl = 'https://raw.githubusercontent.com';
const baseUrl = 'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original';


function nockByChainName(chainName: string) {
const chainDataPath = `/cosmos/chain-registry/master/${chainName}/chain.json`;
Expand Down
21 changes: 10 additions & 11 deletions v2/packages/client/setup-jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import nock from 'nock';

import { assetLists, chains, ibc } from './test-utils';

const baseUrl = 'https://raw.githubusercontent.com';

const baseUrl = 'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full';

beforeAll(() => {
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/chain.json',
Expand All @@ -13,35 +12,35 @@ beforeAll(() => {
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/juno-osmosis.json',
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/osmosis-secretnetwork.json'
nock(baseUrl)
.get('/cosmos/chain-registry/master/osmosis/chain.json')
.get('/osmosis/chain.json')
.reply(200, chains.find(c => c.chainName === 'osmosis'));
nock(baseUrl)
.get('/cosmos/chain-registry/master/osmosis/assetlist.json')
.get('/osmosis/assetlist.json')
.reply(200, assetLists.find(c => c.chainName === 'osmosis'));

nock(baseUrl)
.get('/cosmos/chain-registry/master/stargaze/chain.json')
.get('/stargaze/chain.json')
.reply(200, chains.find(c => c.chainName === 'stargaze'));
nock(baseUrl)
.get('/cosmos/chain-registry/master/stargaze/assetlist.json')
.get('/stargaze/assetlist.json')
.reply(200, assetLists.find(c => c.chainName === 'stargaze'));

nock(baseUrl)
.get('/cosmos/chain-registry/master/juno/chain.json')
.get('/juno/chain.json')
.reply(200, chains.find(c => c.chainName === 'juno'));
nock(baseUrl)
.get('/cosmos/chain-registry/master/juno/assetlist.json')
.get('/juno/assetlist.json')
.reply(200, assetLists.find(c => c.chainName === 'juno'));

nock(baseUrl)
.get('/cosmos/chain-registry/master/secretnetwork/assetlist.json')
.get('/secretnetwork/assetlist.json')
.reply(200, assetLists.find(c => c.chainName === 'secretnetwork'));

nock(baseUrl)
.get('/cosmos/chain-registry/master/_IBC/juno-osmosis.json')
.get('/_IBC/juno-osmosis.json')
.reply(200, ibc.find(i => i.chain1.chainName === 'juno' && i.chain2.chainName==='osmosis'));
nock(baseUrl)
.get('/cosmos/chain-registry/master/_IBC/osmosis-secretnetwork.json')
.get('/_IBC/osmosis-secretnetwork.json')
.reply(200, ibc.find(i => i.chain1.chainName === 'osmosis' && i.chain2.chainName==='secretnetwork'));
});

Expand Down

0 comments on commit 43523c8

Please sign in to comment.