-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Finished tests for /react and /core
- Added mock variables - Fixed nx testing issues with css and global variables - Replaced redundant crypto library - Started adding data-testid's to UI components - Updated configs for tsc exclusion and presets - Added codecov.yml file for coverage Github action - Adjust babel to not build test files
- Loading branch information
1 parent
c32ec9e
commit 58f7334
Showing
73 changed files
with
2,013 additions
and
1,134 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,46 @@ | ||
name: Run & Upload Test Coverage | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
- feature/** | ||
|
||
jobs: | ||
run-tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Build packages | ||
run: yarn build:all | ||
|
||
- name: Run Jest tests | ||
run: yarn test:coverage | ||
|
||
- name: List coverage files | ||
run: | | ||
ls -al ./packages/core | ||
ls -al ./packages/core/coverage | ||
ls -al ./packages/react/coverage | ||
ls -al ./packages/proto/coverage | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
files: ./packages/core/coverage/coverage-final.json,./packages/react/coverage/coverage-final.json,./packages/proto/coverage/coverage-final.json | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
fail_ci_if_error: true |
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,26 @@ | ||
flags: | ||
core: | ||
paths: | ||
- packages/core/** | ||
react: | ||
paths: | ||
- packages/react/** | ||
proto: | ||
paths: | ||
- packages/proto/** | ||
|
||
coverage: | ||
status: | ||
project: | ||
core: | ||
target: 80% | ||
flags: | ||
- core | ||
react: | ||
target: 80% | ||
flags: | ||
- react | ||
proto: | ||
target: 80% | ||
flags: | ||
- proto |
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,6 +1,6 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'jsdom', | ||
testPathIgnorePatterns: ['node_modules', 'dist'], | ||
preset: 'ts-jest', | ||
testEnvironment: 'jsdom', | ||
testPathIgnorePatterns: ['node_modules', 'dist'] | ||
}; |
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
21 changes: 21 additions & 0 deletions
21
packages/core/src/lib/queryClient/__tests__/queryClient.spec.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { seiprotocol } from '@sei-js/proto'; | ||
import { getQueryClient } from '../queryClient'; | ||
|
||
// Mock the createLCDClient method | ||
jest.mock('@sei-js/proto', () => ({ | ||
seiprotocol: { | ||
ClientFactory: { | ||
createLCDClient: jest.fn() | ||
} | ||
} | ||
})); | ||
|
||
describe('getQueryClient', () => { | ||
it('should call createLCDClient with the correct argument and return the result', async () => { | ||
const restEndpoint = 'http://rest.atlantic-2.provider.com'; | ||
|
||
await getQueryClient(restEndpoint); | ||
|
||
expect(seiprotocol.ClientFactory.createLCDClient).toHaveBeenCalledWith({ restEndpoint }); | ||
}); | ||
}); |
41 changes: 41 additions & 0 deletions
41
packages/core/src/lib/signingClient/__tests__/cosmWasmClient.spec.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { CosmWasmClient, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'; | ||
import { OfflineSigner } from '@cosmjs/proto-signing'; | ||
import { getCosmWasmClient, getSigningCosmWasmClient } from '../cosmWasmClient'; | ||
|
||
jest.mock('@cosmjs/cosmwasm-stargate', () => ({ | ||
CosmWasmClient: { | ||
connect: jest.fn() | ||
}, | ||
SigningCosmWasmClient: { | ||
connectWithSigner: jest.fn() | ||
} | ||
})); | ||
|
||
describe('getCosmWasmClient', () => { | ||
it('should call CosmWasmClient.connect with the correct rpcEndpoint', async () => { | ||
const rpcEndpoint = 'http://localhost:26657'; | ||
|
||
await getCosmWasmClient(rpcEndpoint); | ||
|
||
expect(CosmWasmClient.connect).toHaveBeenCalledWith(rpcEndpoint); | ||
}); | ||
}); | ||
|
||
describe('getSigningCosmWasmClient', () => { | ||
it('should call SigningCosmWasmClient.connectWithSigner with the correct parameters', async () => { | ||
const rpcEndpoint = 'http://localhost:26657'; | ||
const signer = {} as OfflineSigner; | ||
const options = {}; | ||
|
||
await getSigningCosmWasmClient(rpcEndpoint, signer, options); | ||
|
||
expect(SigningCosmWasmClient.connectWithSigner).toHaveBeenCalledWith( | ||
rpcEndpoint, | ||
signer, | ||
expect.objectContaining({ | ||
registry: expect.anything(), | ||
aminoTypes: expect.anything() | ||
}) | ||
); | ||
}); | ||
}); |
69 changes: 69 additions & 0 deletions
69
packages/core/src/lib/signingClient/__tests__/stargateClient.spec.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { StargateClient, SigningStargateClient, AminoTypes } from '@cosmjs/stargate'; | ||
import { OfflineSigner, Registry } from '@cosmjs/proto-signing'; | ||
import { createSeiAminoTypes, createSeiRegistry, getSigningClient, getStargateClient } from '../stargateClient'; | ||
|
||
jest.mock('@cosmjs/stargate', () => { | ||
const originalModule = jest.requireActual('@cosmjs/stargate'); | ||
|
||
return { | ||
...originalModule, | ||
StargateClient: { | ||
...originalModule.StargateClient, | ||
connect: jest.fn() | ||
}, | ||
SigningStargateClient: { | ||
...originalModule.SigningStargateClient, | ||
connectWithSigner: jest.fn() | ||
} | ||
}; | ||
}); | ||
|
||
describe('stargateClient', () => { | ||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
describe('createSeiRegistry', () => { | ||
it('should return a Registry instance', () => { | ||
const registry = createSeiRegistry(); | ||
expect(registry).toBeInstanceOf(Registry); | ||
}); | ||
}); | ||
|
||
describe('createSeiAminoTypes', () => { | ||
it('should return an AminoTypes instance', () => { | ||
const aminoTypes = createSeiAminoTypes(); | ||
expect(aminoTypes).toBeInstanceOf(AminoTypes); | ||
}); | ||
}); | ||
|
||
describe('getStargateClient', () => { | ||
it('should call StargateClient.connect with the correct rpcEndpoint', async () => { | ||
const rpcEndpoint = 'http://localhost:26657'; | ||
|
||
await getStargateClient(rpcEndpoint); | ||
|
||
expect(StargateClient.connect).toHaveBeenCalledWith(rpcEndpoint, {}); | ||
}); | ||
}); | ||
|
||
describe('getSigningClient', () => { | ||
it('should call SigningStargateClient.connectWithSigner with the correct parameters', async () => { | ||
const rpcEndpoint = 'http://localhost:26657'; | ||
const signer = {} as OfflineSigner; | ||
const options = {}; | ||
|
||
await getSigningClient(rpcEndpoint, signer, options); | ||
|
||
expect(SigningStargateClient.connectWithSigner).toHaveBeenCalledWith( | ||
rpcEndpoint, | ||
signer, | ||
expect.objectContaining({ | ||
registry: createSeiRegistry(), | ||
aminoTypes: createSeiAminoTypes() | ||
}) | ||
); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.