forked from tracychen/coinbase-onchainkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: let's get to 100% unit-test coverage (coinbase#256)
- Loading branch information
Showing
44 changed files
with
483 additions
and
269 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@coinbase/onchainkit': minor | ||
--- | ||
|
||
- **feat**: 100% unit-test coverage. By @zizzamia #256 |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
import { base, baseSepolia, optimism, zora } from 'viem/chains'; | ||
import { getChainEASGraphQLAPI } from './easSupportedChains'; | ||
|
||
describe('easSupportedChains', () => { | ||
describe('getChainEASGraphQLAPI', () => { | ||
it('should return Base Chain EAS GraphQL API', async () => { | ||
const chainEASGraphQLAPI = getChainEASGraphQLAPI(base); | ||
expect(chainEASGraphQLAPI).toEqual('https://base.easscan.org/graphql'); | ||
}); | ||
|
||
it('should return Base Sepolia Chain EAS GraphQL API', async () => { | ||
const chainEASGraphQLAPI = getChainEASGraphQLAPI(baseSepolia); | ||
expect(chainEASGraphQLAPI).toEqual('https://base-sepolia.easscan.org/graphql'); | ||
}); | ||
|
||
it('should return Optimism Chain EAS GraphQL API', async () => { | ||
const chainEASGraphQLAPI = getChainEASGraphQLAPI(optimism); | ||
expect(chainEASGraphQLAPI).toEqual('https://optimism.easscan.org/graphql'); | ||
}); | ||
|
||
it('should return empty string when Chain EAS GraphQL API is not present', async () => { | ||
const chainEASGraphQLAPI = getChainEASGraphQLAPI(zora); | ||
expect(chainEASGraphQLAPI).toEqual(''); | ||
}); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
src/utils/easAttestation.ts → src/identity/easSupportedChains.ts
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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
/** | ||
* getSlicedAddress returns the first 5 and last 4 characters of an address. | ||
* Returns the first 5 and last 4 characters of an address. | ||
*/ | ||
export const getSlicedAddress = (address: `0x${string}` | undefined) => { | ||
if (!address) { | ||
return ''; | ||
} | ||
export const getSlicedAddress = (address: `0x${string}`) => { | ||
return `${address.slice(0, 5)}...${address.slice(-4)}`; | ||
}; |
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,9 @@ | ||
import { base } from 'viem/chains'; | ||
import { createEasGraphQLClient } from './createEasGraphQLClient'; | ||
|
||
describe('createEasGraphQLClient', () => { | ||
it('should return a easGraphqlClient', () => { | ||
const easGraphqlClient = createEasGraphQLClient(base); | ||
expect(easGraphqlClient.requestConfig).toEqual({}); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
src/network/easGraphQL.ts → src/network/createEasGraphQLClient.ts
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...neynar/frame/neynarFrameFunctions.test.ts → ...eynar/frame/neynarFrameValidation.test.ts
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
2 changes: 1 addition & 1 deletion
2
...tils/neynar/frame/neynarFrameFunctions.ts → ...ils/neynar/frame/neynarFrameValidation.ts
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,33 @@ | ||
import { version } from '../../version'; | ||
import { NEYNAR_DEFAULT_API_KEY } from './frame/neynarFrameValidation'; | ||
import { getDataFromNeynar } from './getDataFromNeynar'; | ||
|
||
describe('getDataFromNeynar', () => { | ||
let fetchMock = jest.fn(); | ||
let status = 200; | ||
|
||
beforeEach(() => { | ||
status = 200; | ||
global.fetch = jest.fn(() => | ||
Promise.resolve({ | ||
status, | ||
json: fetchMock, | ||
}), | ||
) as jest.Mock; | ||
}); | ||
|
||
it('should call fetch correctly', async () => { | ||
const apiURLMock = 'https://api.neynar.com/v2/amazing-api'; | ||
await getDataFromNeynar(apiURLMock); | ||
expect(global.fetch).toHaveBeenCalledWith(apiURLMock, { | ||
method: 'GET', | ||
url: apiURLMock, | ||
headers: { | ||
accept: 'application/json', | ||
api_key: NEYNAR_DEFAULT_API_KEY, | ||
'content-type': 'application/json', | ||
onchainkit_version: version, | ||
}, | ||
}); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
src/utils/neynar/getDataFormNeynar.ts → src/utils/neynar/getDataFromNeynar.ts
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,35 @@ | ||
import { version } from '../../version'; | ||
import { NEYNAR_DEFAULT_API_KEY } from './frame/neynarFrameValidation'; | ||
import { postDataToNeynar } from './postDataToNeynar'; | ||
|
||
describe('postDataToNeynar', () => { | ||
let fetchMock = jest.fn(); | ||
let status = 200; | ||
|
||
beforeEach(() => { | ||
status = 200; | ||
global.fetch = jest.fn(() => | ||
Promise.resolve({ | ||
status, | ||
json: fetchMock, | ||
}), | ||
) as jest.Mock; | ||
}); | ||
|
||
it('should call fetch correctly', async () => { | ||
const mockURL = 'https://api.neynar.com/v2/amazing-api'; | ||
const mockData = {}; | ||
await postDataToNeynar(mockURL, NEYNAR_DEFAULT_API_KEY, mockData); | ||
expect(global.fetch).toHaveBeenCalledWith(mockURL, { | ||
method: 'POST', | ||
url: mockURL, | ||
headers: { | ||
accept: 'application/json', | ||
api_key: NEYNAR_DEFAULT_API_KEY, | ||
'content-type': 'application/json', | ||
onchainkit_version: version, | ||
}, | ||
body: JSON.stringify(mockData), | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.