From dd599c9f17dc317303a8f4f4317219abebdbc8e3 Mon Sep 17 00:00:00 2001 From: "Pablo F. Mescher" Date: Wed, 15 Jan 2020 11:42:52 +0100 Subject: [PATCH] Fixed broken tests Signed-off-by: Pablo F. Mescher --- src/aquarius/Aquarius.ts | 2 +- test/aquarius/Aquarius.test.ts | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/aquarius/Aquarius.ts b/src/aquarius/Aquarius.ts index 5cbbfc2..d6984f8 100644 --- a/src/aquarius/Aquarius.ts +++ b/src/aquarius/Aquarius.ts @@ -26,7 +26,7 @@ export interface SearchQuery { * Aquarius provides an off-chain database store for metadata about data assets. */ export class Aquarius { - private fetch: WebServiceConnector + public fetch: WebServiceConnector private logger: Logger private aquariusUri: string diff --git a/test/aquarius/Aquarius.test.ts b/test/aquarius/Aquarius.test.ts index e0465eb..7065de6 100644 --- a/test/aquarius/Aquarius.test.ts +++ b/test/aquarius/Aquarius.test.ts @@ -5,6 +5,7 @@ import { Aquarius, SearchQuery } from '../../src/aquarius/Aquarius' import { DDO } from '../../src/ddo/DDO' import DID from '../../src/ocean/DID' import config from '../config' +import { Logger } from '../../src/utils' use(spies) @@ -53,7 +54,7 @@ describe('Aquarius', () => { } as SearchQuery it('should query metadata', async () => { - spy.on(ocean.utils.fetch, 'post', () => reponsify(getResults([new DDO()]))) + spy.on(aquarius.fetch, 'post', () => reponsify(getResults([new DDO()]))) const result = await aquarius.queryMetadata(query) assert.typeOf(result.results, 'array') @@ -64,7 +65,7 @@ describe('Aquarius', () => { }) it('should query metadata and return real ddo', async () => { - spy.on(ocean.utils.fetch, 'post', () => reponsify(getResults([new DDO()]))) + spy.on(aquarius.fetch, 'post', () => reponsify(getResults([new DDO()]))) const result = await aquarius.queryMetadata(query) assert.typeOf(result.results, 'array') @@ -87,7 +88,7 @@ describe('Aquarius', () => { } as SearchQuery it('should query metadata by text', async () => { - spy.on(ocean.utils.fetch, 'get', () => reponsify(getResults([new DDO()]))) + spy.on(aquarius.fetch, 'get', () => reponsify(getResults([new DDO()]))) const result = await aquarius.queryMetadataByText(query) assert.typeOf(result.results, 'array') @@ -98,9 +99,9 @@ describe('Aquarius', () => { }) it('should query metadata by text with a new instance', async () => { - spy.on(ocean.utils.fetch, 'get', () => reponsify(getResults([new DDO()]))) - - const aquariusNew = new Aquarius(config.aquariusUri, ocean.utils, null) + const aquariusNew = new Aquarius(config.aquariusUri, new Logger()) + spy.on(aquariusNew.fetch, 'get', () => reponsify(getResults([new DDO()]))) + const result = await aquariusNew.queryMetadataByText(query) assert.typeOf(result.results, 'array') assert.lengthOf(result.results, 1) @@ -110,7 +111,7 @@ describe('Aquarius', () => { }) it('should query metadata and return real ddo', async () => { - spy.on(ocean.utils.fetch, 'get', () => reponsify(getResults([new DDO()]))) + spy.on(aquarius.fetch, 'get', () => reponsify(getResults([new DDO()]))) const result = await aquarius.queryMetadataByText(query) assert.typeOf(result.results, 'array') @@ -126,7 +127,7 @@ describe('Aquarius', () => { id: did.getId() }) - spy.on(ocean.utils.fetch, 'post', () => reponsify(ddo)) + spy.on(aquarius.fetch, 'post', () => reponsify(ddo)) const result: DDO = await aquarius.storeDDO(ddo) assert(result) @@ -141,8 +142,8 @@ describe('Aquarius', () => { id: did.getId() }) - spy.on(ocean.utils.fetch, 'post', () => reponsify(ddo)) - spy.on(ocean.utils.fetch, 'get', () => reponsify(ddo)) + spy.on(aquarius.fetch, 'post', () => reponsify(ddo)) + spy.on(aquarius.fetch, 'get', () => reponsify(ddo)) const storageResult: DDO = await aquarius.storeDDO(ddo) assert(storageResult)