Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing unit tests #9

Merged
merged 38 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
42f682c
Edit package.json + Remove pkgjson version
matextrem Apr 5, 2022
b17c039
replace the main module file
ramirotw Apr 5, 2022
b34132d
remove absolute imports
ramirotw Apr 5, 2022
59a9fd8
Merge remote-tracking branch 'origin/main' into bugfix/export-bundle
ramirotw Apr 5, 2022
2ea10cb
fix imports
ramirotw Apr 5, 2022
d2d4fcf
add missing multiformats lib
ramirotw Apr 5, 2022
32f693f
add babel plugin to transpile the nullish coalescing operator so the …
ramirotw Apr 5, 2022
b097ebb
Add setup tests
matextrem Apr 8, 2022
79067db
Add Test setup configuration + Setup some tests
matextrem Apr 8, 2022
f698170
Update coveralls.yml github action template
matextrem Apr 8, 2022
77bcc6d
Fix coveralls template
matextrem Apr 8, 2022
1b46634
Update coverage yml
matextrem Apr 8, 2022
5c86d99
Add coverage to test yml file
matextrem Apr 8, 2022
9298e3e
Update test github action template
matextrem Apr 8, 2022
7822a94
Update coveralls script
matextrem Apr 8, 2022
62017ef
Update coveralls script
matextrem Apr 8, 2022
cb4e94e
test variables
matextrem Apr 9, 2022
6e7ac1c
Test
matextrem Apr 9, 2022
27d9598
Test
matextrem Apr 9, 2022
9cfa1f2
Test
matextrem Apr 9, 2022
d7d0320
update script
matextrem Apr 9, 2022
2295965
Update coverage script
matextrem Apr 9, 2022
7dd543c
Bump version
matextrem Apr 9, 2022
50e534a
Bump version
matextrem Apr 9, 2022
ece749d
Hardcode repo token just for testing purposes
matextrem Apr 9, 2022
f4ba492
Change trigger action
matextrem Apr 9, 2022
7fd0acf
Update trigger action
matextrem Apr 9, 2022
7cf14a5
Update token variable regen
matextrem Apr 9, 2022
995f259
Merge branch 'main' into 2/unit-tests
matextrem Apr 12, 2022
7ebe408
enable debug mode
matextrem Apr 9, 2022
85ccada
Add more tests to cover CowApi
matextrem Apr 12, 2022
2c9a81a
Merge branch 'main' into 2/unit-tests
matextrem Apr 14, 2022
2be3188
Fix types + merge from main
matextrem Apr 14, 2022
10808e5
Fix dep name
matextrem Apr 14, 2022
3f88a66
Improve tests + Remove gnosis.pm/contracts mocking
matextrem Apr 18, 2022
994487b
Merge branch 'main' into 2/unit-tests
matextrem Apr 21, 2022
507750d
Improve tests readability
matextrem Apr 21, 2022
776d468
Fix getTrades test
matextrem Apr 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Unit tests
on:
pull_request:
push:
branches:
- main
name: Unit tests & Coverage
on: [push, pull_request]

env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

jobs:
test:
Expand Down Expand Up @@ -35,7 +34,7 @@ jobs:
rm -rf .yarncache
yarn cache clean
- name: Run tests
run: 'npm run test'
run: yarn run test:coverage

- name: Comment in failing tests
uses: mattallty/jest-github-action@v1.0.3
Expand All @@ -45,3 +44,9 @@ jobs:
with:
test-command: 'echo unit tests already executed'
coverage-comment: false

- name: Coveralls Report
uses: coverallsapp/github-action@1.1.3
if: success() || failure()
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules
dist
dist
coverage
.coveralls.yml
jest.results.json
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# CoW protocol SDK
[![Styled With Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io/)
[![Coverage Status](https://coveralls.io/repos/github/cowprotocol/cow-sdk/badge.svg?branch=main)](https://coveralls.io/github/cowprotocol/cow-sdk?branch=main)


> ⚠️⚠️ THE SDK IS IN Beta ⚠️⚠️
Expand Down
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"lint": "eslint src",
"format": "prettier --write \"src/**/*.+(ts|json)\"",
"test": "jest",
"test:coverage": "jest --coverage --json --outputFile=jest.results.json && cat ./coverage/lcov.info | coveralls",
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"preversion": "npm run lint",
Expand All @@ -36,18 +37,28 @@
"@types/jest": "^27.0.3",
"@typescript-eslint/eslint-plugin": "^5.9.0",
"@typescript-eslint/parser": "^5.9.0",
"coveralls": "^3.1.1",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"eth-testing": "^1.0.0",
"jest": "^27.3.1",
"jest-fetch-mock": "^3.0.3",
"microbundle": "^0.14.2",
"prettier": "^2.5.1"
},
"jest": {
"automock": false,
"resetMocks": false,
"setupFiles": [
"./setupTests.js"
]
},
"keywords": [
"cow",
"cow-protocol",
"sdk",
"crypto",
"typescript"
]
}
}
17 changes: 17 additions & 0 deletions setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import fetchMock from 'jest-fetch-mock'
import log from 'loglevel'
import { generateTestingUtils } from 'eth-testing'

jest.setMock('cross-fetch', fetchMock)
jest.mock('@gnosis.pm/gp-v2-contracts')
matextrem marked this conversation as resolved.
Show resolved Hide resolved

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

global.window = global
global.window.ethereum = testingUtils.getProvider()
matextrem marked this conversation as resolved.
Show resolved Hide resolved

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
Loading