Skip to content

Commit

Permalink
Comments in PR
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnRiera committed Dec 15, 2021
1 parent 0ad855d commit d566584
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 29 deletions.
41 changes: 41 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -61,12 +61,14 @@
"devDependencies": {
"@types/bn.js": "^5.1.0",
"@types/chai": "^4.3.0",
"@types/chai-as-promised": "^7.1.4",
"@types/mocha": "^9.0.0",
"@types/node": "^16.11.11",
"@types/sinon": "^10.0.6",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"eslint": "^8.3.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.3",
Expand Down
40 changes: 11 additions & 29 deletions src/near-rpc-provider.spec.ts
@@ -1,11 +1,13 @@
import { BigNumber } from '@ethersproject/bignumber'
import { expect } from 'chai'
import { expect, use } from 'chai'
import chaiAsPromised from 'chai-as-promised'
import sinon from 'sinon'
import { NearRpcProvider, RpcError } from './near-rpc-provider'
import { NEAR_TESTNET_NETWORK, NEAR_BETANET_NETWORK, NEAR_NETWORK } from './networks'

describe('NearRpcProvider', () => {
let provider: NearRpcProvider
use(chaiAsPromised)

beforeEach(async () => {
provider = new NearRpcProvider(NEAR_TESTNET_NETWORK)
Expand Down Expand Up @@ -34,13 +36,8 @@ describe('NearRpcProvider', () => {
expect(balance).to.be.instanceOf(BigNumber)
})

it('should throw an error if params are not provided', async () => {
try {
await provider.getBalance('')
} catch (error) {
expect(error).to.exist
expect(error).to.be.an.instanceof(Error)
}
it('should throw an error if params are not provided', () => {
expect(provider.getBalance('', '')).to.be.rejectedWith(Error)
})
})

Expand All @@ -66,13 +63,8 @@ describe('NearRpcProvider', () => {
expect(block.timestamp).to.equal(block2.timestamp)
})

it('should throw an error if params are not provided', async () => {
try {
await provider.getBlock('')
} catch (error) {
expect(error).to.exist
expect(error).to.be.an.instanceof(Error)
}
it('should throw an error if params are not provided', () => {
expect(provider.getBlock('')).to.be.rejectedWith(Error)
})
})

Expand All @@ -83,13 +75,8 @@ describe('NearRpcProvider', () => {
expect(gasPrice.gt(BigNumber.from(0))).to.be.true
})

it('should throw an error if there is something wrong', async () => {
try {
await provider.getGasPrice()
} catch (error) {
expect(error).to.exist
expect(error).to.be.an.instanceof(Error)
}
it('should throw an error if there is something wrong', () => {
expect(provider.getGasPrice()).to.be.rejectedWith(Error)
})
})

Expand Down Expand Up @@ -132,13 +119,8 @@ describe('NearRpcProvider', () => {
expect(code).to.be.exist
})

it('should throw an error if params are not provided', async () => {
try {
await provider.getCode('', '')
} catch (error) {
expect(error).to.exist
expect(error).to.be.an.instanceof(Error)
}
it('should throw an error if params are not provided', () => {
expect(provider.getCode('')).to.be.rejectedWith(Error)
})
})

Expand Down

0 comments on commit d566584

Please sign in to comment.