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/Ocean.test.ts

44 lines
1.1 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-02-06 00:38:54 +01:00
2019-06-20 00:20:09 +02:00
import Account from '../../src/ocean/Account'
import { Ocean } from '../../src/ocean/Ocean'
import config from '../config'
import TestContractHandler from '../keeper/TestContractHandler'
2018-10-05 12:34:18 +02:00
2019-02-06 00:38:54 +01:00
use(spies)
2018-10-05 12:34:18 +02:00
let ocean: Ocean
2018-10-17 18:24:01 +02:00
2019-06-20 00:20:09 +02:00
describe('Ocean', () => {
before(async () => {
await TestContractHandler.prepareContracts()
ocean = await Ocean.getInstance(config)
})
2019-02-06 00:38:54 +01:00
beforeEach(async () => {
2019-06-20 00:20:09 +02:00
spy.on(ocean.utils.signature, 'signText', () => `0x${'a'.repeat(130)}`)
2019-02-06 00:38:54 +01:00
})
afterEach(() => {
spy.restore()
})
2019-06-20 00:20:09 +02:00
describe('#getInstance()', () => {
2019-11-06 13:44:36 +01:00
it('should get an instance of Ocean', async () => {
2018-11-05 10:01:58 +01:00
const oceanInstance: Ocean = await Ocean.getInstance(config)
2018-11-05 10:01:58 +01:00
assert(oceanInstance)
})
})
2019-06-20 00:20:09 +02:00
describe('#getAccounts()', () => {
it('should list accounts', async () => {
const accs: Account[] = await ocean.accounts.list()
2018-10-16 14:56:18 +02:00
2019-06-20 00:20:09 +02:00
assert(accs.length === 10)
assert((await accs[5].getBalance()).ocn === 0)
assert(typeof accs[0].getId() === 'string')
2018-10-05 12:34:18 +02:00
})
2018-10-16 14:56:18 +02:00
})
2018-10-05 12:34:18 +02:00
})