diff --git a/src/ocean/OceanCompute.ts b/src/ocean/OceanCompute.ts index 55f9206..488c467 100644 --- a/src/ocean/OceanCompute.ts +++ b/src/ocean/OceanCompute.ts @@ -9,7 +9,7 @@ export interface ComputeJobStatus { jobId: string dateCreated: string dateFinished: string - status: boolean + status: number statusText: string configlogUrl: string publishlogUrl: string diff --git a/test/ocean/OceanCompute.test.ts b/test/ocean/OceanCompute.test.ts new file mode 100644 index 0000000..a1fc4c6 --- /dev/null +++ b/test/ocean/OceanCompute.test.ts @@ -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) + }) + }) +})