1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
squid-js/test/ocean/OceanAccounts.test.ts

50 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-06-20 00:20:09 +02:00
import { assert, spy, use } from 'chai'
2019-11-11 12:27:18 +01:00
import spies from 'chai-spies'
2019-06-20 00:20:09 +02:00
import config from '../config'
import Account from '../../src/ocean/Account'
import { Ocean } from '../../src/ocean/Ocean'
import { OceanAccounts } from '../../src/ocean/OceanAccounts'
use(spies)
2019-06-20 00:20:09 +02:00
describe('OceanAccounts', () => {
let oceanAccounts: OceanAccounts
before(async () => {
oceanAccounts = (await Ocean.getInstance(config)).accounts
})
afterEach(() => {
spy.restore()
})
2019-06-20 00:20:09 +02:00
describe('#list()', () => {
it('should return the list of accounts', async () => {
const accounts = await oceanAccounts.list()
2019-06-20 00:20:09 +02:00
accounts.map(account => assert.instanceOf(account, Account))
})
})
2019-06-20 00:20:09 +02:00
describe('#balance()', () => {
it('should return the balance of an account', async () => {
const [account] = await oceanAccounts.list()
2019-06-20 00:20:09 +02:00
spy.on(account, 'getBalance', () => ({ eth: 1, ocn: 5 }))
const balance = await oceanAccounts.balance(account)
2019-06-20 00:20:09 +02:00
assert.deepEqual(balance, { eth: 1, ocn: 5 })
})
})
2019-06-20 00:20:09 +02:00
describe('#requestTokens()', () => {
it('should return the balance of an account', async () => {
const [account] = await oceanAccounts.list()
2019-06-20 00:20:09 +02:00
spy.on(account, 'requestTokens', () => 10)
const success = await oceanAccounts.requestTokens(account, 10)
assert.isTrue(success)
})
})
})