-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #908 from blockscout/test/hook-for-paginated-queries
test: pagination refactoring and test
- Loading branch information
Showing
130 changed files
with
1,125 additions
and
579 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Jest: watch current file", | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest", | ||
"args": [ | ||
"${fileBasename}", | ||
"--runInBand", | ||
"--verbose", | ||
"-i", | ||
"--no-cache", | ||
"--watchAll", | ||
"--testTimeout=1000000000", | ||
], | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen" | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -1,12 +1,47 @@ | ||
# app config | ||
NEXT_PUBLIC_APP_HOST=blockscout.com | ||
NEXT_PUBLIC_APP_PROTOCOL=http | ||
NEXT_PUBLIC_APP_HOST=localhost | ||
NEXT_PUBLIC_APP_PORT=3000 | ||
NEXT_PUBLIC_APP_INSTANCE=jest | ||
NEXT_PUBLIC_APP_ENV=testing | ||
|
||
# ui config | ||
NEXT_PUBLIC_BLOCKSCOUT_VERSION=v4.1.7-beta | ||
NEXT_PUBLIC_NETWORK_EXPLORERS=[{'title':'Bitquery','baseUrl':'https://explorer.bitquery.io/','paths':{'tx':'/goerli/tx','address':'/goerli/address','token':'/goerli/token','block':'/goerli/block'}},{'title':'Etherscan','baseUrl':'https://goerli.etherscan.io/','paths':{'tx':'/tx','address':'/address','token':'/token','block':'/block'}}] | ||
NEXT_PUBLIC_GIT_TAG=v1.0.11 | ||
NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs','coin_price','market_cap'] | ||
NEXT_PUBLIC_HOMEPAGE_SHOW_AVG_BLOCK_TIME=true | ||
NEXT_PUBLIC_HOMEPAGE_SHOW_GAS_TRACKER=true | ||
NEXT_PUBLIC_HOMEPAGE_PLATE_BACKGROUND= | ||
NEXT_PUBLIC_FEATURED_NETWORKS= | ||
NEXT_PUBLIC_FOOTER_LINKS= | ||
NEXT_PUBLIC_NETWORK_LOGO= | ||
NEXT_PUBLIC_NETWORK_LOGO_DARK= | ||
NEXT_PUBLIC_NETWORK_ICON= | ||
NEXT_PUBLIC_NETWORK_ICON_DARK= | ||
NEXT_PUBLIC_NETWORK_RPC_URL=https://localhost:1111 | ||
NEXT_PUBLIC_IS_TESTNET=true | ||
NEXT_PUBLIC_MARKETPLACE_CONFIG_URL=https://localhost:3000/marketplace-config.json | ||
NEXT_PUBLIC_IS_L2_NETWORK=false | ||
|
||
# network config | ||
NEXT_PUBLIC_NETWORK_NAME=Blockscout | ||
NEXT_PUBLIC_NETWORK_SHORT_NAME=Blockscout | ||
NEXT_PUBLIC_NETWORK_ASSETS_PATHNAME= | ||
NEXT_PUBLIC_NETWORK_ID=1 | ||
NEXT_PUBLIC_NETWORK_CURRENCY_NAME=Ether | ||
NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL=ETH | ||
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS=18 | ||
NEXT_PUBLIC_NETWORK_TOKEN_ADDRESS= | ||
NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED=true | ||
NEXT_PUBLIC_NETWORK_VERIFICATION_TYPE=validation | ||
NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM=https://localhost:3000/marketplace-submit-form | ||
|
||
# api config | ||
NEXT_PUBLIC_API_HOST=blockscout.com | ||
NEXT_PUBLIC_STATS_API_HOST=https://stats-test.aws-k8s.blockscout.com | ||
NEXT_PUBLIC_API_HOST=localhost | ||
NEXT_PUBLIC_API_PORT=3003 | ||
NEXT_PUBLIC_STATS_API_HOST=https://localhost:3004 | ||
NEXT_PUBLIC_CONTRACT_INFO_API_HOST=https://localhost:3005 | ||
NEXT_PUBLIC_ADMIN_SERVICE_API_HOST=https://localhost:3006 | ||
NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY=xxx | ||
NEXT_PUBLIC_API_BASE_PATH=/ |
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,51 @@ | ||
import { ChakraProvider } from '@chakra-ui/react'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import type { RenderOptions } from '@testing-library/react'; | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import { AppContextProvider } from 'lib/contexts/app'; | ||
import { ScrollDirectionProvider } from 'lib/contexts/scrollDirection'; | ||
import { SocketProvider } from 'lib/socket/context'; | ||
import theme from 'theme'; | ||
|
||
import 'lib/setLocale'; | ||
|
||
const PAGE_PROPS = { | ||
cookies: '', | ||
referrer: '', | ||
}; | ||
|
||
const TestApp = ({ children }: {children: React.ReactNode}) => { | ||
const [ queryClient ] = React.useState(() => new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
refetchOnWindowFocus: false, | ||
retry: 0, | ||
}, | ||
}, | ||
})); | ||
|
||
return ( | ||
<ChakraProvider theme={ theme }> | ||
<QueryClientProvider client={ queryClient }> | ||
<AppContextProvider pageProps={ PAGE_PROPS }> | ||
<ScrollDirectionProvider> | ||
<SocketProvider> | ||
{ children } | ||
</SocketProvider> | ||
</ScrollDirectionProvider> | ||
</AppContextProvider> | ||
</QueryClientProvider> | ||
</ChakraProvider> | ||
); | ||
}; | ||
|
||
const customRender = ( | ||
ui: React.ReactElement, | ||
options?: Omit<RenderOptions, 'wrapper'>, | ||
) => render(ui, { wrapper: TestApp, ...options }); | ||
|
||
export * from '@testing-library/react'; | ||
export { customRender as render }; | ||
export { TestApp as wrapper }; |
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,17 @@ | ||
import type { NextRouter } from 'next/router'; | ||
|
||
export const router = { | ||
query: {}, | ||
push: jest.fn(() => Promise.resolve()), | ||
}; | ||
|
||
export const useRouter = jest.fn<unknown, Array<Partial<NextRouter>>>(() => (router)); | ||
|
||
export const mockUseRouter = (params?: Partial<NextRouter>) => { | ||
return { | ||
useRouter: jest.fn(() => ({ | ||
...router, | ||
...params, | ||
})), | ||
}; | ||
}; |
Oops, something went wrong.