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

setup compute unit tests

This commit is contained in:
Matthias Kretschmann 2020-01-21 21:21:19 +01:00
parent 6b52d4dbaa
commit db689aab63
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 49 additions and 1 deletions

View File

@ -9,7 +9,7 @@ export interface ComputeJobStatus {
jobId: string jobId: string
dateCreated: string dateCreated: string
dateFinished: string dateFinished: string
status: boolean status: number
statusText: string statusText: string
configlogUrl: string configlogUrl: string
publishlogUrl: string publishlogUrl: string

View File

@ -0,0 +1,48 @@
import { assert, spy, use } from 'chai'
import spies from 'chai-spies'
import { Ocean } from '../../src/ocean/Ocean'
import config from '../config'
import { Account } from '../../src/squid'
import { OceanCompute } from '../../src/ocean/OceanCompute'
use(spies)
const responsify = async data => ({
ok: true,
json: () => Promise.resolve(data)
})
describe('OceanCompute', () => {
let ocean: Ocean
let account: Account
let compute: OceanCompute
before(async () => {
ocean = await Ocean.getInstance(config)
;[account] = await ocean.accounts.list()
compute = ocean.compute // eslint-disable-line prefer-destructuring
})
afterEach(() => {
spy.restore()
})
describe('#start()', () => {
it('should start a new job', async () => {
spy.on(ocean.utils.fetch, 'post', () => responsify({ jobId: 'my-job-id' }))
const response = await compute.start(account, 'xxx', 'xxx')
assert(response.jobId === 'my-job-id')
})
})
describe('#stop()', () => {
it('should stop a job', async () => {
spy.on(ocean.utils.fetch, 'put', () => responsify({ status: 6 }))
const response = await compute.stop(account, 'xxx', 'xxx')
assert(response.status === 6)
})
})
})