-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into feat/add-sound-geom…
…etry-values
- Loading branch information
Showing
6 changed files
with
123 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { CatalogFilters, ChainId, Network } from '@dcl/schemas' | ||
import { getQuerySources } from '../../ports/catalog/utils' | ||
import { getSubgraphNameForNetwork } from '../../subgraphUtils' | ||
|
||
const marketplaceChainId = 1 | ||
const collectionsChainId = 137 | ||
|
||
jest.mock('../../logic/chainIds', () => ({ | ||
getCollectionsChainId: () => collectionsChainId, | ||
getMarketplaceChainId: () => marketplaceChainId, | ||
})) | ||
|
||
describe('getQuerySources', () => { | ||
let filters: CatalogFilters | ||
let sources: Record<string, string> | ||
describe('when filtering by network', () => { | ||
beforeEach(() => { | ||
filters = { network: Network.ETHEREUM } | ||
sources = getQuerySources(filters) | ||
}) | ||
it('should return sources for the provided network', () => { | ||
expect(sources).toEqual({ | ||
[Network.ETHEREUM]: getSubgraphNameForNetwork( | ||
Network.ETHEREUM, | ||
marketplaceChainId as ChainId | ||
), | ||
}) | ||
}) | ||
}) | ||
|
||
describe('when filtering by creator', () => { | ||
beforeEach(() => { | ||
filters = { creator: ['someCreator'] } | ||
sources = getQuerySources(filters) | ||
}) | ||
it('should return sources for the creator provided with default networks', () => { | ||
expect(sources).toEqual({ | ||
[Network.MATIC]: getSubgraphNameForNetwork( | ||
Network.MATIC, | ||
collectionsChainId as ChainId | ||
), | ||
}) | ||
}) | ||
}) | ||
|
||
describe('when no filter is provided', () => { | ||
beforeEach(() => { | ||
filters = {} | ||
sources = getQuerySources(filters) | ||
}) | ||
it('should return sources for default networks', () => { | ||
expect(sources).toEqual({ | ||
[Network.ETHEREUM]: getSubgraphNameForNetwork( | ||
Network.ETHEREUM, | ||
marketplaceChainId as ChainId | ||
), | ||
[Network.MATIC]: getSubgraphNameForNetwork( | ||
Network.MATIC, | ||
collectionsChainId as ChainId | ||
), | ||
}) | ||
}) | ||
}) | ||
}) |