From f1e15c9eda187188372abd32db8d4496e799a5e9 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 22 Jan 2020 11:30:27 +0100 Subject: [PATCH] more basic unit tests --- test/ocean/OceanCompute.test.ts | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/test/ocean/OceanCompute.test.ts b/test/ocean/OceanCompute.test.ts index a1fc4c6..ebcebfe 100644 --- a/test/ocean/OceanCompute.test.ts +++ b/test/ocean/OceanCompute.test.ts @@ -45,4 +45,53 @@ describe('OceanCompute', () => { assert(response.status === 6) }) }) + + describe('#restart()', () => { + it('should restart a job', async () => { + spy.on(ocean.utils.fetch, 'put', () => responsify({ status: 6 })) + spy.on(ocean.utils.fetch, 'post', () => responsify({ jobId: 'my-job-id' })) + + const response = await compute.restart(account, 'xxx', 'xxx') + assert(response.jobId === 'my-job-id') + }) + }) + + describe('#delete()', () => { + it('should delete a job', async () => { + spy.on(ocean.utils.fetch, 'delete', () => responsify({ status: 8 })) + + const response = await compute.delete(account, 'xxx', 'xxx') + assert(response.status === 8) + }) + }) + + describe('#status()', () => { + it('should get the status of one job', async () => { + spy.on(ocean.utils.fetch, 'get', () => responsify([{ status: 1 }])) + + const response = await compute.status(account, 'xxx', 'xxx') + assert(response.length === 1) + assert(response[0].status === 1) + }) + + it('should get the status of multiple jobs', async () => { + spy.on(ocean.utils.fetch, 'get', () => + responsify([{ status: 1 }, { status: 1 }]) + ) + + const response = await compute.status(account, 'xxx') + assert(response.length === 2) + assert(response[0].status === 1) + }) + + it('should get all jobs for one owner', async () => { + spy.on(ocean.utils.fetch, 'get', () => + responsify([{ status: 1 }, { status: 1 }]) + ) + + const response = await compute.status(account) + assert(response.length === 2) + assert(response[0].status === 1) + }) + }) })