Skip to content

Commit

Permalink
Fix types + merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
matextrem committed Apr 14, 2022
1 parent 2c9a81a commit 2be3188
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Unit tests & Coverage
on: [pull_request, push]
on: [push, pull_request]

env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
yarn cache clean
- name: Run tests
run: yarn run test:coverage

- name: Comment in failing tests
uses: mattallty/jest-github-action@v1.0.3
if: failure()
Expand All @@ -49,4 +49,4 @@ jobs:
uses: coverallsapp/github-action@1.1.3
if: success() || failure()
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
8 changes: 7 additions & 1 deletion setupTests.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import fetchMock from 'jest-fetch-mock'
import log from 'logLevel'
import { generateTestingUtils } from 'eth-testing'

jest.setMock('cross-fetch', fetchMock)
jest.setMock('loglevel', { debug: jest.fn(), error: jest.fn(), info: jest.fn() })
jest.mock('@gnosis.pm/gp-v2-contracts')

const testingUtils = generateTestingUtils({ providerType: 'MetaMask' })
testingUtils.mockChainId('0x4') //Rinkeby

global.window = global
global.window.ethereum = testingUtils.getProvider()

log.info = jest.fn
log.debug = jest.fn
log.error = jest.fn
log.setLevel = jest.fn
2 changes: 1 addition & 1 deletion src/CowSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class CowSdk<T extends ChainId> {
log.setLevel(options.loglevel || 'error')
}

updateChainId = (chainId: T) => {
updateChainId = (chainId: ChainId) => {
this.context.updateChainId(chainId)
}

Expand Down
10 changes: 6 additions & 4 deletions src/api/cow/cow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,9 @@ test('Invalid: Get Price Quote (Legacy) with unexisting token', async () => {

test('Valid: Get Profile Data', async () => {
fetchMock.mockResponseOnce(JSON.stringify(PROFILE_DATA_RESPONSE), { status: HTTP_STATUS_OK })
const cowSdk1 = new CowSdk(1)
//cowSdk.updateChainId(1)
const cowSdk1 = new CowSdk(chainId)
cowSdk1.updateChainId(1)

await cowSdk1.cowApi.getProfileData('0x6810e776880c02933d47db1b9fc05908e5386b96')
expect(fetchMock).toHaveBeenCalledTimes(1)
expect(fetchMock).toHaveBeenCalledWith(
Expand All @@ -324,8 +325,9 @@ test('Invalid: Get Profile Data from unexisting address', async () => {
}),
{ status: HTTP_STATUS_NOT_FOUND }
)
const cowSdk1 = new CowSdk(1)
//cowSdk.updateChainId(1)
const cowSdk1 = new CowSdk(chainId)
cowSdk1.updateChainId(1)

try {
await cowSdk1.cowApi.getProfileData('unexistingAddress')
} catch (e) {
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"noUnusedLocals": true,
"noUnusedLocals": true
},
"exclude": [
"dist"
Expand Down

0 comments on commit 2be3188

Please sign in to comment.