Skip to content

Commit

Permalink
feat(test): Added tests (pancakeswap#202)
Browse files Browse the repository at this point in the history
* feat(test): Added tests

* build: Updated github workflow

* fix(build): Removed extraneous dependencies

* chore: Reorganized test folder structure
  • Loading branch information
hachiojidev authored Dec 14, 2020
1 parent 0d60365 commit 9535997
Show file tree
Hide file tree
Showing 6 changed files with 725 additions and 639 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Tests
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install modules
run: yarn
- name: Run Jest tests
run: yarn test
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@pancakeswap-libs/eslint-config-pancake": "1.0.0",
"@types/jest": "^26.0.19",
"eslint": "^7.2.0",
"husky": "^4.3.0",
"prettier": "^2.1.2"
Expand Down
12 changes: 12 additions & 0 deletions src/__tests__/unit/formatAddress.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import formatAddress from '../../utils/formatAddress'

it.each([
['bc1qmkv9wumjy2yzgghf2jmuvzvua6hgauh5grnm59', 'bc1qmk...grnm59'],
['bc1qexasackdmnfpslk8ncmlcprjqqcvzgkrdu5q6y', 'bc1qex...du5q6y'],
['bc1q0xnppfz2merk59zcxsuqc7h0lkaw4ycts9y0nu', 'bc1q0x...s9y0nu'],
['bc1qhyv7a33zq57nld3hpunk25hkfxfey3rpjxctcn', 'bc1qhy...jxctcn'],
['bc1qh4hluzu3d3egwgwdk03xy8xrszd4q7vehttfww', 'bc1qh4...httfww'],
['0x3249d704a6a80731d990857E54D8222916B1C161', '0x3249...B1C161'],
])('format %s', (address, expected) => {
expect(formatAddress(address)).toEqual(expected)
})
13 changes: 13 additions & 0 deletions src/__tests__/unit/getTimePeriods.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import getTimePeriods from '../../utils/getTimePeriods'

it.each([
[40, { years: 0, months: 0, days: 0, hours: 0, minutes: 0, seconds: 40 }],
[60, { years: 0, months: 0, days: 0, hours: 0, minutes: 1, seconds: 0 }],
[70, { years: 0, months: 0, days: 0, hours: 0, minutes: 1, seconds: 10 }],
[691200, { years: 0, months: 0, days: 8, hours: 0, minutes: 0, seconds: 0 }],
[5259600, { years: 0, months: 2, days: 0, hours: 0, minutes: 0, seconds: 0 }],
[94672800, { years: 3, months: 0, days: 0, hours: 0, minutes: 0, seconds: 0 }],
[34277461, { years: 1, months: 1, days: 1, hours: 1, minutes: 1, seconds: 1 }],
])('format %i seconds', (seconds, expected) => {
expect(getTimePeriods(seconds)).toEqual(expected)
})
12 changes: 9 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"compilerOptions": {
"baseUrl": "src",
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
Expand All @@ -14,10 +18,12 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"jsx": "react-jsx",
"strictNullChecks": false,
"noImplicitAny": false,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
"include": [
"src"
]
}
Loading

0 comments on commit 9535997

Please sign in to comment.